QR Code Barcode Dimension Size using C#

Developer Guide for QR Code 2D barcode image dimension size (width & height) in C#

Setting QR Code Barcode Size in C#


QR Code Structure

  • W : the width of QR Code image (including quiet zone).
  • H : the height of QR Code image (including quiet zone).
  • X : the width of QR Code module.
  • Q : the width of the quiet zone; Q = 4X.



Setting QR Code Barcode Size in C#

Basic information you should know

QR Code images sizes range from Version 1 to Version 40 and the image size is determined as long as the image version and module size are determined.



  • V : the version of QR Code, ranging from Version 1 to Version 40.


As for QR Code image version, it is decided by the amount of your input data. And the maximum data capacity for each QR Code symbol version is specified in ISO/IEC 18004:2006.

The QR Code barcode width, W (measured in pixel), including quiet zone, can be computed from the following expression:

W = [ 8 * 2 + ( 4V + 1) ] X + 2Q

W is equal to the value of QR Code image height (H).


Three Situations for Setting QR Code Barcode Size in C#

Setting QR Code barcode size in C# QR Code Generation Components may have three situations:

Situation 1:

If you need to create a QR Code with a minimum X, the following steps should be adopted:
  • Set QR Code property X to the minimum value.
  • Set QR Code property AutoResize value to false.
  • Customize other QR Code properties.
Eg1. You set in C# QR Code generator:
qrcode.X = 4;
qrcode.AutoResize = false;
Other properties: default;
The created QR Code image is:


Situation 2:

If you need to create a QR Code with fixed barcode image width (W) and height (H), also try to draw maximum barcode module (X) as possible, the steps below should be adopted:
  • Set QR Code property Width and Height to the fixed value.
  • Set QR Code property AutoResize value to true.
  • Customize other QR Code properties.
Eg2. You set in C# QR Code generator:
qrcode.BarcodeWidth = 120;
qrcode.BarcodeHeight = 120;
qrcode.AutoResize = true;
Other properties: default.
The created QR Code image is:

In the above QR Code image, the bar module (X) is 5 pixel, which is the maximum bar module.


Situation 3:

If you need to create a QR Code with minimum X, fixed barcode image width (W) and height (H), the following steps should be adopted:
  • Set QR Code property X to the minimum value.
  • Set QR Code property Width and Height to the fixed value.
  • Set QR Code property AutoResize value to false.
  • Customize other QR Code properties.
Eg3. You set in C# QR Code generator:
qrcode.X = 3;
qrcode.BarcodeWidth = 100;
qrcode.BarcodeHeight = 100;
qrcode.AutoResize = false;
Other properties: default;
The created QR Code image is:


Note that, there will be a minimum barcode image width and height defined by QR Code ISO specification as long as you set the bar module (X) value.

QR Code minimum barcode image width (W min) is:

W = [ 8 * 2 + ( 4 * 1 + 1) ] X + 2Q      //Q = 0 (default by C# QR Code generator)

W is equal to the value of QR Code image height (H).

Thereby, if your BarcodeWidth value is less than the minimum barcode width, the barcode generator component will reset BarcodeWidth value to the minimum barcode width value.

For instance, you set in C# QR Code generator:

qrcode.X = 6;
qrcode.BarcodeWidth = 100;
qrcode.BarcodeHeight = 100;
qrcode.AutoResize = false;
Other properties: default.
Then QR Code barcode minimum width (W min) is:
W = [ 8 * 2 + ( 4 * 1 + 1) ] X + 2Q      //Q = 0 (default by C# QR Code generator)
    = ( 16 + 5 ) X
    = 21X       //X = 6
    = 126 pixel

Now your BarcodeWidth setting is 100 pixel, which is less than the minimum barcode width (126 pixel), the component generated QR Code image will be like this.


If your BarcodeWidth setting is 150 pixel, which is larger than the minimum barcode width (126 pixel), the generated QR Code image will be like below.






OnBarcode is a market-leading provider of barcode imaging generator, reader controls and components for ASP.NET, Windows Forms, WPF, as well Java, Android, iOS (iPhone, iPad) across all major enterprise development platforms. We provides comprehensive tutorials and how-tos for various linear, 2d barcode information, such as C# in ASP.NET, C# .NET, C# Barcode Encoding, C# Barcode Image, VB.NET in ASP.NET, VB.NET Winforms, VB.NET Barcode Encoding. OnBarcode barcode products are supported by RasterEdge ASP.NET Document Viewer, which supports ASP.NET PDF Viewer, ASP.NET MVC Document Viewer, ASP.NET PDF Editor, MVC PDF Viewer. And provide high quality C# Convert PDF to Tiff, C# Convert PDF to Word, C# Convert PDF to HTML, C# Convert PDF to Jpeg images, and their easy and simple documents, like C# PDF SDK, C# extract text from PDF, C# Compress PDF, Print PDF in C# and C# extract image from PDF.
Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.