Advanced usage QR Code renderers

Shane Krueger edited this page Oct 6, 2025 · 42 revisions
  1. Introduction to the "QR Code Renderers"
  2. Overview of the different Renderers
    2.1. QRCode-Renderer in detail
    2.2. AsciiQRCode-Renderer in detail
    2.3. Base64QRCode-Renderer in detail
    2.4. BitmapByteQRCode-Renderer in detail
    2.5. PngByteQRCode-Renderer in detail
    2.6. SvgQRCode-Renderer in detail
    2.7. UnityQRCode-Renderer in detail
    2.8. XamlQRCode-Renderer in detail
    2.9. PostscriptQRCode-Renderer in detail
    2.10. PdfByteQRCode-Renderer in detail
    2.11. ArtQRCode-Renderer in detail

1. Introduction to the "QR Code Renderers"

As explained in the architectural overview, the QRCoder separates data/information from output/representation. So in data/core layer you create the QR Code information:

CodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The payload aka the text which should be encoded.",QRCodeGenerator.ECCLevel.Q);

Now you have to bring this information into a representation you like - or better said - you have to convert this information into the output format you like. Therefore you can use the so called "QR Code renderers". This are classes of the QRCoder which help you to represent that QrCodeData the way you prefer. Each renderer-class has a function called "GetGraphic" which returns the graphical representation of the QR Code.

Before we have a look at each of the renderers, let's have a quick look onto the following comparison table which shows the benefits of each of the renderer classes.

2. Overview of the different Renderers

The following table gives an overview of which renderer is available on which target platforms and which datatype it generates.

NameOutput Format.NET3.5+.NET4.0+.NET5.0.NET5.0-windows.NET6.0.NET6.0-windows.NETStandard1.3+.NETStandard2.0+
QRCodeBitmap-object (System.Drawing.Bitmap)(2)
AsciiQrCodeString (QR Code encoded as ASCII chars)
Base64QRCodeString (QR Code encoded as Base64)(1)
BitmapByteQRCodeByte-Array containing raw Bitmap
PngByteQRCodeByte-Array containing raw PNG image
SvgQRCodeString (QR Coded as SVG vector graphic)
UnityQRCode (via QRCoder.Unity nuget-package)Texture2D (UnityEngine.Texture2D)
XamlQRCode (via QRCoder.Xaml nuget-package)DrawingImage (for usage in WPF, Silverlight, etc.)
PostscriptQRCodeString (QR code encoded as PS/EPS string.)
PdfByteQRCodeByte-Array containing raw PDF document
ArtQRCodeBitmap-object (System.Drawing.Bitmap)(2)

(1)On platforms other than Windows only PNG is supported in Base64QRCode

(2)Only supported on Windows

2.1 QRCode-Renderer in detail

Classname/Classfile: QRCode/QRCode.cs

When to use?

Use it if you want a pixel-based image (=Bitmap) and if you are working with .NET Framework. Use it if you want to show the QR Code in your app, save the QR Code as image file or deliver the QR Code as download.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);QRCodeqrCode=newQRCode(qrCodeData);BitmapqrCodeImage=qrCode.GetGraphic(20);

Parameter table

There are four different overloads:

Overload 1(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 3(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 4(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
iconBitmapnullIf null, then ignored. If set, the Bitmap is drawn in the middle of the QR Code
iconSizePercentint15Value from 1-99. Sets how much % of the QR Code will be covered by the icon
iconBorderWidthint6Width of the border which is drawn around the icon. Minimum: 1
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
iconBackgroundColorColor?nullDefines the background color of the icon. If null(=default) the value of lightColoris used. (Icon background is only rendered and thus iconBackgroundColor is only used, if parameter icon != null and iconBorderWidth > 0.)

Good to know

This renderer is the way to go, if you want to draw an icon onto the QR Code.In most cases this renderer fits the needs very well.

2.2 AsciiQRCode-Renderer in detail

Classname/Classfile: ASCIIQRCode / ASCIIQRCode.cs

When to use?

Useful for web-, retro- and console-environments. By use of this encoder you get a QR code encoded as string just build out of chars. By default UTF-8 block symbols are used.

Trivia:The renderer is called Ascii renderer, although it uses characters from the Utf-8 character set by default. The idea behind this is that the renderer uses a text-based graphical representation that is reminiscent of classic Ascii art. Naming it Utf8QrCode was rejected in the design phase, as it would be difficult to deduce from this name what type of return value the renderer has.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);AsciiQRCodeqrCode=newAsciiQRCode(qrCodeData);stringqrCodeAsAsciiArt=qrCode.GetGraphic(1);

Parameter table

There are three different overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
repeatPerModuleintNumber of repeated darkColorString/whiteSpaceString per module. (Must be 1 or greater.)
darkColorStringstring██String for use as dark color modules. In case of string make sure whiteSpaceString has the same length.
whiteSpaceStringstringString for use as white modules (whitespace). In case of string make sure darkColorString has the same length.
drawQuietZonesbooltrueIf true a white border is "drawn" around the whole QR Code
endOfLinestring\nEnd of line separator.

Overload 2(Functionname: GetLineByLineGraphic, Return type: string[])

Parameter nameTypeDefaultDescription
repeatPerModuleintNumber of repeated darkColorString/whiteSpaceString per module.
darkColorStringstring██String for use as dark color modules. In case of string make sure whiteSpaceString has the same length.
whiteSpaceStringstringString for use as white modules (whitespace). In case of string make sure darkColorString has the same length.
drawQuietZonesbooltrueIf true a white border is "drawn" around the whole QR Code.

Overload 3(Functionname: GetGraphicSmall, Return type: string)

Parameter nameTypeDefaultDescription
drawQuietZonesbooltrueIf true a border is "drawn" around the whole QR Code.
invertboolfalseIf set to true, light- and dark color will be switched.
endOfLinestring\nEnd of line separator.

Good to know

If you set darkColorString or whiteSpaceString you have to ensure that they are both of the same length. Also you should keep in mind that this type of rendering only works when shown in a so called "Monospace" font. If you need a smaller representation than GetGraphic with repeatPerModule: 1, use GetGraphicSmall which compresses two module lines into one character line each.

2.3 Base64QRCode-Renderer in detail

Classname/Classfile: Base64QRCode / Base64QRCode.cs

When to use?

Usually very helpful in web and database environments. You can embed the Base64 images into html code, easily trafer them via HTTP requests or write them into databases without any hassle.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);Base64QRCodeqrCode=newBase64QRCode(qrCodeData);stringqrCodeImageAsBase64=qrCode.GetGraphic(20);

Parameter table

There are four different overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
iconBitmapnullIf null, then ignored. If set, the Bitmap is drawn in the middle of the QR Code
iconSizePercentint15Value from 1-99. Sets how much % of the QR Code will be covered by the icon
iconBorderWidthint6Width of the border which is drawn around the icon. Minimum: 1
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Good to know

The string returned by the GetGraphic-method just contains the image as Base64 string. It does not contain any HTML tags, etc. If you like to embed the image for example, you have to add the img-tag. E.g.

//...varimgType=Base64QRCode.ImageType.Jpeg;Base64QRCodeqrCode=newBase64QRCode(qrCodeData);stringqrCodeImageAsBase64=qrCode.GetGraphic(20,Color.Black,Color.White,true,imgType);varhtmlPictureTag=$"<img alt=\"Embedded QR Code\" src=\"data:image/{imgType.ToString().ToLower()};base64,{qrCodeImageAsBase64}\" />";

2.4 BitmapByteQRCode-Renderer in detail

Classname/Classfile: BitmapByteQRCode / BitmapByteQRCode.cs

When to use?

When using the PCL version of the QRCoder (e.g. in mobile projects) this is, besides PngByteQRCode, the only available renderer. It returns the QR code as byte-array which contains a Bitmap graphic. Since many of the platforms where the PCL library is available have different implementations of Bitmap class, but nearly any platform can create an image from byte[], this is some way of dealing with images cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);BitmapByteQRCodeqrCode=newBitmapByteQRCode(qrCodeData);byte[]qrCodeAsBitmapByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-image code //e.g. Windows 10 - Full .NET FrameworkBitmapbmp;using(varms=newMemoryStream(qrCodeAsBitmapByteArr)){qrCodeImage=newBitmap(ms);}//e.g. Windows 10 Universal App (UAP)using(InMemoryRandomAccessStreamstream=newInMemoryRandomAccessStream()){using(DataWriterwriter=newDataWriter(stream.GetOutputStreamAt(0))){writer.WriteBytes(qrCodeImage);awaitwriter.StoreAsync();}varimage=newBitmapImage();awaitimage.SetSourceAsync(stream);imageViewer.Source=image;}

Parameter table

There are two overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorRgbabyte[]The color of the dark modules, as RGB array
lightColorRgbabyte[]The color of the light modules, as RGB array

Good to know

Since this method shall be 100% platform independent the Bitmap in the byte[] is created manually byte by byte. So this renderer doesn't offer any fancy parameters right now. If you are an Bitmap expert feel free to improve the code. If you aren't but want a cool QR code, use the QR code module matrix and create your own renderer.

2.5 PngByteQRCode-Renderer in detail

Classname/Classfile: PngByteQRCode / PngByteQRCode.cs

When to use?

When using the PCL version of the QRCoder (e.g. in mobile projects) this is, besides BitmapByteQRCode, the available renderer. It returns the QR code as byte-array which contains a PNG graphic. Since many of the platforms where the PCL library is available have different implementations of Imaging classes, but nearly any platform can create an image from byte[] (or write a byte-array to file), this is some way of dealing with images cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PngByteQRCodeqrCode=newPngByteQRCode(qrCodeData);byte[]qrCodeAsPngByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-image code //e.g. Windows 10 - Full .NET FrameworkBitmapbmp;using(varms=newMemoryStream(qrCodeAsPngByteArr)){qrCodeImage=newBitmap(ms);}//e.g. Windows 10 Universal App (UAP)using(InMemoryRandomAccessStreamstream=newInMemoryRandomAccessStream()){using(DataWriterwriter=newDataWriter(stream.GetOutputStreamAt(0))){writer.WriteBytes(qrCodeAsPngByteArr);awaitwriter.StoreAsync();}varimage=newBitmapImage();awaitimage.SetSourceAsync(stream);imageViewer.Source=image;}

Parameter table

There are three overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorRgbabyte[]The color of the dark modules, as RGB(A) array
lightColorRgbabyte[]The color of the light modules, as RGB(A) array
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 3(Return type: byte[])
Not available under NET_STANDARD_1_3

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Good to know

Since this method shall be 100% platform independent the Png in the byte[] is created manually byte by byte. So this renderer doesn't offer any fancy parameters right now. If you are an Png expert feel free to improve the code. If you aren't but want a cool QR code, use the QR code module matrix and create your own renderer.

2.6 SvgQRCode-Renderer in detail

Classname/Classfile: SvgQRCode / SvgQRCode.cs

When to use?

Use this if you want to print the QR code in a huge size or when dealing with scalable (in sense of screensize) web applications. The SvgQRCode returns a scalable vector graphic which never gets blurry by its nature.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);SvgQRCodeqrCode=newSvgQRCode(qrCodeData);stringqrCodeAsSvg=qrCode.GetGraphic(20);

Parameter table

There are six overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 5(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 6(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Good to know

The string returned just contains the plain SVG. You can save it to file via StreamWriter-class or File.WriteAllText-method or you can embed into a website. But don't forget to write the correct tags around the SVG string. (Have a look here.)

2.7 UnityQRCode-Renderer in detail

Classname/Classfile:(external) See QRCoder.Unity-repository

When to use?

Use this renderer if you are working on an Unity-based app or game. This renderer return a Texture2D object for easier handling. It saves you some time, compared to the other renders.

How to use it - simple way

Install via Nuget: PM> Install-Package QRCoder.Unity
(QRCoder.Unity@nuget)

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);UnityQRCodeqrCode=newUnityQRCode(qrCodeData);Texture2DqrCodeAsTexture2D=qrCode.GetGraphic(20);

Parameter table

There are 3 overloads:

Overload 1(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation

Overload 3(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorUnityEngine.ColorThe color of the dark/black modules
lightColorUnityEngine.ColorThe color of the light/white modules

Good to know

This renderer is some kind of experimental. There are some reports that it sometimes is buggy on iOS devices, whilst Android, Windows and Linux should be working fine. So please test your project in an appropriate manner when using this renderer.

2.8 XamlQRCode-Renderer in detail

Classname/Classfile: XamlQRCode / XamlQRCode.cs

When to use?

Use this if you want to print the QR code in an XAML application (e.g. WPF, Silverlight). The XamlQRCode returns a scalable vector XAML object tree which never gets blurry by its nature.

How to use it - simple way

Install via Nuget: PM> Install-Package QRCoder.Xaml
(QRCoder.Xaml@nuget)

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);XamlQRCodeqrCode=newXamlQRCode(qrCodeData);DrawingImageqrCodeAsXaml=qrCode.GetGraphic(20);

Parameter table

There are five overloads:

Overload 1(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size

Overload 2(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
drawQuietZonesboolIf true a white border is drawn around the whole QR Code

Overload 3(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 4(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 5(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkBrushBrushThe brush of the dark/black modules
lightBrushBrushThe brush of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Good to know

The object tree returned can be assigned to an System.Windows.Controls.Image (<Image> in XAML) element's Source property. In the MVVM approach, the Source property can be bound to a model's string property and QR generation code can be implemented as an IValueConverter to convert a string value to QR code and return the System.Windows.Media.DrawingImage generated.

The <Image> element uses anti-aliased rendering by default, which makes the readability of a QR code worse. In order to display it with aliased rendering, set the RenderOptions.EdgeMode attached property to "Aliased".

2.9 PostscriptQRCode-Renderer in detail

Classname/Classfile: PostscriptQRCode / PostscriptQRCode.cs

When to use?

Use this if you want to print the QR code on a postscript printer or if you want to create a pdf file.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PostscriptQRCodeqrCode=newPostscriptQRCode(qrCodeData);stringqrCodeAsPostscript=qrCode.GetGraphic(20);

Parameter table

There are six overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
epsModeboolfalseIf true, create the file as Encapsulated Postscript (EPS)

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 5(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 6(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Good to know

The string returned just contains the plain Postscript. You can save it to file via StreamWriter-class or File.WriteAllText-method.

2.10 PdfByteQRCode-Renderer in detail

Classname/Classfile: PdfByteQRCode / PdfByteQRCode.cs

When to use?

This renderer returns the QR code as byte-array which contains a PDF document. It is available on all platforms that support System.Drawing (e.g. .NET Framework >= 3.5, .NET Standard 2.0, ...) but isn't supported in .NET Standard 1.1 environments. Since many of the platforms have different implementations of PDF classes, but any platform can write a byte[] into a file, this is some way of dealing with PDFs cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PdfByteQRCodeqrCode=newPdfByteQRCode(qrCodeData);byte[]qrCodeAsPdfByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-(PDF-)file code 

Parameter table

There are two overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark modules, as hex string e.g. #000000
lightColorHtmlHexstringThe color of the light modules, as hex string e.g. #ffffff
dpiint150DPI (dots per inch) resolution of the PDF document
jpgQualitylong85Quality of the QR code graphic inside the PDF. From 1 (bad) to 100 (perfect).

Good to know

n/a

2.11 ArtQRCode-Renderer in detail

Classname/Classfile: QRCode/ArtQRCode.cs

When to use?

Use it if you want a pixel-based image (=Bitmap) with a more "artistic" style. You can set background images and define how the module are rendered. (As default they will be rendered as dots/circular).

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);ArtQRCodeqrCode=newArtQRCode(qrCodeData);BitmapqrCodeImage=qrCode.GetGraphic(10);

Parameter table

There are three different overloads:

Overload 1(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintAmount of px each dark/light module of the QR code shall take place in the final QR code image

Overload 2(Return type: Bitmap)

Parameter nameTypeDefaultDescription
backgroundImageBitmapnullA bitmap object that will be used as background picture

Overload 3(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorColor of the dark modules
lightColorColorColor of the light modules
backgroundColorColorColor of the background
backgroundImageBitmapnullA bitmap object that will be used as background picture
pixelSizeFactordouble1.0Value between 0.0 to 1.0 that defines how big the module dots are. The bigger the value, the less round the dots will be.
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
quietZoneRenderingStyleQuietZoneStyleQuietZoneStyle.DottedDefines how the quiet zones shall be rendered. (Dotted or flat/filled.)
backgroundImageStyleBackgroundImageStyleBackgroundImageStyle.DataAreaOnlyStyle of the background image (if set). Fill=spanning complete graphic; DataAreaOnly=Don't paint background into quietzone
finderPatternImageBitmapnullOptional image that should be used instead of the default finder patterns

Good to know

This renderer allows the creation of visually appealing/beautiful QR codes, but it should be noted that the official QRCode standard does not provide for such a form. Depending on the background image used or if the pixelSizeFactor-value is too small, the QRCode may be recognized worse or not at all. This risk cannot be avoided and is the responsibility of the respective developer who includes the ArtQRCode in his/her application.

Clone this wiki locally

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Advanced usage QR Code renderers

Shane Krueger edited this page Oct 6, 2025 · 42 revisions
  1. Introduction to the "QR Code Renderers"
  2. Overview of the different Renderers
    2.1. QRCode-Renderer in detail
    2.2. AsciiQRCode-Renderer in detail
    2.3. Base64QRCode-Renderer in detail
    2.4. BitmapByteQRCode-Renderer in detail
    2.5. PngByteQRCode-Renderer in detail
    2.6. SvgQRCode-Renderer in detail
    2.7. UnityQRCode-Renderer in detail
    2.8. XamlQRCode-Renderer in detail
    2.9. PostscriptQRCode-Renderer in detail
    2.10. PdfByteQRCode-Renderer in detail
    2.11. ArtQRCode-Renderer in detail

1. Introduction to the "QR Code Renderers"

As explained in the architectural overview, the QRCoder separates data/information from output/representation. So in data/core layer you create the QR Code information:

CodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The payload aka the text which should be encoded.",QRCodeGenerator.ECCLevel.Q);

Now you have to bring this information into a representation you like - or better said - you have to convert this information into the output format you like. Therefore you can use the so called "QR Code renderers". This are classes of the QRCoder which help you to represent that QrCodeData the way you prefer. Each renderer-class has a function called "GetGraphic" which returns the graphical representation of the QR Code.

Before we have a look at each of the renderers, let's have a quick look onto the following comparison table which shows the benefits of each of the renderer classes.

2. Overview of the different Renderers

The following table gives an overview of which renderer is available on which target platforms and which datatype it generates.

NameOutput Format.NET3.5+.NET4.0+.NET5.0.NET5.0-windows.NET6.0.NET6.0-windows.NETStandard1.3+.NETStandard2.0+
QRCodeBitmap-object (System.Drawing.Bitmap)(2)
AsciiQrCodeString (QR Code encoded as ASCII chars)
Base64QRCodeString (QR Code encoded as Base64)(1)
BitmapByteQRCodeByte-Array containing raw Bitmap
PngByteQRCodeByte-Array containing raw PNG image
SvgQRCodeString (QR Coded as SVG vector graphic)
UnityQRCode (via QRCoder.Unity nuget-package)Texture2D (UnityEngine.Texture2D)
XamlQRCode (via QRCoder.Xaml nuget-package)DrawingImage (for usage in WPF, Silverlight, etc.)
PostscriptQRCodeString (QR code encoded as PS/EPS string.)
PdfByteQRCodeByte-Array containing raw PDF document
ArtQRCodeBitmap-object (System.Drawing.Bitmap)(2)

(1)On platforms other than Windows only PNG is supported in Base64QRCode

(2)Only supported on Windows

2.1 QRCode-Renderer in detail

Classname/Classfile: QRCode/QRCode.cs

When to use?

Use it if you want a pixel-based image (=Bitmap) and if you are working with .NET Framework. Use it if you want to show the QR Code in your app, save the QR Code as image file or deliver the QR Code as download.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);QRCodeqrCode=newQRCode(qrCodeData);BitmapqrCodeImage=qrCode.GetGraphic(20);

Parameter table

There are four different overloads:

Overload 1(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 3(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 4(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
iconBitmapnullIf null, then ignored. If set, the Bitmap is drawn in the middle of the QR Code
iconSizePercentint15Value from 1-99. Sets how much % of the QR Code will be covered by the icon
iconBorderWidthint6Width of the border which is drawn around the icon. Minimum: 1
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
iconBackgroundColorColor?nullDefines the background color of the icon. If null(=default) the value of lightColoris used. (Icon background is only rendered and thus iconBackgroundColor is only used, if parameter icon != null and iconBorderWidth > 0.)

Good to know

This renderer is the way to go, if you want to draw an icon onto the QR Code.In most cases this renderer fits the needs very well.

2.2 AsciiQRCode-Renderer in detail

Classname/Classfile: ASCIIQRCode / ASCIIQRCode.cs

When to use?

Useful for web-, retro- and console-environments. By use of this encoder you get a QR code encoded as string just build out of chars. By default UTF-8 block symbols are used.

Trivia:The renderer is called Ascii renderer, although it uses characters from the Utf-8 character set by default. The idea behind this is that the renderer uses a text-based graphical representation that is reminiscent of classic Ascii art. Naming it Utf8QrCode was rejected in the design phase, as it would be difficult to deduce from this name what type of return value the renderer has.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);AsciiQRCodeqrCode=newAsciiQRCode(qrCodeData);stringqrCodeAsAsciiArt=qrCode.GetGraphic(1);

Parameter table

There are three different overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
repeatPerModuleintNumber of repeated darkColorString/whiteSpaceString per module. (Must be 1 or greater.)
darkColorStringstring██String for use as dark color modules. In case of string make sure whiteSpaceString has the same length.
whiteSpaceStringstringString for use as white modules (whitespace). In case of string make sure darkColorString has the same length.
drawQuietZonesbooltrueIf true a white border is "drawn" around the whole QR Code
endOfLinestring\nEnd of line separator.

Overload 2(Functionname: GetLineByLineGraphic, Return type: string[])

Parameter nameTypeDefaultDescription
repeatPerModuleintNumber of repeated darkColorString/whiteSpaceString per module.
darkColorStringstring██String for use as dark color modules. In case of string make sure whiteSpaceString has the same length.
whiteSpaceStringstringString for use as white modules (whitespace). In case of string make sure darkColorString has the same length.
drawQuietZonesbooltrueIf true a white border is "drawn" around the whole QR Code.

Overload 3(Functionname: GetGraphicSmall, Return type: string)

Parameter nameTypeDefaultDescription
drawQuietZonesbooltrueIf true a border is "drawn" around the whole QR Code.
invertboolfalseIf set to true, light- and dark color will be switched.
endOfLinestring\nEnd of line separator.

Good to know

If you set darkColorString or whiteSpaceString you have to ensure that they are both of the same length. Also you should keep in mind that this type of rendering only works when shown in a so called "Monospace" font. If you need a smaller representation than GetGraphic with repeatPerModule: 1, use GetGraphicSmall which compresses two module lines into one character line each.

2.3 Base64QRCode-Renderer in detail

Classname/Classfile: Base64QRCode / Base64QRCode.cs

When to use?

Usually very helpful in web and database environments. You can embed the Base64 images into html code, easily trafer them via HTTP requests or write them into databases without any hassle.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);Base64QRCodeqrCode=newBase64QRCode(qrCodeData);stringqrCodeImageAsBase64=qrCode.GetGraphic(20);

Parameter table

There are four different overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
iconBitmapnullIf null, then ignored. If set, the Bitmap is drawn in the middle of the QR Code
iconSizePercentint15Value from 1-99. Sets how much % of the QR Code will be covered by the icon
iconBorderWidthint6Width of the border which is drawn around the icon. Minimum: 1
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Good to know

The string returned by the GetGraphic-method just contains the image as Base64 string. It does not contain any HTML tags, etc. If you like to embed the image for example, you have to add the img-tag. E.g.

//...varimgType=Base64QRCode.ImageType.Jpeg;Base64QRCodeqrCode=newBase64QRCode(qrCodeData);stringqrCodeImageAsBase64=qrCode.GetGraphic(20,Color.Black,Color.White,true,imgType);varhtmlPictureTag=$"<img alt=\"Embedded QR Code\" src=\"data:image/{imgType.ToString().ToLower()};base64,{qrCodeImageAsBase64}\" />";

2.4 BitmapByteQRCode-Renderer in detail

Classname/Classfile: BitmapByteQRCode / BitmapByteQRCode.cs

When to use?

When using the PCL version of the QRCoder (e.g. in mobile projects) this is, besides PngByteQRCode, the only available renderer. It returns the QR code as byte-array which contains a Bitmap graphic. Since many of the platforms where the PCL library is available have different implementations of Bitmap class, but nearly any platform can create an image from byte[], this is some way of dealing with images cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);BitmapByteQRCodeqrCode=newBitmapByteQRCode(qrCodeData);byte[]qrCodeAsBitmapByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-image code //e.g. Windows 10 - Full .NET FrameworkBitmapbmp;using(varms=newMemoryStream(qrCodeAsBitmapByteArr)){qrCodeImage=newBitmap(ms);}//e.g. Windows 10 Universal App (UAP)using(InMemoryRandomAccessStreamstream=newInMemoryRandomAccessStream()){using(DataWriterwriter=newDataWriter(stream.GetOutputStreamAt(0))){writer.WriteBytes(qrCodeImage);awaitwriter.StoreAsync();}varimage=newBitmapImage();awaitimage.SetSourceAsync(stream);imageViewer.Source=image;}

Parameter table

There are two overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorRgbabyte[]The color of the dark modules, as RGB array
lightColorRgbabyte[]The color of the light modules, as RGB array

Good to know

Since this method shall be 100% platform independent the Bitmap in the byte[] is created manually byte by byte. So this renderer doesn't offer any fancy parameters right now. If you are an Bitmap expert feel free to improve the code. If you aren't but want a cool QR code, use the QR code module matrix and create your own renderer.

2.5 PngByteQRCode-Renderer in detail

Classname/Classfile: PngByteQRCode / PngByteQRCode.cs

When to use?

When using the PCL version of the QRCoder (e.g. in mobile projects) this is, besides BitmapByteQRCode, the available renderer. It returns the QR code as byte-array which contains a PNG graphic. Since many of the platforms where the PCL library is available have different implementations of Imaging classes, but nearly any platform can create an image from byte[] (or write a byte-array to file), this is some way of dealing with images cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PngByteQRCodeqrCode=newPngByteQRCode(qrCodeData);byte[]qrCodeAsPngByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-image code //e.g. Windows 10 - Full .NET FrameworkBitmapbmp;using(varms=newMemoryStream(qrCodeAsPngByteArr)){qrCodeImage=newBitmap(ms);}//e.g. Windows 10 Universal App (UAP)using(InMemoryRandomAccessStreamstream=newInMemoryRandomAccessStream()){using(DataWriterwriter=newDataWriter(stream.GetOutputStreamAt(0))){writer.WriteBytes(qrCodeAsPngByteArr);awaitwriter.StoreAsync();}varimage=newBitmapImage();awaitimage.SetSourceAsync(stream);imageViewer.Source=image;}

Parameter table

There are three overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorRgbabyte[]The color of the dark modules, as RGB(A) array
lightColorRgbabyte[]The color of the light modules, as RGB(A) array
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 3(Return type: byte[])
Not available under NET_STANDARD_1_3

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Good to know

Since this method shall be 100% platform independent the Png in the byte[] is created manually byte by byte. So this renderer doesn't offer any fancy parameters right now. If you are an Png expert feel free to improve the code. If you aren't but want a cool QR code, use the QR code module matrix and create your own renderer.

2.6 SvgQRCode-Renderer in detail

Classname/Classfile: SvgQRCode / SvgQRCode.cs

When to use?

Use this if you want to print the QR code in a huge size or when dealing with scalable (in sense of screensize) web applications. The SvgQRCode returns a scalable vector graphic which never gets blurry by its nature.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);SvgQRCodeqrCode=newSvgQRCode(qrCodeData);stringqrCodeAsSvg=qrCode.GetGraphic(20);

Parameter table

There are six overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 5(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 6(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Good to know

The string returned just contains the plain SVG. You can save it to file via StreamWriter-class or File.WriteAllText-method or you can embed into a website. But don't forget to write the correct tags around the SVG string. (Have a look here.)

2.7 UnityQRCode-Renderer in detail

Classname/Classfile:(external) See QRCoder.Unity-repository

When to use?

Use this renderer if you are working on an Unity-based app or game. This renderer return a Texture2D object for easier handling. It saves you some time, compared to the other renders.

How to use it - simple way

Install via Nuget: PM> Install-Package QRCoder.Unity
(QRCoder.Unity@nuget)

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);UnityQRCodeqrCode=newUnityQRCode(qrCodeData);Texture2DqrCodeAsTexture2D=qrCode.GetGraphic(20);

Parameter table

There are 3 overloads:

Overload 1(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation

Overload 3(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorUnityEngine.ColorThe color of the dark/black modules
lightColorUnityEngine.ColorThe color of the light/white modules

Good to know

This renderer is some kind of experimental. There are some reports that it sometimes is buggy on iOS devices, whilst Android, Windows and Linux should be working fine. So please test your project in an appropriate manner when using this renderer.

2.8 XamlQRCode-Renderer in detail

Classname/Classfile: XamlQRCode / XamlQRCode.cs

When to use?

Use this if you want to print the QR code in an XAML application (e.g. WPF, Silverlight). The XamlQRCode returns a scalable vector XAML object tree which never gets blurry by its nature.

How to use it - simple way

Install via Nuget: PM> Install-Package QRCoder.Xaml
(QRCoder.Xaml@nuget)

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);XamlQRCodeqrCode=newXamlQRCode(qrCodeData);DrawingImageqrCodeAsXaml=qrCode.GetGraphic(20);

Parameter table

There are five overloads:

Overload 1(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size

Overload 2(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
drawQuietZonesboolIf true a white border is drawn around the whole QR Code

Overload 3(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 4(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 5(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkBrushBrushThe brush of the dark/black modules
lightBrushBrushThe brush of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Good to know

The object tree returned can be assigned to an System.Windows.Controls.Image (<Image> in XAML) element's Source property. In the MVVM approach, the Source property can be bound to a model's string property and QR generation code can be implemented as an IValueConverter to convert a string value to QR code and return the System.Windows.Media.DrawingImage generated.

The <Image> element uses anti-aliased rendering by default, which makes the readability of a QR code worse. In order to display it with aliased rendering, set the RenderOptions.EdgeMode attached property to "Aliased".

2.9 PostscriptQRCode-Renderer in detail

Classname/Classfile: PostscriptQRCode / PostscriptQRCode.cs

When to use?

Use this if you want to print the QR code on a postscript printer or if you want to create a pdf file.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PostscriptQRCodeqrCode=newPostscriptQRCode(qrCodeData);stringqrCodeAsPostscript=qrCode.GetGraphic(20);

Parameter table

There are six overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
epsModeboolfalseIf true, create the file as Encapsulated Postscript (EPS)

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 5(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 6(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Good to know

The string returned just contains the plain Postscript. You can save it to file via StreamWriter-class or File.WriteAllText-method.

2.10 PdfByteQRCode-Renderer in detail

Classname/Classfile: PdfByteQRCode / PdfByteQRCode.cs

When to use?

This renderer returns the QR code as byte-array which contains a PDF document. It is available on all platforms that support System.Drawing (e.g. .NET Framework >= 3.5, .NET Standard 2.0, ...) but isn't supported in .NET Standard 1.1 environments. Since many of the platforms have different implementations of PDF classes, but any platform can write a byte[] into a file, this is some way of dealing with PDFs cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PdfByteQRCodeqrCode=newPdfByteQRCode(qrCodeData);byte[]qrCodeAsPdfByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-(PDF-)file code 

Parameter table

There are two overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark modules, as hex string e.g. #000000
lightColorHtmlHexstringThe color of the light modules, as hex string e.g. #ffffff
dpiint150DPI (dots per inch) resolution of the PDF document
jpgQualitylong85Quality of the QR code graphic inside the PDF. From 1 (bad) to 100 (perfect).

Good to know

n/a

2.11 ArtQRCode-Renderer in detail

Classname/Classfile: QRCode/ArtQRCode.cs

When to use?

Use it if you want a pixel-based image (=Bitmap) with a more "artistic" style. You can set background images and define how the module are rendered. (As default they will be rendered as dots/circular).

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);ArtQRCodeqrCode=newArtQRCode(qrCodeData);BitmapqrCodeImage=qrCode.GetGraphic(10);

Parameter table

There are three different overloads:

Overload 1(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintAmount of px each dark/light module of the QR code shall take place in the final QR code image

Overload 2(Return type: Bitmap)

Parameter nameTypeDefaultDescription
backgroundImageBitmapnullA bitmap object that will be used as background picture

Overload 3(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorColor of the dark modules
lightColorColorColor of the light modules
backgroundColorColorColor of the background
backgroundImageBitmapnullA bitmap object that will be used as background picture
pixelSizeFactordouble1.0Value between 0.0 to 1.0 that defines how big the module dots are. The bigger the value, the less round the dots will be.
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
quietZoneRenderingStyleQuietZoneStyleQuietZoneStyle.DottedDefines how the quiet zones shall be rendered. (Dotted or flat/filled.)
backgroundImageStyleBackgroundImageStyleBackgroundImageStyle.DataAreaOnlyStyle of the background image (if set). Fill=spanning complete graphic; DataAreaOnly=Don't paint background into quietzone
finderPatternImageBitmapnullOptional image that should be used instead of the default finder patterns

Good to know

This renderer allows the creation of visually appealing/beautiful QR codes, but it should be noted that the official QRCode standard does not provide for such a form. Depending on the background image used or if the pixelSizeFactor-value is too small, the QRCode may be recognized worse or not at all. This risk cannot be avoided and is the responsibility of the respective developer who includes the ArtQRCode in his/her application.

Clone this wiki locally

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Advanced usage QR Code renderers

Shane Krueger edited this page Oct 6, 2025 · 42 revisions
  1. Introduction to the "QR Code Renderers"
  2. Overview of the different Renderers
    2.1. QRCode-Renderer in detail
    2.2. AsciiQRCode-Renderer in detail
    2.3. Base64QRCode-Renderer in detail
    2.4. BitmapByteQRCode-Renderer in detail
    2.5. PngByteQRCode-Renderer in detail
    2.6. SvgQRCode-Renderer in detail
    2.7. UnityQRCode-Renderer in detail
    2.8. XamlQRCode-Renderer in detail
    2.9. PostscriptQRCode-Renderer in detail
    2.10. PdfByteQRCode-Renderer in detail
    2.11. ArtQRCode-Renderer in detail

1. Introduction to the "QR Code Renderers"

As explained in the architectural overview, the QRCoder separates data/information from output/representation. So in data/core layer you create the QR Code information:

CodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The payload aka the text which should be encoded.",QRCodeGenerator.ECCLevel.Q);

Now you have to bring this information into a representation you like - or better said - you have to convert this information into the output format you like. Therefore you can use the so called "QR Code renderers". This are classes of the QRCoder which help you to represent that QrCodeData the way you prefer. Each renderer-class has a function called "GetGraphic" which returns the graphical representation of the QR Code.

Before we have a look at each of the renderers, let's have a quick look onto the following comparison table which shows the benefits of each of the renderer classes.

2. Overview of the different Renderers

The following table gives an overview of which renderer is available on which target platforms and which datatype it generates.

NameOutput Format.NET3.5+.NET4.0+.NET5.0.NET5.0-windows.NET6.0.NET6.0-windows.NETStandard1.3+.NETStandard2.0+
QRCodeBitmap-object (System.Drawing.Bitmap)(2)
AsciiQrCodeString (QR Code encoded as ASCII chars)
Base64QRCodeString (QR Code encoded as Base64)(1)
BitmapByteQRCodeByte-Array containing raw Bitmap
PngByteQRCodeByte-Array containing raw PNG image
SvgQRCodeString (QR Coded as SVG vector graphic)
UnityQRCode (via QRCoder.Unity nuget-package)Texture2D (UnityEngine.Texture2D)
XamlQRCode (via QRCoder.Xaml nuget-package)DrawingImage (for usage in WPF, Silverlight, etc.)
PostscriptQRCodeString (QR code encoded as PS/EPS string.)
PdfByteQRCodeByte-Array containing raw PDF document
ArtQRCodeBitmap-object (System.Drawing.Bitmap)(2)

(1)On platforms other than Windows only PNG is supported in Base64QRCode

(2)Only supported on Windows

2.1 QRCode-Renderer in detail

Classname/Classfile: QRCode/QRCode.cs

When to use?

Use it if you want a pixel-based image (=Bitmap) and if you are working with .NET Framework. Use it if you want to show the QR Code in your app, save the QR Code as image file or deliver the QR Code as download.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);QRCodeqrCode=newQRCode(qrCodeData);BitmapqrCodeImage=qrCode.GetGraphic(20);

Parameter table

There are four different overloads:

Overload 1(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 3(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 4(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
iconBitmapnullIf null, then ignored. If set, the Bitmap is drawn in the middle of the QR Code
iconSizePercentint15Value from 1-99. Sets how much % of the QR Code will be covered by the icon
iconBorderWidthint6Width of the border which is drawn around the icon. Minimum: 1
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
iconBackgroundColorColor?nullDefines the background color of the icon. If null(=default) the value of lightColoris used. (Icon background is only rendered and thus iconBackgroundColor is only used, if parameter icon != null and iconBorderWidth > 0.)

Good to know

This renderer is the way to go, if you want to draw an icon onto the QR Code.In most cases this renderer fits the needs very well.

2.2 AsciiQRCode-Renderer in detail

Classname/Classfile: ASCIIQRCode / ASCIIQRCode.cs

When to use?

Useful for web-, retro- and console-environments. By use of this encoder you get a QR code encoded as string just build out of chars. By default UTF-8 block symbols are used.

Trivia:The renderer is called Ascii renderer, although it uses characters from the Utf-8 character set by default. The idea behind this is that the renderer uses a text-based graphical representation that is reminiscent of classic Ascii art. Naming it Utf8QrCode was rejected in the design phase, as it would be difficult to deduce from this name what type of return value the renderer has.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);AsciiQRCodeqrCode=newAsciiQRCode(qrCodeData);stringqrCodeAsAsciiArt=qrCode.GetGraphic(1);

Parameter table

There are three different overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
repeatPerModuleintNumber of repeated darkColorString/whiteSpaceString per module. (Must be 1 or greater.)
darkColorStringstring██String for use as dark color modules. In case of string make sure whiteSpaceString has the same length.
whiteSpaceStringstringString for use as white modules (whitespace). In case of string make sure darkColorString has the same length.
drawQuietZonesbooltrueIf true a white border is "drawn" around the whole QR Code
endOfLinestring\nEnd of line separator.

Overload 2(Functionname: GetLineByLineGraphic, Return type: string[])

Parameter nameTypeDefaultDescription
repeatPerModuleintNumber of repeated darkColorString/whiteSpaceString per module.
darkColorStringstring██String for use as dark color modules. In case of string make sure whiteSpaceString has the same length.
whiteSpaceStringstringString for use as white modules (whitespace). In case of string make sure darkColorString has the same length.
drawQuietZonesbooltrueIf true a white border is "drawn" around the whole QR Code.

Overload 3(Functionname: GetGraphicSmall, Return type: string)

Parameter nameTypeDefaultDescription
drawQuietZonesbooltrueIf true a border is "drawn" around the whole QR Code.
invertboolfalseIf set to true, light- and dark color will be switched.
endOfLinestring\nEnd of line separator.

Good to know

If you set darkColorString or whiteSpaceString you have to ensure that they are both of the same length. Also you should keep in mind that this type of rendering only works when shown in a so called "Monospace" font. If you need a smaller representation than GetGraphic with repeatPerModule: 1, use GetGraphicSmall which compresses two module lines into one character line each.

2.3 Base64QRCode-Renderer in detail

Classname/Classfile: Base64QRCode / Base64QRCode.cs

When to use?

Usually very helpful in web and database environments. You can embed the Base64 images into html code, easily trafer them via HTTP requests or write them into databases without any hassle.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);Base64QRCodeqrCode=newBase64QRCode(qrCodeData);stringqrCodeImageAsBase64=qrCode.GetGraphic(20);

Parameter table

There are four different overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
iconBitmapnullIf null, then ignored. If set, the Bitmap is drawn in the middle of the QR Code
iconSizePercentint15Value from 1-99. Sets how much % of the QR Code will be covered by the icon
iconBorderWidthint6Width of the border which is drawn around the icon. Minimum: 1
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Good to know

The string returned by the GetGraphic-method just contains the image as Base64 string. It does not contain any HTML tags, etc. If you like to embed the image for example, you have to add the img-tag. E.g.

//...varimgType=Base64QRCode.ImageType.Jpeg;Base64QRCodeqrCode=newBase64QRCode(qrCodeData);stringqrCodeImageAsBase64=qrCode.GetGraphic(20,Color.Black,Color.White,true,imgType);varhtmlPictureTag=$"<img alt=\"Embedded QR Code\" src=\"data:image/{imgType.ToString().ToLower()};base64,{qrCodeImageAsBase64}\" />";

2.4 BitmapByteQRCode-Renderer in detail

Classname/Classfile: BitmapByteQRCode / BitmapByteQRCode.cs

When to use?

When using the PCL version of the QRCoder (e.g. in mobile projects) this is, besides PngByteQRCode, the only available renderer. It returns the QR code as byte-array which contains a Bitmap graphic. Since many of the platforms where the PCL library is available have different implementations of Bitmap class, but nearly any platform can create an image from byte[], this is some way of dealing with images cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);BitmapByteQRCodeqrCode=newBitmapByteQRCode(qrCodeData);byte[]qrCodeAsBitmapByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-image code //e.g. Windows 10 - Full .NET FrameworkBitmapbmp;using(varms=newMemoryStream(qrCodeAsBitmapByteArr)){qrCodeImage=newBitmap(ms);}//e.g. Windows 10 Universal App (UAP)using(InMemoryRandomAccessStreamstream=newInMemoryRandomAccessStream()){using(DataWriterwriter=newDataWriter(stream.GetOutputStreamAt(0))){writer.WriteBytes(qrCodeImage);awaitwriter.StoreAsync();}varimage=newBitmapImage();awaitimage.SetSourceAsync(stream);imageViewer.Source=image;}

Parameter table

There are two overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorRgbabyte[]The color of the dark modules, as RGB array
lightColorRgbabyte[]The color of the light modules, as RGB array

Good to know

Since this method shall be 100% platform independent the Bitmap in the byte[] is created manually byte by byte. So this renderer doesn't offer any fancy parameters right now. If you are an Bitmap expert feel free to improve the code. If you aren't but want a cool QR code, use the QR code module matrix and create your own renderer.

2.5 PngByteQRCode-Renderer in detail

Classname/Classfile: PngByteQRCode / PngByteQRCode.cs

When to use?

When using the PCL version of the QRCoder (e.g. in mobile projects) this is, besides BitmapByteQRCode, the available renderer. It returns the QR code as byte-array which contains a PNG graphic. Since many of the platforms where the PCL library is available have different implementations of Imaging classes, but nearly any platform can create an image from byte[] (or write a byte-array to file), this is some way of dealing with images cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PngByteQRCodeqrCode=newPngByteQRCode(qrCodeData);byte[]qrCodeAsPngByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-image code //e.g. Windows 10 - Full .NET FrameworkBitmapbmp;using(varms=newMemoryStream(qrCodeAsPngByteArr)){qrCodeImage=newBitmap(ms);}//e.g. Windows 10 Universal App (UAP)using(InMemoryRandomAccessStreamstream=newInMemoryRandomAccessStream()){using(DataWriterwriter=newDataWriter(stream.GetOutputStreamAt(0))){writer.WriteBytes(qrCodeAsPngByteArr);awaitwriter.StoreAsync();}varimage=newBitmapImage();awaitimage.SetSourceAsync(stream);imageViewer.Source=image;}

Parameter table

There are three overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorRgbabyte[]The color of the dark modules, as RGB(A) array
lightColorRgbabyte[]The color of the light modules, as RGB(A) array
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 3(Return type: byte[])
Not available under NET_STANDARD_1_3

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Good to know

Since this method shall be 100% platform independent the Png in the byte[] is created manually byte by byte. So this renderer doesn't offer any fancy parameters right now. If you are an Png expert feel free to improve the code. If you aren't but want a cool QR code, use the QR code module matrix and create your own renderer.

2.6 SvgQRCode-Renderer in detail

Classname/Classfile: SvgQRCode / SvgQRCode.cs

When to use?

Use this if you want to print the QR code in a huge size or when dealing with scalable (in sense of screensize) web applications. The SvgQRCode returns a scalable vector graphic which never gets blurry by its nature.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);SvgQRCodeqrCode=newSvgQRCode(qrCodeData);stringqrCodeAsSvg=qrCode.GetGraphic(20);

Parameter table

There are six overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 5(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 6(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Good to know

The string returned just contains the plain SVG. You can save it to file via StreamWriter-class or File.WriteAllText-method or you can embed into a website. But don't forget to write the correct tags around the SVG string. (Have a look here.)

2.7 UnityQRCode-Renderer in detail

Classname/Classfile:(external) See QRCoder.Unity-repository

When to use?

Use this renderer if you are working on an Unity-based app or game. This renderer return a Texture2D object for easier handling. It saves you some time, compared to the other renders.

How to use it - simple way

Install via Nuget: PM> Install-Package QRCoder.Unity
(QRCoder.Unity@nuget)

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);UnityQRCodeqrCode=newUnityQRCode(qrCodeData);Texture2DqrCodeAsTexture2D=qrCode.GetGraphic(20);

Parameter table

There are 3 overloads:

Overload 1(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation

Overload 3(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorUnityEngine.ColorThe color of the dark/black modules
lightColorUnityEngine.ColorThe color of the light/white modules

Good to know

This renderer is some kind of experimental. There are some reports that it sometimes is buggy on iOS devices, whilst Android, Windows and Linux should be working fine. So please test your project in an appropriate manner when using this renderer.

2.8 XamlQRCode-Renderer in detail

Classname/Classfile: XamlQRCode / XamlQRCode.cs

When to use?

Use this if you want to print the QR code in an XAML application (e.g. WPF, Silverlight). The XamlQRCode returns a scalable vector XAML object tree which never gets blurry by its nature.

How to use it - simple way

Install via Nuget: PM> Install-Package QRCoder.Xaml
(QRCoder.Xaml@nuget)

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);XamlQRCodeqrCode=newXamlQRCode(qrCodeData);DrawingImageqrCodeAsXaml=qrCode.GetGraphic(20);

Parameter table

There are five overloads:

Overload 1(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size

Overload 2(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
drawQuietZonesboolIf true a white border is drawn around the whole QR Code

Overload 3(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 4(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 5(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkBrushBrushThe brush of the dark/black modules
lightBrushBrushThe brush of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Good to know

The object tree returned can be assigned to an System.Windows.Controls.Image (<Image> in XAML) element's Source property. In the MVVM approach, the Source property can be bound to a model's string property and QR generation code can be implemented as an IValueConverter to convert a string value to QR code and return the System.Windows.Media.DrawingImage generated.

The <Image> element uses anti-aliased rendering by default, which makes the readability of a QR code worse. In order to display it with aliased rendering, set the RenderOptions.EdgeMode attached property to "Aliased".

2.9 PostscriptQRCode-Renderer in detail

Classname/Classfile: PostscriptQRCode / PostscriptQRCode.cs

When to use?

Use this if you want to print the QR code on a postscript printer or if you want to create a pdf file.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PostscriptQRCodeqrCode=newPostscriptQRCode(qrCodeData);stringqrCodeAsPostscript=qrCode.GetGraphic(20);

Parameter table

There are six overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
epsModeboolfalseIf true, create the file as Encapsulated Postscript (EPS)

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 5(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 6(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Good to know

The string returned just contains the plain Postscript. You can save it to file via StreamWriter-class or File.WriteAllText-method.

2.10 PdfByteQRCode-Renderer in detail

Classname/Classfile: PdfByteQRCode / PdfByteQRCode.cs

When to use?

This renderer returns the QR code as byte-array which contains a PDF document. It is available on all platforms that support System.Drawing (e.g. .NET Framework >= 3.5, .NET Standard 2.0, ...) but isn't supported in .NET Standard 1.1 environments. Since many of the platforms have different implementations of PDF classes, but any platform can write a byte[] into a file, this is some way of dealing with PDFs cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PdfByteQRCodeqrCode=newPdfByteQRCode(qrCodeData);byte[]qrCodeAsPdfByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-(PDF-)file code 

Parameter table

There are two overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark modules, as hex string e.g. #000000
lightColorHtmlHexstringThe color of the light modules, as hex string e.g. #ffffff
dpiint150DPI (dots per inch) resolution of the PDF document
jpgQualitylong85Quality of the QR code graphic inside the PDF. From 1 (bad) to 100 (perfect).

Good to know

n/a

2.11 ArtQRCode-Renderer in detail

Classname/Classfile: QRCode/ArtQRCode.cs

When to use?

Use it if you want a pixel-based image (=Bitmap) with a more "artistic" style. You can set background images and define how the module are rendered. (As default they will be rendered as dots/circular).

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);ArtQRCodeqrCode=newArtQRCode(qrCodeData);BitmapqrCodeImage=qrCode.GetGraphic(10);

Parameter table

There are three different overloads:

Overload 1(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintAmount of px each dark/light module of the QR code shall take place in the final QR code image

Overload 2(Return type: Bitmap)

Parameter nameTypeDefaultDescription
backgroundImageBitmapnullA bitmap object that will be used as background picture

Overload 3(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorColor of the dark modules
lightColorColorColor of the light modules
backgroundColorColorColor of the background
backgroundImageBitmapnullA bitmap object that will be used as background picture
pixelSizeFactordouble1.0Value between 0.0 to 1.0 that defines how big the module dots are. The bigger the value, the less round the dots will be.
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
quietZoneRenderingStyleQuietZoneStyleQuietZoneStyle.DottedDefines how the quiet zones shall be rendered. (Dotted or flat/filled.)
backgroundImageStyleBackgroundImageStyleBackgroundImageStyle.DataAreaOnlyStyle of the background image (if set). Fill=spanning complete graphic; DataAreaOnly=Don't paint background into quietzone
finderPatternImageBitmapnullOptional image that should be used instead of the default finder patterns

Good to know

This renderer allows the creation of visually appealing/beautiful QR codes, but it should be noted that the official QRCode standard does not provide for such a form. Depending on the background image used or if the pixelSizeFactor-value is too small, the QRCode may be recognized worse or not at all. This risk cannot be avoided and is the responsibility of the respective developer who includes the ArtQRCode in his/her application.

Clone this wiki locally

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Advanced usage QR Code renderers

Shane Krueger edited this page Oct 6, 2025 · 42 revisions
  1. Introduction to the "QR Code Renderers"
  2. Overview of the different Renderers
    2.1. QRCode-Renderer in detail
    2.2. AsciiQRCode-Renderer in detail
    2.3. Base64QRCode-Renderer in detail
    2.4. BitmapByteQRCode-Renderer in detail
    2.5. PngByteQRCode-Renderer in detail
    2.6. SvgQRCode-Renderer in detail
    2.7. UnityQRCode-Renderer in detail
    2.8. XamlQRCode-Renderer in detail
    2.9. PostscriptQRCode-Renderer in detail
    2.10. PdfByteQRCode-Renderer in detail
    2.11. ArtQRCode-Renderer in detail

1. Introduction to the "QR Code Renderers"

As explained in the architectural overview, the QRCoder separates data/information from output/representation. So in data/core layer you create the QR Code information:

CodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The payload aka the text which should be encoded.",QRCodeGenerator.ECCLevel.Q);

Now you have to bring this information into a representation you like - or better said - you have to convert this information into the output format you like. Therefore you can use the so called "QR Code renderers". This are classes of the QRCoder which help you to represent that QrCodeData the way you prefer. Each renderer-class has a function called "GetGraphic" which returns the graphical representation of the QR Code.

Before we have a look at each of the renderers, let's have a quick look onto the following comparison table which shows the benefits of each of the renderer classes.

2. Overview of the different Renderers

The following table gives an overview of which renderer is available on which target platforms and which datatype it generates.

NameOutput Format.NET3.5+.NET4.0+.NET5.0.NET5.0-windows.NET6.0.NET6.0-windows.NETStandard1.3+.NETStandard2.0+
QRCodeBitmap-object (System.Drawing.Bitmap)(2)
AsciiQrCodeString (QR Code encoded as ASCII chars)
Base64QRCodeString (QR Code encoded as Base64)(1)
BitmapByteQRCodeByte-Array containing raw Bitmap
PngByteQRCodeByte-Array containing raw PNG image
SvgQRCodeString (QR Coded as SVG vector graphic)
UnityQRCode (via QRCoder.Unity nuget-package)Texture2D (UnityEngine.Texture2D)
XamlQRCode (via QRCoder.Xaml nuget-package)DrawingImage (for usage in WPF, Silverlight, etc.)
PostscriptQRCodeString (QR code encoded as PS/EPS string.)
PdfByteQRCodeByte-Array containing raw PDF document
ArtQRCodeBitmap-object (System.Drawing.Bitmap)(2)

(1)On platforms other than Windows only PNG is supported in Base64QRCode

(2)Only supported on Windows

2.1 QRCode-Renderer in detail

Classname/Classfile: QRCode/QRCode.cs

When to use?

Use it if you want a pixel-based image (=Bitmap) and if you are working with .NET Framework. Use it if you want to show the QR Code in your app, save the QR Code as image file or deliver the QR Code as download.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);QRCodeqrCode=newQRCode(qrCodeData);BitmapqrCodeImage=qrCode.GetGraphic(20);

Parameter table

There are four different overloads:

Overload 1(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 3(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 4(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
iconBitmapnullIf null, then ignored. If set, the Bitmap is drawn in the middle of the QR Code
iconSizePercentint15Value from 1-99. Sets how much % of the QR Code will be covered by the icon
iconBorderWidthint6Width of the border which is drawn around the icon. Minimum: 1
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
iconBackgroundColorColor?nullDefines the background color of the icon. If null(=default) the value of lightColoris used. (Icon background is only rendered and thus iconBackgroundColor is only used, if parameter icon != null and iconBorderWidth > 0.)

Good to know

This renderer is the way to go, if you want to draw an icon onto the QR Code.In most cases this renderer fits the needs very well.

2.2 AsciiQRCode-Renderer in detail

Classname/Classfile: ASCIIQRCode / ASCIIQRCode.cs

When to use?

Useful for web-, retro- and console-environments. By use of this encoder you get a QR code encoded as string just build out of chars. By default UTF-8 block symbols are used.

Trivia:The renderer is called Ascii renderer, although it uses characters from the Utf-8 character set by default. The idea behind this is that the renderer uses a text-based graphical representation that is reminiscent of classic Ascii art. Naming it Utf8QrCode was rejected in the design phase, as it would be difficult to deduce from this name what type of return value the renderer has.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);AsciiQRCodeqrCode=newAsciiQRCode(qrCodeData);stringqrCodeAsAsciiArt=qrCode.GetGraphic(1);

Parameter table

There are three different overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
repeatPerModuleintNumber of repeated darkColorString/whiteSpaceString per module. (Must be 1 or greater.)
darkColorStringstring██String for use as dark color modules. In case of string make sure whiteSpaceString has the same length.
whiteSpaceStringstringString for use as white modules (whitespace). In case of string make sure darkColorString has the same length.
drawQuietZonesbooltrueIf true a white border is "drawn" around the whole QR Code
endOfLinestring\nEnd of line separator.

Overload 2(Functionname: GetLineByLineGraphic, Return type: string[])

Parameter nameTypeDefaultDescription
repeatPerModuleintNumber of repeated darkColorString/whiteSpaceString per module.
darkColorStringstring██String for use as dark color modules. In case of string make sure whiteSpaceString has the same length.
whiteSpaceStringstringString for use as white modules (whitespace). In case of string make sure darkColorString has the same length.
drawQuietZonesbooltrueIf true a white border is "drawn" around the whole QR Code.

Overload 3(Functionname: GetGraphicSmall, Return type: string)

Parameter nameTypeDefaultDescription
drawQuietZonesbooltrueIf true a border is "drawn" around the whole QR Code.
invertboolfalseIf set to true, light- and dark color will be switched.
endOfLinestring\nEnd of line separator.

Good to know

If you set darkColorString or whiteSpaceString you have to ensure that they are both of the same length. Also you should keep in mind that this type of rendering only works when shown in a so called "Monospace" font. If you need a smaller representation than GetGraphic with repeatPerModule: 1, use GetGraphicSmall which compresses two module lines into one character line each.

2.3 Base64QRCode-Renderer in detail

Classname/Classfile: Base64QRCode / Base64QRCode.cs

When to use?

Usually very helpful in web and database environments. You can embed the Base64 images into html code, easily trafer them via HTTP requests or write them into databases without any hassle.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);Base64QRCodeqrCode=newBase64QRCode(qrCodeData);stringqrCodeImageAsBase64=qrCode.GetGraphic(20);

Parameter table

There are four different overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
iconBitmapnullIf null, then ignored. If set, the Bitmap is drawn in the middle of the QR Code
iconSizePercentint15Value from 1-99. Sets how much % of the QR Code will be covered by the icon
iconBorderWidthint6Width of the border which is drawn around the icon. Minimum: 1
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Good to know

The string returned by the GetGraphic-method just contains the image as Base64 string. It does not contain any HTML tags, etc. If you like to embed the image for example, you have to add the img-tag. E.g.

//...varimgType=Base64QRCode.ImageType.Jpeg;Base64QRCodeqrCode=newBase64QRCode(qrCodeData);stringqrCodeImageAsBase64=qrCode.GetGraphic(20,Color.Black,Color.White,true,imgType);varhtmlPictureTag=$"<img alt=\"Embedded QR Code\" src=\"data:image/{imgType.ToString().ToLower()};base64,{qrCodeImageAsBase64}\" />";

2.4 BitmapByteQRCode-Renderer in detail

Classname/Classfile: BitmapByteQRCode / BitmapByteQRCode.cs

When to use?

When using the PCL version of the QRCoder (e.g. in mobile projects) this is, besides PngByteQRCode, the only available renderer. It returns the QR code as byte-array which contains a Bitmap graphic. Since many of the platforms where the PCL library is available have different implementations of Bitmap class, but nearly any platform can create an image from byte[], this is some way of dealing with images cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);BitmapByteQRCodeqrCode=newBitmapByteQRCode(qrCodeData);byte[]qrCodeAsBitmapByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-image code //e.g. Windows 10 - Full .NET FrameworkBitmapbmp;using(varms=newMemoryStream(qrCodeAsBitmapByteArr)){qrCodeImage=newBitmap(ms);}//e.g. Windows 10 Universal App (UAP)using(InMemoryRandomAccessStreamstream=newInMemoryRandomAccessStream()){using(DataWriterwriter=newDataWriter(stream.GetOutputStreamAt(0))){writer.WriteBytes(qrCodeImage);awaitwriter.StoreAsync();}varimage=newBitmapImage();awaitimage.SetSourceAsync(stream);imageViewer.Source=image;}

Parameter table

There are two overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorRgbabyte[]The color of the dark modules, as RGB array
lightColorRgbabyte[]The color of the light modules, as RGB array

Good to know

Since this method shall be 100% platform independent the Bitmap in the byte[] is created manually byte by byte. So this renderer doesn't offer any fancy parameters right now. If you are an Bitmap expert feel free to improve the code. If you aren't but want a cool QR code, use the QR code module matrix and create your own renderer.

2.5 PngByteQRCode-Renderer in detail

Classname/Classfile: PngByteQRCode / PngByteQRCode.cs

When to use?

When using the PCL version of the QRCoder (e.g. in mobile projects) this is, besides BitmapByteQRCode, the available renderer. It returns the QR code as byte-array which contains a PNG graphic. Since many of the platforms where the PCL library is available have different implementations of Imaging classes, but nearly any platform can create an image from byte[] (or write a byte-array to file), this is some way of dealing with images cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PngByteQRCodeqrCode=newPngByteQRCode(qrCodeData);byte[]qrCodeAsPngByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-image code //e.g. Windows 10 - Full .NET FrameworkBitmapbmp;using(varms=newMemoryStream(qrCodeAsPngByteArr)){qrCodeImage=newBitmap(ms);}//e.g. Windows 10 Universal App (UAP)using(InMemoryRandomAccessStreamstream=newInMemoryRandomAccessStream()){using(DataWriterwriter=newDataWriter(stream.GetOutputStreamAt(0))){writer.WriteBytes(qrCodeAsPngByteArr);awaitwriter.StoreAsync();}varimage=newBitmapImage();awaitimage.SetSourceAsync(stream);imageViewer.Source=image;}

Parameter table

There are three overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorRgbabyte[]The color of the dark modules, as RGB(A) array
lightColorRgbabyte[]The color of the light modules, as RGB(A) array
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 3(Return type: byte[])
Not available under NET_STANDARD_1_3

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Good to know

Since this method shall be 100% platform independent the Png in the byte[] is created manually byte by byte. So this renderer doesn't offer any fancy parameters right now. If you are an Png expert feel free to improve the code. If you aren't but want a cool QR code, use the QR code module matrix and create your own renderer.

2.6 SvgQRCode-Renderer in detail

Classname/Classfile: SvgQRCode / SvgQRCode.cs

When to use?

Use this if you want to print the QR code in a huge size or when dealing with scalable (in sense of screensize) web applications. The SvgQRCode returns a scalable vector graphic which never gets blurry by its nature.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);SvgQRCodeqrCode=newSvgQRCode(qrCodeData);stringqrCodeAsSvg=qrCode.GetGraphic(20);

Parameter table

There are six overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 5(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 6(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Good to know

The string returned just contains the plain SVG. You can save it to file via StreamWriter-class or File.WriteAllText-method or you can embed into a website. But don't forget to write the correct tags around the SVG string. (Have a look here.)

2.7 UnityQRCode-Renderer in detail

Classname/Classfile:(external) See QRCoder.Unity-repository

When to use?

Use this renderer if you are working on an Unity-based app or game. This renderer return a Texture2D object for easier handling. It saves you some time, compared to the other renders.

How to use it - simple way

Install via Nuget: PM> Install-Package QRCoder.Unity
(QRCoder.Unity@nuget)

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);UnityQRCodeqrCode=newUnityQRCode(qrCodeData);Texture2DqrCodeAsTexture2D=qrCode.GetGraphic(20);

Parameter table

There are 3 overloads:

Overload 1(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation

Overload 3(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorUnityEngine.ColorThe color of the dark/black modules
lightColorUnityEngine.ColorThe color of the light/white modules

Good to know

This renderer is some kind of experimental. There are some reports that it sometimes is buggy on iOS devices, whilst Android, Windows and Linux should be working fine. So please test your project in an appropriate manner when using this renderer.

2.8 XamlQRCode-Renderer in detail

Classname/Classfile: XamlQRCode / XamlQRCode.cs

When to use?

Use this if you want to print the QR code in an XAML application (e.g. WPF, Silverlight). The XamlQRCode returns a scalable vector XAML object tree which never gets blurry by its nature.

How to use it - simple way

Install via Nuget: PM> Install-Package QRCoder.Xaml
(QRCoder.Xaml@nuget)

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);XamlQRCodeqrCode=newXamlQRCode(qrCodeData);DrawingImageqrCodeAsXaml=qrCode.GetGraphic(20);

Parameter table

There are five overloads:

Overload 1(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size

Overload 2(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
drawQuietZonesboolIf true a white border is drawn around the whole QR Code

Overload 3(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 4(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 5(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkBrushBrushThe brush of the dark/black modules
lightBrushBrushThe brush of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Good to know

The object tree returned can be assigned to an System.Windows.Controls.Image (<Image> in XAML) element's Source property. In the MVVM approach, the Source property can be bound to a model's string property and QR generation code can be implemented as an IValueConverter to convert a string value to QR code and return the System.Windows.Media.DrawingImage generated.

The <Image> element uses anti-aliased rendering by default, which makes the readability of a QR code worse. In order to display it with aliased rendering, set the RenderOptions.EdgeMode attached property to "Aliased".

2.9 PostscriptQRCode-Renderer in detail

Classname/Classfile: PostscriptQRCode / PostscriptQRCode.cs

When to use?

Use this if you want to print the QR code on a postscript printer or if you want to create a pdf file.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PostscriptQRCodeqrCode=newPostscriptQRCode(qrCodeData);stringqrCodeAsPostscript=qrCode.GetGraphic(20);

Parameter table

There are six overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
epsModeboolfalseIf true, create the file as Encapsulated Postscript (EPS)

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 5(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 6(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Good to know

The string returned just contains the plain Postscript. You can save it to file via StreamWriter-class or File.WriteAllText-method.

2.10 PdfByteQRCode-Renderer in detail

Classname/Classfile: PdfByteQRCode / PdfByteQRCode.cs

When to use?

This renderer returns the QR code as byte-array which contains a PDF document. It is available on all platforms that support System.Drawing (e.g. .NET Framework >= 3.5, .NET Standard 2.0, ...) but isn't supported in .NET Standard 1.1 environments. Since many of the platforms have different implementations of PDF classes, but any platform can write a byte[] into a file, this is some way of dealing with PDFs cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PdfByteQRCodeqrCode=newPdfByteQRCode(qrCodeData);byte[]qrCodeAsPdfByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-(PDF-)file code 

Parameter table

There are two overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark modules, as hex string e.g. #000000
lightColorHtmlHexstringThe color of the light modules, as hex string e.g. #ffffff
dpiint150DPI (dots per inch) resolution of the PDF document
jpgQualitylong85Quality of the QR code graphic inside the PDF. From 1 (bad) to 100 (perfect).

Good to know

n/a

2.11 ArtQRCode-Renderer in detail

Classname/Classfile: QRCode/ArtQRCode.cs

When to use?

Use it if you want a pixel-based image (=Bitmap) with a more "artistic" style. You can set background images and define how the module are rendered. (As default they will be rendered as dots/circular).

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);ArtQRCodeqrCode=newArtQRCode(qrCodeData);BitmapqrCodeImage=qrCode.GetGraphic(10);

Parameter table

There are three different overloads:

Overload 1(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintAmount of px each dark/light module of the QR code shall take place in the final QR code image

Overload 2(Return type: Bitmap)

Parameter nameTypeDefaultDescription
backgroundImageBitmapnullA bitmap object that will be used as background picture

Overload 3(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorColor of the dark modules
lightColorColorColor of the light modules
backgroundColorColorColor of the background
backgroundImageBitmapnullA bitmap object that will be used as background picture
pixelSizeFactordouble1.0Value between 0.0 to 1.0 that defines how big the module dots are. The bigger the value, the less round the dots will be.
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
quietZoneRenderingStyleQuietZoneStyleQuietZoneStyle.DottedDefines how the quiet zones shall be rendered. (Dotted or flat/filled.)
backgroundImageStyleBackgroundImageStyleBackgroundImageStyle.DataAreaOnlyStyle of the background image (if set). Fill=spanning complete graphic; DataAreaOnly=Don't paint background into quietzone
finderPatternImageBitmapnullOptional image that should be used instead of the default finder patterns

Good to know

This renderer allows the creation of visually appealing/beautiful QR codes, but it should be noted that the official QRCode standard does not provide for such a form. Depending on the background image used or if the pixelSizeFactor-value is too small, the QRCode may be recognized worse or not at all. This risk cannot be avoided and is the responsibility of the respective developer who includes the ArtQRCode in his/her application.

Clone this wiki locally

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Advanced usage QR Code renderers

Shane Krueger edited this page Oct 6, 2025 · 42 revisions
  1. Introduction to the "QR Code Renderers"
  2. Overview of the different Renderers
    2.1. QRCode-Renderer in detail
    2.2. AsciiQRCode-Renderer in detail
    2.3. Base64QRCode-Renderer in detail
    2.4. BitmapByteQRCode-Renderer in detail
    2.5. PngByteQRCode-Renderer in detail
    2.6. SvgQRCode-Renderer in detail
    2.7. UnityQRCode-Renderer in detail
    2.8. XamlQRCode-Renderer in detail
    2.9. PostscriptQRCode-Renderer in detail
    2.10. PdfByteQRCode-Renderer in detail
    2.11. ArtQRCode-Renderer in detail

1. Introduction to the "QR Code Renderers"

As explained in the architectural overview, the QRCoder separates data/information from output/representation. So in data/core layer you create the QR Code information:

CodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The payload aka the text which should be encoded.",QRCodeGenerator.ECCLevel.Q);

Now you have to bring this information into a representation you like - or better said - you have to convert this information into the output format you like. Therefore you can use the so called "QR Code renderers". This are classes of the QRCoder which help you to represent that QrCodeData the way you prefer. Each renderer-class has a function called "GetGraphic" which returns the graphical representation of the QR Code.

Before we have a look at each of the renderers, let's have a quick look onto the following comparison table which shows the benefits of each of the renderer classes.

2. Overview of the different Renderers

The following table gives an overview of which renderer is available on which target platforms and which datatype it generates.

NameOutput Format.NET3.5+.NET4.0+.NET5.0.NET5.0-windows.NET6.0.NET6.0-windows.NETStandard1.3+.NETStandard2.0+
QRCodeBitmap-object (System.Drawing.Bitmap)(2)
AsciiQrCodeString (QR Code encoded as ASCII chars)
Base64QRCodeString (QR Code encoded as Base64)(1)
BitmapByteQRCodeByte-Array containing raw Bitmap
PngByteQRCodeByte-Array containing raw PNG image
SvgQRCodeString (QR Coded as SVG vector graphic)
UnityQRCode (via QRCoder.Unity nuget-package)Texture2D (UnityEngine.Texture2D)
XamlQRCode (via QRCoder.Xaml nuget-package)DrawingImage (for usage in WPF, Silverlight, etc.)
PostscriptQRCodeString (QR code encoded as PS/EPS string.)
PdfByteQRCodeByte-Array containing raw PDF document
ArtQRCodeBitmap-object (System.Drawing.Bitmap)(2)

(1)On platforms other than Windows only PNG is supported in Base64QRCode

(2)Only supported on Windows

2.1 QRCode-Renderer in detail

Classname/Classfile: QRCode/QRCode.cs

When to use?

Use it if you want a pixel-based image (=Bitmap) and if you are working with .NET Framework. Use it if you want to show the QR Code in your app, save the QR Code as image file or deliver the QR Code as download.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);QRCodeqrCode=newQRCode(qrCodeData);BitmapqrCodeImage=qrCode.GetGraphic(20);

Parameter table

There are four different overloads:

Overload 1(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 3(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 4(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
iconBitmapnullIf null, then ignored. If set, the Bitmap is drawn in the middle of the QR Code
iconSizePercentint15Value from 1-99. Sets how much % of the QR Code will be covered by the icon
iconBorderWidthint6Width of the border which is drawn around the icon. Minimum: 1
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
iconBackgroundColorColor?nullDefines the background color of the icon. If null(=default) the value of lightColoris used. (Icon background is only rendered and thus iconBackgroundColor is only used, if parameter icon != null and iconBorderWidth > 0.)

Good to know

This renderer is the way to go, if you want to draw an icon onto the QR Code.In most cases this renderer fits the needs very well.

2.2 AsciiQRCode-Renderer in detail

Classname/Classfile: ASCIIQRCode / ASCIIQRCode.cs

When to use?

Useful for web-, retro- and console-environments. By use of this encoder you get a QR code encoded as string just build out of chars. By default UTF-8 block symbols are used.

Trivia:The renderer is called Ascii renderer, although it uses characters from the Utf-8 character set by default. The idea behind this is that the renderer uses a text-based graphical representation that is reminiscent of classic Ascii art. Naming it Utf8QrCode was rejected in the design phase, as it would be difficult to deduce from this name what type of return value the renderer has.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);AsciiQRCodeqrCode=newAsciiQRCode(qrCodeData);stringqrCodeAsAsciiArt=qrCode.GetGraphic(1);

Parameter table

There are three different overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
repeatPerModuleintNumber of repeated darkColorString/whiteSpaceString per module. (Must be 1 or greater.)
darkColorStringstring██String for use as dark color modules. In case of string make sure whiteSpaceString has the same length.
whiteSpaceStringstringString for use as white modules (whitespace). In case of string make sure darkColorString has the same length.
drawQuietZonesbooltrueIf true a white border is "drawn" around the whole QR Code
endOfLinestring\nEnd of line separator.

Overload 2(Functionname: GetLineByLineGraphic, Return type: string[])

Parameter nameTypeDefaultDescription
repeatPerModuleintNumber of repeated darkColorString/whiteSpaceString per module.
darkColorStringstring██String for use as dark color modules. In case of string make sure whiteSpaceString has the same length.
whiteSpaceStringstringString for use as white modules (whitespace). In case of string make sure darkColorString has the same length.
drawQuietZonesbooltrueIf true a white border is "drawn" around the whole QR Code.

Overload 3(Functionname: GetGraphicSmall, Return type: string)

Parameter nameTypeDefaultDescription
drawQuietZonesbooltrueIf true a border is "drawn" around the whole QR Code.
invertboolfalseIf set to true, light- and dark color will be switched.
endOfLinestring\nEnd of line separator.

Good to know

If you set darkColorString or whiteSpaceString you have to ensure that they are both of the same length. Also you should keep in mind that this type of rendering only works when shown in a so called "Monospace" font. If you need a smaller representation than GetGraphic with repeatPerModule: 1, use GetGraphicSmall which compresses two module lines into one character line each.

2.3 Base64QRCode-Renderer in detail

Classname/Classfile: Base64QRCode / Base64QRCode.cs

When to use?

Usually very helpful in web and database environments. You can embed the Base64 images into html code, easily trafer them via HTTP requests or write them into databases without any hassle.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);Base64QRCodeqrCode=newBase64QRCode(qrCodeData);stringqrCodeImageAsBase64=qrCode.GetGraphic(20);

Parameter table

There are four different overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
iconBitmapnullIf null, then ignored. If set, the Bitmap is drawn in the middle of the QR Code
iconSizePercentint15Value from 1-99. Sets how much % of the QR Code will be covered by the icon
iconBorderWidthint6Width of the border which is drawn around the icon. Minimum: 1
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Good to know

The string returned by the GetGraphic-method just contains the image as Base64 string. It does not contain any HTML tags, etc. If you like to embed the image for example, you have to add the img-tag. E.g.

//...varimgType=Base64QRCode.ImageType.Jpeg;Base64QRCodeqrCode=newBase64QRCode(qrCodeData);stringqrCodeImageAsBase64=qrCode.GetGraphic(20,Color.Black,Color.White,true,imgType);varhtmlPictureTag=$"<img alt=\"Embedded QR Code\" src=\"data:image/{imgType.ToString().ToLower()};base64,{qrCodeImageAsBase64}\" />";

2.4 BitmapByteQRCode-Renderer in detail

Classname/Classfile: BitmapByteQRCode / BitmapByteQRCode.cs

When to use?

When using the PCL version of the QRCoder (e.g. in mobile projects) this is, besides PngByteQRCode, the only available renderer. It returns the QR code as byte-array which contains a Bitmap graphic. Since many of the platforms where the PCL library is available have different implementations of Bitmap class, but nearly any platform can create an image from byte[], this is some way of dealing with images cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);BitmapByteQRCodeqrCode=newBitmapByteQRCode(qrCodeData);byte[]qrCodeAsBitmapByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-image code //e.g. Windows 10 - Full .NET FrameworkBitmapbmp;using(varms=newMemoryStream(qrCodeAsBitmapByteArr)){qrCodeImage=newBitmap(ms);}//e.g. Windows 10 Universal App (UAP)using(InMemoryRandomAccessStreamstream=newInMemoryRandomAccessStream()){using(DataWriterwriter=newDataWriter(stream.GetOutputStreamAt(0))){writer.WriteBytes(qrCodeImage);awaitwriter.StoreAsync();}varimage=newBitmapImage();awaitimage.SetSourceAsync(stream);imageViewer.Source=image;}

Parameter table

There are two overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorRgbabyte[]The color of the dark modules, as RGB array
lightColorRgbabyte[]The color of the light modules, as RGB array

Good to know

Since this method shall be 100% platform independent the Bitmap in the byte[] is created manually byte by byte. So this renderer doesn't offer any fancy parameters right now. If you are an Bitmap expert feel free to improve the code. If you aren't but want a cool QR code, use the QR code module matrix and create your own renderer.

2.5 PngByteQRCode-Renderer in detail

Classname/Classfile: PngByteQRCode / PngByteQRCode.cs

When to use?

When using the PCL version of the QRCoder (e.g. in mobile projects) this is, besides BitmapByteQRCode, the available renderer. It returns the QR code as byte-array which contains a PNG graphic. Since many of the platforms where the PCL library is available have different implementations of Imaging classes, but nearly any platform can create an image from byte[] (or write a byte-array to file), this is some way of dealing with images cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PngByteQRCodeqrCode=newPngByteQRCode(qrCodeData);byte[]qrCodeAsPngByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-image code //e.g. Windows 10 - Full .NET FrameworkBitmapbmp;using(varms=newMemoryStream(qrCodeAsPngByteArr)){qrCodeImage=newBitmap(ms);}//e.g. Windows 10 Universal App (UAP)using(InMemoryRandomAccessStreamstream=newInMemoryRandomAccessStream()){using(DataWriterwriter=newDataWriter(stream.GetOutputStreamAt(0))){writer.WriteBytes(qrCodeAsPngByteArr);awaitwriter.StoreAsync();}varimage=newBitmapImage();awaitimage.SetSourceAsync(stream);imageViewer.Source=image;}

Parameter table

There are three overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorRgbabyte[]The color of the dark modules, as RGB(A) array
lightColorRgbabyte[]The color of the light modules, as RGB(A) array
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 3(Return type: byte[])
Not available under NET_STANDARD_1_3

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Good to know

Since this method shall be 100% platform independent the Png in the byte[] is created manually byte by byte. So this renderer doesn't offer any fancy parameters right now. If you are an Png expert feel free to improve the code. If you aren't but want a cool QR code, use the QR code module matrix and create your own renderer.

2.6 SvgQRCode-Renderer in detail

Classname/Classfile: SvgQRCode / SvgQRCode.cs

When to use?

Use this if you want to print the QR code in a huge size or when dealing with scalable (in sense of screensize) web applications. The SvgQRCode returns a scalable vector graphic which never gets blurry by its nature.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);SvgQRCodeqrCode=newSvgQRCode(qrCodeData);stringqrCodeAsSvg=qrCode.GetGraphic(20);

Parameter table

There are six overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 5(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 6(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Good to know

The string returned just contains the plain SVG. You can save it to file via StreamWriter-class or File.WriteAllText-method or you can embed into a website. But don't forget to write the correct tags around the SVG string. (Have a look here.)

2.7 UnityQRCode-Renderer in detail

Classname/Classfile:(external) See QRCoder.Unity-repository

When to use?

Use this renderer if you are working on an Unity-based app or game. This renderer return a Texture2D object for easier handling. It saves you some time, compared to the other renders.

How to use it - simple way

Install via Nuget: PM> Install-Package QRCoder.Unity
(QRCoder.Unity@nuget)

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);UnityQRCodeqrCode=newUnityQRCode(qrCodeData);Texture2DqrCodeAsTexture2D=qrCode.GetGraphic(20);

Parameter table

There are 3 overloads:

Overload 1(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation

Overload 3(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorUnityEngine.ColorThe color of the dark/black modules
lightColorUnityEngine.ColorThe color of the light/white modules

Good to know

This renderer is some kind of experimental. There are some reports that it sometimes is buggy on iOS devices, whilst Android, Windows and Linux should be working fine. So please test your project in an appropriate manner when using this renderer.

2.8 XamlQRCode-Renderer in detail

Classname/Classfile: XamlQRCode / XamlQRCode.cs

When to use?

Use this if you want to print the QR code in an XAML application (e.g. WPF, Silverlight). The XamlQRCode returns a scalable vector XAML object tree which never gets blurry by its nature.

How to use it - simple way

Install via Nuget: PM> Install-Package QRCoder.Xaml
(QRCoder.Xaml@nuget)

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);XamlQRCodeqrCode=newXamlQRCode(qrCodeData);DrawingImageqrCodeAsXaml=qrCode.GetGraphic(20);

Parameter table

There are five overloads:

Overload 1(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size

Overload 2(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
drawQuietZonesboolIf true a white border is drawn around the whole QR Code

Overload 3(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 4(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 5(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkBrushBrushThe brush of the dark/black modules
lightBrushBrushThe brush of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Good to know

The object tree returned can be assigned to an System.Windows.Controls.Image (<Image> in XAML) element's Source property. In the MVVM approach, the Source property can be bound to a model's string property and QR generation code can be implemented as an IValueConverter to convert a string value to QR code and return the System.Windows.Media.DrawingImage generated.

The <Image> element uses anti-aliased rendering by default, which makes the readability of a QR code worse. In order to display it with aliased rendering, set the RenderOptions.EdgeMode attached property to "Aliased".

2.9 PostscriptQRCode-Renderer in detail

Classname/Classfile: PostscriptQRCode / PostscriptQRCode.cs

When to use?

Use this if you want to print the QR code on a postscript printer or if you want to create a pdf file.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PostscriptQRCodeqrCode=newPostscriptQRCode(qrCodeData);stringqrCodeAsPostscript=qrCode.GetGraphic(20);

Parameter table

There are six overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
epsModeboolfalseIf true, create the file as Encapsulated Postscript (EPS)

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 5(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 6(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Good to know

The string returned just contains the plain Postscript. You can save it to file via StreamWriter-class or File.WriteAllText-method.

2.10 PdfByteQRCode-Renderer in detail

Classname/Classfile: PdfByteQRCode / PdfByteQRCode.cs

When to use?

This renderer returns the QR code as byte-array which contains a PDF document. It is available on all platforms that support System.Drawing (e.g. .NET Framework >= 3.5, .NET Standard 2.0, ...) but isn't supported in .NET Standard 1.1 environments. Since many of the platforms have different implementations of PDF classes, but any platform can write a byte[] into a file, this is some way of dealing with PDFs cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PdfByteQRCodeqrCode=newPdfByteQRCode(qrCodeData);byte[]qrCodeAsPdfByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-(PDF-)file code 

Parameter table

There are two overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark modules, as hex string e.g. #000000
lightColorHtmlHexstringThe color of the light modules, as hex string e.g. #ffffff
dpiint150DPI (dots per inch) resolution of the PDF document
jpgQualitylong85Quality of the QR code graphic inside the PDF. From 1 (bad) to 100 (perfect).

Good to know

n/a

2.11 ArtQRCode-Renderer in detail

Classname/Classfile: QRCode/ArtQRCode.cs

When to use?

Use it if you want a pixel-based image (=Bitmap) with a more "artistic" style. You can set background images and define how the module are rendered. (As default they will be rendered as dots/circular).

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);ArtQRCodeqrCode=newArtQRCode(qrCodeData);BitmapqrCodeImage=qrCode.GetGraphic(10);

Parameter table

There are three different overloads:

Overload 1(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintAmount of px each dark/light module of the QR code shall take place in the final QR code image

Overload 2(Return type: Bitmap)

Parameter nameTypeDefaultDescription
backgroundImageBitmapnullA bitmap object that will be used as background picture

Overload 3(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorColor of the dark modules
lightColorColorColor of the light modules
backgroundColorColorColor of the background
backgroundImageBitmapnullA bitmap object that will be used as background picture
pixelSizeFactordouble1.0Value between 0.0 to 1.0 that defines how big the module dots are. The bigger the value, the less round the dots will be.
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
quietZoneRenderingStyleQuietZoneStyleQuietZoneStyle.DottedDefines how the quiet zones shall be rendered. (Dotted or flat/filled.)
backgroundImageStyleBackgroundImageStyleBackgroundImageStyle.DataAreaOnlyStyle of the background image (if set). Fill=spanning complete graphic; DataAreaOnly=Don't paint background into quietzone
finderPatternImageBitmapnullOptional image that should be used instead of the default finder patterns

Good to know

This renderer allows the creation of visually appealing/beautiful QR codes, but it should be noted that the official QRCode standard does not provide for such a form. Depending on the background image used or if the pixelSizeFactor-value is too small, the QRCode may be recognized worse or not at all. This risk cannot be avoided and is the responsibility of the respective developer who includes the ArtQRCode in his/her application.

Clone this wiki locally

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Advanced usage QR Code renderers

Shane Krueger edited this page Oct 6, 2025 · 42 revisions
  1. Introduction to the "QR Code Renderers"
  2. Overview of the different Renderers
    2.1. QRCode-Renderer in detail
    2.2. AsciiQRCode-Renderer in detail
    2.3. Base64QRCode-Renderer in detail
    2.4. BitmapByteQRCode-Renderer in detail
    2.5. PngByteQRCode-Renderer in detail
    2.6. SvgQRCode-Renderer in detail
    2.7. UnityQRCode-Renderer in detail
    2.8. XamlQRCode-Renderer in detail
    2.9. PostscriptQRCode-Renderer in detail
    2.10. PdfByteQRCode-Renderer in detail
    2.11. ArtQRCode-Renderer in detail

1. Introduction to the "QR Code Renderers"

As explained in the architectural overview, the QRCoder separates data/information from output/representation. So in data/core layer you create the QR Code information:

CodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The payload aka the text which should be encoded.",QRCodeGenerator.ECCLevel.Q);

Now you have to bring this information into a representation you like - or better said - you have to convert this information into the output format you like. Therefore you can use the so called "QR Code renderers". This are classes of the QRCoder which help you to represent that QrCodeData the way you prefer. Each renderer-class has a function called "GetGraphic" which returns the graphical representation of the QR Code.

Before we have a look at each of the renderers, let's have a quick look onto the following comparison table which shows the benefits of each of the renderer classes.

2. Overview of the different Renderers

The following table gives an overview of which renderer is available on which target platforms and which datatype it generates.

NameOutput Format.NET3.5+.NET4.0+.NET5.0.NET5.0-windows.NET6.0.NET6.0-windows.NETStandard1.3+.NETStandard2.0+
QRCodeBitmap-object (System.Drawing.Bitmap)(2)
AsciiQrCodeString (QR Code encoded as ASCII chars)
Base64QRCodeString (QR Code encoded as Base64)(1)
BitmapByteQRCodeByte-Array containing raw Bitmap
PngByteQRCodeByte-Array containing raw PNG image
SvgQRCodeString (QR Coded as SVG vector graphic)
UnityQRCode (via QRCoder.Unity nuget-package)Texture2D (UnityEngine.Texture2D)
XamlQRCode (via QRCoder.Xaml nuget-package)DrawingImage (for usage in WPF, Silverlight, etc.)
PostscriptQRCodeString (QR code encoded as PS/EPS string.)
PdfByteQRCodeByte-Array containing raw PDF document
ArtQRCodeBitmap-object (System.Drawing.Bitmap)(2)

(1)On platforms other than Windows only PNG is supported in Base64QRCode

(2)Only supported on Windows

2.1 QRCode-Renderer in detail

Classname/Classfile: QRCode/QRCode.cs

When to use?

Use it if you want a pixel-based image (=Bitmap) and if you are working with .NET Framework. Use it if you want to show the QR Code in your app, save the QR Code as image file or deliver the QR Code as download.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);QRCodeqrCode=newQRCode(qrCodeData);BitmapqrCodeImage=qrCode.GetGraphic(20);

Parameter table

There are four different overloads:

Overload 1(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 3(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 4(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
iconBitmapnullIf null, then ignored. If set, the Bitmap is drawn in the middle of the QR Code
iconSizePercentint15Value from 1-99. Sets how much % of the QR Code will be covered by the icon
iconBorderWidthint6Width of the border which is drawn around the icon. Minimum: 1
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
iconBackgroundColorColor?nullDefines the background color of the icon. If null(=default) the value of lightColoris used. (Icon background is only rendered and thus iconBackgroundColor is only used, if parameter icon != null and iconBorderWidth > 0.)

Good to know

This renderer is the way to go, if you want to draw an icon onto the QR Code.In most cases this renderer fits the needs very well.

2.2 AsciiQRCode-Renderer in detail

Classname/Classfile: ASCIIQRCode / ASCIIQRCode.cs

When to use?

Useful for web-, retro- and console-environments. By use of this encoder you get a QR code encoded as string just build out of chars. By default UTF-8 block symbols are used.

Trivia:The renderer is called Ascii renderer, although it uses characters from the Utf-8 character set by default. The idea behind this is that the renderer uses a text-based graphical representation that is reminiscent of classic Ascii art. Naming it Utf8QrCode was rejected in the design phase, as it would be difficult to deduce from this name what type of return value the renderer has.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);AsciiQRCodeqrCode=newAsciiQRCode(qrCodeData);stringqrCodeAsAsciiArt=qrCode.GetGraphic(1);

Parameter table

There are three different overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
repeatPerModuleintNumber of repeated darkColorString/whiteSpaceString per module. (Must be 1 or greater.)
darkColorStringstring██String for use as dark color modules. In case of string make sure whiteSpaceString has the same length.
whiteSpaceStringstringString for use as white modules (whitespace). In case of string make sure darkColorString has the same length.
drawQuietZonesbooltrueIf true a white border is "drawn" around the whole QR Code
endOfLinestring\nEnd of line separator.

Overload 2(Functionname: GetLineByLineGraphic, Return type: string[])

Parameter nameTypeDefaultDescription
repeatPerModuleintNumber of repeated darkColorString/whiteSpaceString per module.
darkColorStringstring██String for use as dark color modules. In case of string make sure whiteSpaceString has the same length.
whiteSpaceStringstringString for use as white modules (whitespace). In case of string make sure darkColorString has the same length.
drawQuietZonesbooltrueIf true a white border is "drawn" around the whole QR Code.

Overload 3(Functionname: GetGraphicSmall, Return type: string)

Parameter nameTypeDefaultDescription
drawQuietZonesbooltrueIf true a border is "drawn" around the whole QR Code.
invertboolfalseIf set to true, light- and dark color will be switched.
endOfLinestring\nEnd of line separator.

Good to know

If you set darkColorString or whiteSpaceString you have to ensure that they are both of the same length. Also you should keep in mind that this type of rendering only works when shown in a so called "Monospace" font. If you need a smaller representation than GetGraphic with repeatPerModule: 1, use GetGraphicSmall which compresses two module lines into one character line each.

2.3 Base64QRCode-Renderer in detail

Classname/Classfile: Base64QRCode / Base64QRCode.cs

When to use?

Usually very helpful in web and database environments. You can embed the Base64 images into html code, easily trafer them via HTTP requests or write them into databases without any hassle.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);Base64QRCodeqrCode=newBase64QRCode(qrCodeData);stringqrCodeImageAsBase64=qrCode.GetGraphic(20);

Parameter table

There are four different overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
iconBitmapnullIf null, then ignored. If set, the Bitmap is drawn in the middle of the QR Code
iconSizePercentint15Value from 1-99. Sets how much % of the QR Code will be covered by the icon
iconBorderWidthint6Width of the border which is drawn around the icon. Minimum: 1
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Good to know

The string returned by the GetGraphic-method just contains the image as Base64 string. It does not contain any HTML tags, etc. If you like to embed the image for example, you have to add the img-tag. E.g.

//...varimgType=Base64QRCode.ImageType.Jpeg;Base64QRCodeqrCode=newBase64QRCode(qrCodeData);stringqrCodeImageAsBase64=qrCode.GetGraphic(20,Color.Black,Color.White,true,imgType);varhtmlPictureTag=$"<img alt=\"Embedded QR Code\" src=\"data:image/{imgType.ToString().ToLower()};base64,{qrCodeImageAsBase64}\" />";

2.4 BitmapByteQRCode-Renderer in detail

Classname/Classfile: BitmapByteQRCode / BitmapByteQRCode.cs

When to use?

When using the PCL version of the QRCoder (e.g. in mobile projects) this is, besides PngByteQRCode, the only available renderer. It returns the QR code as byte-array which contains a Bitmap graphic. Since many of the platforms where the PCL library is available have different implementations of Bitmap class, but nearly any platform can create an image from byte[], this is some way of dealing with images cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);BitmapByteQRCodeqrCode=newBitmapByteQRCode(qrCodeData);byte[]qrCodeAsBitmapByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-image code //e.g. Windows 10 - Full .NET FrameworkBitmapbmp;using(varms=newMemoryStream(qrCodeAsBitmapByteArr)){qrCodeImage=newBitmap(ms);}//e.g. Windows 10 Universal App (UAP)using(InMemoryRandomAccessStreamstream=newInMemoryRandomAccessStream()){using(DataWriterwriter=newDataWriter(stream.GetOutputStreamAt(0))){writer.WriteBytes(qrCodeImage);awaitwriter.StoreAsync();}varimage=newBitmapImage();awaitimage.SetSourceAsync(stream);imageViewer.Source=image;}

Parameter table

There are two overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorRgbabyte[]The color of the dark modules, as RGB array
lightColorRgbabyte[]The color of the light modules, as RGB array

Good to know

Since this method shall be 100% platform independent the Bitmap in the byte[] is created manually byte by byte. So this renderer doesn't offer any fancy parameters right now. If you are an Bitmap expert feel free to improve the code. If you aren't but want a cool QR code, use the QR code module matrix and create your own renderer.

2.5 PngByteQRCode-Renderer in detail

Classname/Classfile: PngByteQRCode / PngByteQRCode.cs

When to use?

When using the PCL version of the QRCoder (e.g. in mobile projects) this is, besides BitmapByteQRCode, the available renderer. It returns the QR code as byte-array which contains a PNG graphic. Since many of the platforms where the PCL library is available have different implementations of Imaging classes, but nearly any platform can create an image from byte[] (or write a byte-array to file), this is some way of dealing with images cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PngByteQRCodeqrCode=newPngByteQRCode(qrCodeData);byte[]qrCodeAsPngByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-image code //e.g. Windows 10 - Full .NET FrameworkBitmapbmp;using(varms=newMemoryStream(qrCodeAsPngByteArr)){qrCodeImage=newBitmap(ms);}//e.g. Windows 10 Universal App (UAP)using(InMemoryRandomAccessStreamstream=newInMemoryRandomAccessStream()){using(DataWriterwriter=newDataWriter(stream.GetOutputStreamAt(0))){writer.WriteBytes(qrCodeAsPngByteArr);awaitwriter.StoreAsync();}varimage=newBitmapImage();awaitimage.SetSourceAsync(stream);imageViewer.Source=image;}

Parameter table

There are three overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorRgbabyte[]The color of the dark modules, as RGB(A) array
lightColorRgbabyte[]The color of the light modules, as RGB(A) array
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 3(Return type: byte[])
Not available under NET_STANDARD_1_3

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Good to know

Since this method shall be 100% platform independent the Png in the byte[] is created manually byte by byte. So this renderer doesn't offer any fancy parameters right now. If you are an Png expert feel free to improve the code. If you aren't but want a cool QR code, use the QR code module matrix and create your own renderer.

2.6 SvgQRCode-Renderer in detail

Classname/Classfile: SvgQRCode / SvgQRCode.cs

When to use?

Use this if you want to print the QR code in a huge size or when dealing with scalable (in sense of screensize) web applications. The SvgQRCode returns a scalable vector graphic which never gets blurry by its nature.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);SvgQRCodeqrCode=newSvgQRCode(qrCodeData);stringqrCodeAsSvg=qrCode.GetGraphic(20);

Parameter table

There are six overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 5(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 6(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Good to know

The string returned just contains the plain SVG. You can save it to file via StreamWriter-class or File.WriteAllText-method or you can embed into a website. But don't forget to write the correct tags around the SVG string. (Have a look here.)

2.7 UnityQRCode-Renderer in detail

Classname/Classfile:(external) See QRCoder.Unity-repository

When to use?

Use this renderer if you are working on an Unity-based app or game. This renderer return a Texture2D object for easier handling. It saves you some time, compared to the other renders.

How to use it - simple way

Install via Nuget: PM> Install-Package QRCoder.Unity
(QRCoder.Unity@nuget)

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);UnityQRCodeqrCode=newUnityQRCode(qrCodeData);Texture2DqrCodeAsTexture2D=qrCode.GetGraphic(20);

Parameter table

There are 3 overloads:

Overload 1(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation

Overload 3(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorUnityEngine.ColorThe color of the dark/black modules
lightColorUnityEngine.ColorThe color of the light/white modules

Good to know

This renderer is some kind of experimental. There are some reports that it sometimes is buggy on iOS devices, whilst Android, Windows and Linux should be working fine. So please test your project in an appropriate manner when using this renderer.

2.8 XamlQRCode-Renderer in detail

Classname/Classfile: XamlQRCode / XamlQRCode.cs

When to use?

Use this if you want to print the QR code in an XAML application (e.g. WPF, Silverlight). The XamlQRCode returns a scalable vector XAML object tree which never gets blurry by its nature.

How to use it - simple way

Install via Nuget: PM> Install-Package QRCoder.Xaml
(QRCoder.Xaml@nuget)

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);XamlQRCodeqrCode=newXamlQRCode(qrCodeData);DrawingImageqrCodeAsXaml=qrCode.GetGraphic(20);

Parameter table

There are five overloads:

Overload 1(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size

Overload 2(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
drawQuietZonesboolIf true a white border is drawn around the whole QR Code

Overload 3(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 4(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 5(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkBrushBrushThe brush of the dark/black modules
lightBrushBrushThe brush of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Good to know

The object tree returned can be assigned to an System.Windows.Controls.Image (<Image> in XAML) element's Source property. In the MVVM approach, the Source property can be bound to a model's string property and QR generation code can be implemented as an IValueConverter to convert a string value to QR code and return the System.Windows.Media.DrawingImage generated.

The <Image> element uses anti-aliased rendering by default, which makes the readability of a QR code worse. In order to display it with aliased rendering, set the RenderOptions.EdgeMode attached property to "Aliased".

2.9 PostscriptQRCode-Renderer in detail

Classname/Classfile: PostscriptQRCode / PostscriptQRCode.cs

When to use?

Use this if you want to print the QR code on a postscript printer or if you want to create a pdf file.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PostscriptQRCodeqrCode=newPostscriptQRCode(qrCodeData);stringqrCodeAsPostscript=qrCode.GetGraphic(20);

Parameter table

There are six overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
epsModeboolfalseIf true, create the file as Encapsulated Postscript (EPS)

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 5(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 6(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Good to know

The string returned just contains the plain Postscript. You can save it to file via StreamWriter-class or File.WriteAllText-method.

2.10 PdfByteQRCode-Renderer in detail

Classname/Classfile: PdfByteQRCode / PdfByteQRCode.cs

When to use?

This renderer returns the QR code as byte-array which contains a PDF document. It is available on all platforms that support System.Drawing (e.g. .NET Framework >= 3.5, .NET Standard 2.0, ...) but isn't supported in .NET Standard 1.1 environments. Since many of the platforms have different implementations of PDF classes, but any platform can write a byte[] into a file, this is some way of dealing with PDFs cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PdfByteQRCodeqrCode=newPdfByteQRCode(qrCodeData);byte[]qrCodeAsPdfByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-(PDF-)file code 

Parameter table

There are two overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark modules, as hex string e.g. #000000
lightColorHtmlHexstringThe color of the light modules, as hex string e.g. #ffffff
dpiint150DPI (dots per inch) resolution of the PDF document
jpgQualitylong85Quality of the QR code graphic inside the PDF. From 1 (bad) to 100 (perfect).

Good to know

n/a

2.11 ArtQRCode-Renderer in detail

Classname/Classfile: QRCode/ArtQRCode.cs

When to use?

Use it if you want a pixel-based image (=Bitmap) with a more "artistic" style. You can set background images and define how the module are rendered. (As default they will be rendered as dots/circular).

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);ArtQRCodeqrCode=newArtQRCode(qrCodeData);BitmapqrCodeImage=qrCode.GetGraphic(10);

Parameter table

There are three different overloads:

Overload 1(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintAmount of px each dark/light module of the QR code shall take place in the final QR code image

Overload 2(Return type: Bitmap)

Parameter nameTypeDefaultDescription
backgroundImageBitmapnullA bitmap object that will be used as background picture

Overload 3(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorColor of the dark modules
lightColorColorColor of the light modules
backgroundColorColorColor of the background
backgroundImageBitmapnullA bitmap object that will be used as background picture
pixelSizeFactordouble1.0Value between 0.0 to 1.0 that defines how big the module dots are. The bigger the value, the less round the dots will be.
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
quietZoneRenderingStyleQuietZoneStyleQuietZoneStyle.DottedDefines how the quiet zones shall be rendered. (Dotted or flat/filled.)
backgroundImageStyleBackgroundImageStyleBackgroundImageStyle.DataAreaOnlyStyle of the background image (if set). Fill=spanning complete graphic; DataAreaOnly=Don't paint background into quietzone
finderPatternImageBitmapnullOptional image that should be used instead of the default finder patterns

Good to know

This renderer allows the creation of visually appealing/beautiful QR codes, but it should be noted that the official QRCode standard does not provide for such a form. Depending on the background image used or if the pixelSizeFactor-value is too small, the QRCode may be recognized worse or not at all. This risk cannot be avoided and is the responsibility of the respective developer who includes the ArtQRCode in his/her application.

Clone this wiki locally

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Advanced usage QR Code renderers

Shane Krueger edited this page Oct 6, 2025 · 42 revisions
  1. Introduction to the "QR Code Renderers"
  2. Overview of the different Renderers
    2.1. QRCode-Renderer in detail
    2.2. AsciiQRCode-Renderer in detail
    2.3. Base64QRCode-Renderer in detail
    2.4. BitmapByteQRCode-Renderer in detail
    2.5. PngByteQRCode-Renderer in detail
    2.6. SvgQRCode-Renderer in detail
    2.7. UnityQRCode-Renderer in detail
    2.8. XamlQRCode-Renderer in detail
    2.9. PostscriptQRCode-Renderer in detail
    2.10. PdfByteQRCode-Renderer in detail
    2.11. ArtQRCode-Renderer in detail

1. Introduction to the "QR Code Renderers"

As explained in the architectural overview, the QRCoder separates data/information from output/representation. So in data/core layer you create the QR Code information:

CodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The payload aka the text which should be encoded.",QRCodeGenerator.ECCLevel.Q);

Now you have to bring this information into a representation you like - or better said - you have to convert this information into the output format you like. Therefore you can use the so called "QR Code renderers". This are classes of the QRCoder which help you to represent that QrCodeData the way you prefer. Each renderer-class has a function called "GetGraphic" which returns the graphical representation of the QR Code.

Before we have a look at each of the renderers, let's have a quick look onto the following comparison table which shows the benefits of each of the renderer classes.

2. Overview of the different Renderers

The following table gives an overview of which renderer is available on which target platforms and which datatype it generates.

NameOutput Format.NET3.5+.NET4.0+.NET5.0.NET5.0-windows.NET6.0.NET6.0-windows.NETStandard1.3+.NETStandard2.0+
QRCodeBitmap-object (System.Drawing.Bitmap)(2)
AsciiQrCodeString (QR Code encoded as ASCII chars)
Base64QRCodeString (QR Code encoded as Base64)(1)
BitmapByteQRCodeByte-Array containing raw Bitmap
PngByteQRCodeByte-Array containing raw PNG image
SvgQRCodeString (QR Coded as SVG vector graphic)
UnityQRCode (via QRCoder.Unity nuget-package)Texture2D (UnityEngine.Texture2D)
XamlQRCode (via QRCoder.Xaml nuget-package)DrawingImage (for usage in WPF, Silverlight, etc.)
PostscriptQRCodeString (QR code encoded as PS/EPS string.)
PdfByteQRCodeByte-Array containing raw PDF document
ArtQRCodeBitmap-object (System.Drawing.Bitmap)(2)

(1)On platforms other than Windows only PNG is supported in Base64QRCode

(2)Only supported on Windows

2.1 QRCode-Renderer in detail

Classname/Classfile: QRCode/QRCode.cs

When to use?

Use it if you want a pixel-based image (=Bitmap) and if you are working with .NET Framework. Use it if you want to show the QR Code in your app, save the QR Code as image file or deliver the QR Code as download.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);QRCodeqrCode=newQRCode(qrCodeData);BitmapqrCodeImage=qrCode.GetGraphic(20);

Parameter table

There are four different overloads:

Overload 1(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 3(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 4(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
iconBitmapnullIf null, then ignored. If set, the Bitmap is drawn in the middle of the QR Code
iconSizePercentint15Value from 1-99. Sets how much % of the QR Code will be covered by the icon
iconBorderWidthint6Width of the border which is drawn around the icon. Minimum: 1
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
iconBackgroundColorColor?nullDefines the background color of the icon. If null(=default) the value of lightColoris used. (Icon background is only rendered and thus iconBackgroundColor is only used, if parameter icon != null and iconBorderWidth > 0.)

Good to know

This renderer is the way to go, if you want to draw an icon onto the QR Code.In most cases this renderer fits the needs very well.

2.2 AsciiQRCode-Renderer in detail

Classname/Classfile: ASCIIQRCode / ASCIIQRCode.cs

When to use?

Useful for web-, retro- and console-environments. By use of this encoder you get a QR code encoded as string just build out of chars. By default UTF-8 block symbols are used.

Trivia:The renderer is called Ascii renderer, although it uses characters from the Utf-8 character set by default. The idea behind this is that the renderer uses a text-based graphical representation that is reminiscent of classic Ascii art. Naming it Utf8QrCode was rejected in the design phase, as it would be difficult to deduce from this name what type of return value the renderer has.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);AsciiQRCodeqrCode=newAsciiQRCode(qrCodeData);stringqrCodeAsAsciiArt=qrCode.GetGraphic(1);

Parameter table

There are three different overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
repeatPerModuleintNumber of repeated darkColorString/whiteSpaceString per module. (Must be 1 or greater.)
darkColorStringstring██String for use as dark color modules. In case of string make sure whiteSpaceString has the same length.
whiteSpaceStringstringString for use as white modules (whitespace). In case of string make sure darkColorString has the same length.
drawQuietZonesbooltrueIf true a white border is "drawn" around the whole QR Code
endOfLinestring\nEnd of line separator.

Overload 2(Functionname: GetLineByLineGraphic, Return type: string[])

Parameter nameTypeDefaultDescription
repeatPerModuleintNumber of repeated darkColorString/whiteSpaceString per module.
darkColorStringstring██String for use as dark color modules. In case of string make sure whiteSpaceString has the same length.
whiteSpaceStringstringString for use as white modules (whitespace). In case of string make sure darkColorString has the same length.
drawQuietZonesbooltrueIf true a white border is "drawn" around the whole QR Code.

Overload 3(Functionname: GetGraphicSmall, Return type: string)

Parameter nameTypeDefaultDescription
drawQuietZonesbooltrueIf true a border is "drawn" around the whole QR Code.
invertboolfalseIf set to true, light- and dark color will be switched.
endOfLinestring\nEnd of line separator.

Good to know

If you set darkColorString or whiteSpaceString you have to ensure that they are both of the same length. Also you should keep in mind that this type of rendering only works when shown in a so called "Monospace" font. If you need a smaller representation than GetGraphic with repeatPerModule: 1, use GetGraphicSmall which compresses two module lines into one character line each.

2.3 Base64QRCode-Renderer in detail

Classname/Classfile: Base64QRCode / Base64QRCode.cs

When to use?

Usually very helpful in web and database environments. You can embed the Base64 images into html code, easily trafer them via HTTP requests or write them into databases without any hassle.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);Base64QRCodeqrCode=newBase64QRCode(qrCodeData);stringqrCodeImageAsBase64=qrCode.GetGraphic(20);

Parameter table

There are four different overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
iconBitmapnullIf null, then ignored. If set, the Bitmap is drawn in the middle of the QR Code
iconSizePercentint15Value from 1-99. Sets how much % of the QR Code will be covered by the icon
iconBorderWidthint6Width of the border which is drawn around the icon. Minimum: 1
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Good to know

The string returned by the GetGraphic-method just contains the image as Base64 string. It does not contain any HTML tags, etc. If you like to embed the image for example, you have to add the img-tag. E.g.

//...varimgType=Base64QRCode.ImageType.Jpeg;Base64QRCodeqrCode=newBase64QRCode(qrCodeData);stringqrCodeImageAsBase64=qrCode.GetGraphic(20,Color.Black,Color.White,true,imgType);varhtmlPictureTag=$"<img alt=\"Embedded QR Code\" src=\"data:image/{imgType.ToString().ToLower()};base64,{qrCodeImageAsBase64}\" />";

2.4 BitmapByteQRCode-Renderer in detail

Classname/Classfile: BitmapByteQRCode / BitmapByteQRCode.cs

When to use?

When using the PCL version of the QRCoder (e.g. in mobile projects) this is, besides PngByteQRCode, the only available renderer. It returns the QR code as byte-array which contains a Bitmap graphic. Since many of the platforms where the PCL library is available have different implementations of Bitmap class, but nearly any platform can create an image from byte[], this is some way of dealing with images cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);BitmapByteQRCodeqrCode=newBitmapByteQRCode(qrCodeData);byte[]qrCodeAsBitmapByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-image code //e.g. Windows 10 - Full .NET FrameworkBitmapbmp;using(varms=newMemoryStream(qrCodeAsBitmapByteArr)){qrCodeImage=newBitmap(ms);}//e.g. Windows 10 Universal App (UAP)using(InMemoryRandomAccessStreamstream=newInMemoryRandomAccessStream()){using(DataWriterwriter=newDataWriter(stream.GetOutputStreamAt(0))){writer.WriteBytes(qrCodeImage);awaitwriter.StoreAsync();}varimage=newBitmapImage();awaitimage.SetSourceAsync(stream);imageViewer.Source=image;}

Parameter table

There are two overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorRgbabyte[]The color of the dark modules, as RGB array
lightColorRgbabyte[]The color of the light modules, as RGB array

Good to know

Since this method shall be 100% platform independent the Bitmap in the byte[] is created manually byte by byte. So this renderer doesn't offer any fancy parameters right now. If you are an Bitmap expert feel free to improve the code. If you aren't but want a cool QR code, use the QR code module matrix and create your own renderer.

2.5 PngByteQRCode-Renderer in detail

Classname/Classfile: PngByteQRCode / PngByteQRCode.cs

When to use?

When using the PCL version of the QRCoder (e.g. in mobile projects) this is, besides BitmapByteQRCode, the available renderer. It returns the QR code as byte-array which contains a PNG graphic. Since many of the platforms where the PCL library is available have different implementations of Imaging classes, but nearly any platform can create an image from byte[] (or write a byte-array to file), this is some way of dealing with images cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PngByteQRCodeqrCode=newPngByteQRCode(qrCodeData);byte[]qrCodeAsPngByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-image code //e.g. Windows 10 - Full .NET FrameworkBitmapbmp;using(varms=newMemoryStream(qrCodeAsPngByteArr)){qrCodeImage=newBitmap(ms);}//e.g. Windows 10 Universal App (UAP)using(InMemoryRandomAccessStreamstream=newInMemoryRandomAccessStream()){using(DataWriterwriter=newDataWriter(stream.GetOutputStreamAt(0))){writer.WriteBytes(qrCodeAsPngByteArr);awaitwriter.StoreAsync();}varimage=newBitmapImage();awaitimage.SetSourceAsync(stream);imageViewer.Source=image;}

Parameter table

There are three overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorRgbabyte[]The color of the dark modules, as RGB(A) array
lightColorRgbabyte[]The color of the light modules, as RGB(A) array
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 3(Return type: byte[])
Not available under NET_STANDARD_1_3

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Good to know

Since this method shall be 100% platform independent the Png in the byte[] is created manually byte by byte. So this renderer doesn't offer any fancy parameters right now. If you are an Png expert feel free to improve the code. If you aren't but want a cool QR code, use the QR code module matrix and create your own renderer.

2.6 SvgQRCode-Renderer in detail

Classname/Classfile: SvgQRCode / SvgQRCode.cs

When to use?

Use this if you want to print the QR code in a huge size or when dealing with scalable (in sense of screensize) web applications. The SvgQRCode returns a scalable vector graphic which never gets blurry by its nature.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);SvgQRCodeqrCode=newSvgQRCode(qrCodeData);stringqrCodeAsSvg=qrCode.GetGraphic(20);

Parameter table

There are six overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 5(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 6(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Good to know

The string returned just contains the plain SVG. You can save it to file via StreamWriter-class or File.WriteAllText-method or you can embed into a website. But don't forget to write the correct tags around the SVG string. (Have a look here.)

2.7 UnityQRCode-Renderer in detail

Classname/Classfile:(external) See QRCoder.Unity-repository

When to use?

Use this renderer if you are working on an Unity-based app or game. This renderer return a Texture2D object for easier handling. It saves you some time, compared to the other renders.

How to use it - simple way

Install via Nuget: PM> Install-Package QRCoder.Unity
(QRCoder.Unity@nuget)

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);UnityQRCodeqrCode=newUnityQRCode(qrCodeData);Texture2DqrCodeAsTexture2D=qrCode.GetGraphic(20);

Parameter table

There are 3 overloads:

Overload 1(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation

Overload 3(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorUnityEngine.ColorThe color of the dark/black modules
lightColorUnityEngine.ColorThe color of the light/white modules

Good to know

This renderer is some kind of experimental. There are some reports that it sometimes is buggy on iOS devices, whilst Android, Windows and Linux should be working fine. So please test your project in an appropriate manner when using this renderer.

2.8 XamlQRCode-Renderer in detail

Classname/Classfile: XamlQRCode / XamlQRCode.cs

When to use?

Use this if you want to print the QR code in an XAML application (e.g. WPF, Silverlight). The XamlQRCode returns a scalable vector XAML object tree which never gets blurry by its nature.

How to use it - simple way

Install via Nuget: PM> Install-Package QRCoder.Xaml
(QRCoder.Xaml@nuget)

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);XamlQRCodeqrCode=newXamlQRCode(qrCodeData);DrawingImageqrCodeAsXaml=qrCode.GetGraphic(20);

Parameter table

There are five overloads:

Overload 1(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size

Overload 2(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
drawQuietZonesboolIf true a white border is drawn around the whole QR Code

Overload 3(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 4(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 5(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkBrushBrushThe brush of the dark/black modules
lightBrushBrushThe brush of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Good to know

The object tree returned can be assigned to an System.Windows.Controls.Image (<Image> in XAML) element's Source property. In the MVVM approach, the Source property can be bound to a model's string property and QR generation code can be implemented as an IValueConverter to convert a string value to QR code and return the System.Windows.Media.DrawingImage generated.

The <Image> element uses anti-aliased rendering by default, which makes the readability of a QR code worse. In order to display it with aliased rendering, set the RenderOptions.EdgeMode attached property to "Aliased".

2.9 PostscriptQRCode-Renderer in detail

Classname/Classfile: PostscriptQRCode / PostscriptQRCode.cs

When to use?

Use this if you want to print the QR code on a postscript printer or if you want to create a pdf file.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PostscriptQRCodeqrCode=newPostscriptQRCode(qrCodeData);stringqrCodeAsPostscript=qrCode.GetGraphic(20);

Parameter table

There are six overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
epsModeboolfalseIf true, create the file as Encapsulated Postscript (EPS)

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 5(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 6(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Good to know

The string returned just contains the plain Postscript. You can save it to file via StreamWriter-class or File.WriteAllText-method.

2.10 PdfByteQRCode-Renderer in detail

Classname/Classfile: PdfByteQRCode / PdfByteQRCode.cs

When to use?

This renderer returns the QR code as byte-array which contains a PDF document. It is available on all platforms that support System.Drawing (e.g. .NET Framework >= 3.5, .NET Standard 2.0, ...) but isn't supported in .NET Standard 1.1 environments. Since many of the platforms have different implementations of PDF classes, but any platform can write a byte[] into a file, this is some way of dealing with PDFs cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PdfByteQRCodeqrCode=newPdfByteQRCode(qrCodeData);byte[]qrCodeAsPdfByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-(PDF-)file code 

Parameter table

There are two overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark modules, as hex string e.g. #000000
lightColorHtmlHexstringThe color of the light modules, as hex string e.g. #ffffff
dpiint150DPI (dots per inch) resolution of the PDF document
jpgQualitylong85Quality of the QR code graphic inside the PDF. From 1 (bad) to 100 (perfect).

Good to know

n/a

2.11 ArtQRCode-Renderer in detail

Classname/Classfile: QRCode/ArtQRCode.cs

When to use?

Use it if you want a pixel-based image (=Bitmap) with a more "artistic" style. You can set background images and define how the module are rendered. (As default they will be rendered as dots/circular).

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);ArtQRCodeqrCode=newArtQRCode(qrCodeData);BitmapqrCodeImage=qrCode.GetGraphic(10);

Parameter table

There are three different overloads:

Overload 1(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintAmount of px each dark/light module of the QR code shall take place in the final QR code image

Overload 2(Return type: Bitmap)

Parameter nameTypeDefaultDescription
backgroundImageBitmapnullA bitmap object that will be used as background picture

Overload 3(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorColor of the dark modules
lightColorColorColor of the light modules
backgroundColorColorColor of the background
backgroundImageBitmapnullA bitmap object that will be used as background picture
pixelSizeFactordouble1.0Value between 0.0 to 1.0 that defines how big the module dots are. The bigger the value, the less round the dots will be.
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
quietZoneRenderingStyleQuietZoneStyleQuietZoneStyle.DottedDefines how the quiet zones shall be rendered. (Dotted or flat/filled.)
backgroundImageStyleBackgroundImageStyleBackgroundImageStyle.DataAreaOnlyStyle of the background image (if set). Fill=spanning complete graphic; DataAreaOnly=Don't paint background into quietzone
finderPatternImageBitmapnullOptional image that should be used instead of the default finder patterns

Good to know

This renderer allows the creation of visually appealing/beautiful QR codes, but it should be noted that the official QRCode standard does not provide for such a form. Depending on the background image used or if the pixelSizeFactor-value is too small, the QRCode may be recognized worse or not at all. This risk cannot be avoided and is the responsibility of the respective developer who includes the ArtQRCode in his/her application.

Clone this wiki locally

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Advanced usage QR Code renderers

Shane Krueger edited this page Oct 6, 2025 · 42 revisions
  1. Introduction to the "QR Code Renderers"
  2. Overview of the different Renderers
    2.1. QRCode-Renderer in detail
    2.2. AsciiQRCode-Renderer in detail
    2.3. Base64QRCode-Renderer in detail
    2.4. BitmapByteQRCode-Renderer in detail
    2.5. PngByteQRCode-Renderer in detail
    2.6. SvgQRCode-Renderer in detail
    2.7. UnityQRCode-Renderer in detail
    2.8. XamlQRCode-Renderer in detail
    2.9. PostscriptQRCode-Renderer in detail
    2.10. PdfByteQRCode-Renderer in detail
    2.11. ArtQRCode-Renderer in detail

1. Introduction to the "QR Code Renderers"

As explained in the architectural overview, the QRCoder separates data/information from output/representation. So in data/core layer you create the QR Code information:

CodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The payload aka the text which should be encoded.",QRCodeGenerator.ECCLevel.Q);

Now you have to bring this information into a representation you like - or better said - you have to convert this information into the output format you like. Therefore you can use the so called "QR Code renderers". This are classes of the QRCoder which help you to represent that QrCodeData the way you prefer. Each renderer-class has a function called "GetGraphic" which returns the graphical representation of the QR Code.

Before we have a look at each of the renderers, let's have a quick look onto the following comparison table which shows the benefits of each of the renderer classes.

2. Overview of the different Renderers

The following table gives an overview of which renderer is available on which target platforms and which datatype it generates.

NameOutput Format.NET3.5+.NET4.0+.NET5.0.NET5.0-windows.NET6.0.NET6.0-windows.NETStandard1.3+.NETStandard2.0+
QRCodeBitmap-object (System.Drawing.Bitmap)(2)
AsciiQrCodeString (QR Code encoded as ASCII chars)
Base64QRCodeString (QR Code encoded as Base64)(1)
BitmapByteQRCodeByte-Array containing raw Bitmap
PngByteQRCodeByte-Array containing raw PNG image
SvgQRCodeString (QR Coded as SVG vector graphic)
UnityQRCode (via QRCoder.Unity nuget-package)Texture2D (UnityEngine.Texture2D)
XamlQRCode (via QRCoder.Xaml nuget-package)DrawingImage (for usage in WPF, Silverlight, etc.)
PostscriptQRCodeString (QR code encoded as PS/EPS string.)
PdfByteQRCodeByte-Array containing raw PDF document
ArtQRCodeBitmap-object (System.Drawing.Bitmap)(2)

(1)On platforms other than Windows only PNG is supported in Base64QRCode

(2)Only supported on Windows

2.1 QRCode-Renderer in detail

Classname/Classfile: QRCode/QRCode.cs

When to use?

Use it if you want a pixel-based image (=Bitmap) and if you are working with .NET Framework. Use it if you want to show the QR Code in your app, save the QR Code as image file or deliver the QR Code as download.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);QRCodeqrCode=newQRCode(qrCodeData);BitmapqrCodeImage=qrCode.GetGraphic(20);

Parameter table

There are four different overloads:

Overload 1(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 3(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 4(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
iconBitmapnullIf null, then ignored. If set, the Bitmap is drawn in the middle of the QR Code
iconSizePercentint15Value from 1-99. Sets how much % of the QR Code will be covered by the icon
iconBorderWidthint6Width of the border which is drawn around the icon. Minimum: 1
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
iconBackgroundColorColor?nullDefines the background color of the icon. If null(=default) the value of lightColoris used. (Icon background is only rendered and thus iconBackgroundColor is only used, if parameter icon != null and iconBorderWidth > 0.)

Good to know

This renderer is the way to go, if you want to draw an icon onto the QR Code.In most cases this renderer fits the needs very well.

2.2 AsciiQRCode-Renderer in detail

Classname/Classfile: ASCIIQRCode / ASCIIQRCode.cs

When to use?

Useful for web-, retro- and console-environments. By use of this encoder you get a QR code encoded as string just build out of chars. By default UTF-8 block symbols are used.

Trivia:The renderer is called Ascii renderer, although it uses characters from the Utf-8 character set by default. The idea behind this is that the renderer uses a text-based graphical representation that is reminiscent of classic Ascii art. Naming it Utf8QrCode was rejected in the design phase, as it would be difficult to deduce from this name what type of return value the renderer has.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);AsciiQRCodeqrCode=newAsciiQRCode(qrCodeData);stringqrCodeAsAsciiArt=qrCode.GetGraphic(1);

Parameter table

There are three different overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
repeatPerModuleintNumber of repeated darkColorString/whiteSpaceString per module. (Must be 1 or greater.)
darkColorStringstring██String for use as dark color modules. In case of string make sure whiteSpaceString has the same length.
whiteSpaceStringstringString for use as white modules (whitespace). In case of string make sure darkColorString has the same length.
drawQuietZonesbooltrueIf true a white border is "drawn" around the whole QR Code
endOfLinestring\nEnd of line separator.

Overload 2(Functionname: GetLineByLineGraphic, Return type: string[])

Parameter nameTypeDefaultDescription
repeatPerModuleintNumber of repeated darkColorString/whiteSpaceString per module.
darkColorStringstring██String for use as dark color modules. In case of string make sure whiteSpaceString has the same length.
whiteSpaceStringstringString for use as white modules (whitespace). In case of string make sure darkColorString has the same length.
drawQuietZonesbooltrueIf true a white border is "drawn" around the whole QR Code.

Overload 3(Functionname: GetGraphicSmall, Return type: string)

Parameter nameTypeDefaultDescription
drawQuietZonesbooltrueIf true a border is "drawn" around the whole QR Code.
invertboolfalseIf set to true, light- and dark color will be switched.
endOfLinestring\nEnd of line separator.

Good to know

If you set darkColorString or whiteSpaceString you have to ensure that they are both of the same length. Also you should keep in mind that this type of rendering only works when shown in a so called "Monospace" font. If you need a smaller representation than GetGraphic with repeatPerModule: 1, use GetGraphicSmall which compresses two module lines into one character line each.

2.3 Base64QRCode-Renderer in detail

Classname/Classfile: Base64QRCode / Base64QRCode.cs

When to use?

Usually very helpful in web and database environments. You can embed the Base64 images into html code, easily trafer them via HTTP requests or write them into databases without any hassle.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);Base64QRCodeqrCode=newBase64QRCode(qrCodeData);stringqrCodeImageAsBase64=qrCode.GetGraphic(20);

Parameter table

There are four different overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
iconBitmapnullIf null, then ignored. If set, the Bitmap is drawn in the middle of the QR Code
iconSizePercentint15Value from 1-99. Sets how much % of the QR Code will be covered by the icon
iconBorderWidthint6Width of the border which is drawn around the icon. Minimum: 1
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
imgTypeBase64QRCode.ImageTypeBase64QRCode.ImageType.PngSets the image format of the image which is encoded in the Base64 string

Good to know

The string returned by the GetGraphic-method just contains the image as Base64 string. It does not contain any HTML tags, etc. If you like to embed the image for example, you have to add the img-tag. E.g.

//...varimgType=Base64QRCode.ImageType.Jpeg;Base64QRCodeqrCode=newBase64QRCode(qrCodeData);stringqrCodeImageAsBase64=qrCode.GetGraphic(20,Color.Black,Color.White,true,imgType);varhtmlPictureTag=$"<img alt=\"Embedded QR Code\" src=\"data:image/{imgType.ToString().ToLower()};base64,{qrCodeImageAsBase64}\" />";

2.4 BitmapByteQRCode-Renderer in detail

Classname/Classfile: BitmapByteQRCode / BitmapByteQRCode.cs

When to use?

When using the PCL version of the QRCoder (e.g. in mobile projects) this is, besides PngByteQRCode, the only available renderer. It returns the QR code as byte-array which contains a Bitmap graphic. Since many of the platforms where the PCL library is available have different implementations of Bitmap class, but nearly any platform can create an image from byte[], this is some way of dealing with images cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);BitmapByteQRCodeqrCode=newBitmapByteQRCode(qrCodeData);byte[]qrCodeAsBitmapByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-image code //e.g. Windows 10 - Full .NET FrameworkBitmapbmp;using(varms=newMemoryStream(qrCodeAsBitmapByteArr)){qrCodeImage=newBitmap(ms);}//e.g. Windows 10 Universal App (UAP)using(InMemoryRandomAccessStreamstream=newInMemoryRandomAccessStream()){using(DataWriterwriter=newDataWriter(stream.GetOutputStreamAt(0))){writer.WriteBytes(qrCodeImage);awaitwriter.StoreAsync();}varimage=newBitmapImage();awaitimage.SetSourceAsync(stream);imageViewer.Source=image;}

Parameter table

There are two overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorRgbabyte[]The color of the dark modules, as RGB array
lightColorRgbabyte[]The color of the light modules, as RGB array

Good to know

Since this method shall be 100% platform independent the Bitmap in the byte[] is created manually byte by byte. So this renderer doesn't offer any fancy parameters right now. If you are an Bitmap expert feel free to improve the code. If you aren't but want a cool QR code, use the QR code module matrix and create your own renderer.

2.5 PngByteQRCode-Renderer in detail

Classname/Classfile: PngByteQRCode / PngByteQRCode.cs

When to use?

When using the PCL version of the QRCoder (e.g. in mobile projects) this is, besides BitmapByteQRCode, the available renderer. It returns the QR code as byte-array which contains a PNG graphic. Since many of the platforms where the PCL library is available have different implementations of Imaging classes, but nearly any platform can create an image from byte[] (or write a byte-array to file), this is some way of dealing with images cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PngByteQRCodeqrCode=newPngByteQRCode(qrCodeData);byte[]qrCodeAsPngByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-image code //e.g. Windows 10 - Full .NET FrameworkBitmapbmp;using(varms=newMemoryStream(qrCodeAsPngByteArr)){qrCodeImage=newBitmap(ms);}//e.g. Windows 10 Universal App (UAP)using(InMemoryRandomAccessStreamstream=newInMemoryRandomAccessStream()){using(DataWriterwriter=newDataWriter(stream.GetOutputStreamAt(0))){writer.WriteBytes(qrCodeAsPngByteArr);awaitwriter.StoreAsync();}varimage=newBitmapImage();awaitimage.SetSourceAsync(stream);imageViewer.Source=image;}

Parameter table

There are three overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorRgbabyte[]The color of the dark modules, as RGB(A) array
lightColorRgbabyte[]The color of the light modules, as RGB(A) array
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 3(Return type: byte[])
Not available under NET_STANDARD_1_3

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Good to know

Since this method shall be 100% platform independent the Png in the byte[] is created manually byte by byte. So this renderer doesn't offer any fancy parameters right now. If you are an Png expert feel free to improve the code. If you aren't but want a cool QR code, use the QR code module matrix and create your own renderer.

2.6 SvgQRCode-Renderer in detail

Classname/Classfile: SvgQRCode / SvgQRCode.cs

When to use?

Use this if you want to print the QR code in a huge size or when dealing with scalable (in sense of screensize) web applications. The SvgQRCode returns a scalable vector graphic which never gets blurry by its nature.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);SvgQRCodeqrCode=newSvgQRCode(qrCodeData);stringqrCodeAsSvg=qrCode.GetGraphic(20);

Parameter table

There are six overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 5(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Overload 6(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
sizingModeSizingModeSizingMode.WidthHeightAttributeChanges how the size attributes of main <svg>-tag are created. Either width="xxx" height="xxx" (=SizingMode.WidthHeightAttribute) or viewBox="0 0 xxx xxx" (=SizingMode.ViewBoxAttribute) is used.
logoSvgLogonullAn optional logo (svg or bitmap) to be rendered on the QR code

Good to know

The string returned just contains the plain SVG. You can save it to file via StreamWriter-class or File.WriteAllText-method or you can embed into a website. But don't forget to write the correct tags around the SVG string. (Have a look here.)

2.7 UnityQRCode-Renderer in detail

Classname/Classfile:(external) See QRCoder.Unity-repository

When to use?

Use this renderer if you are working on an Unity-based app or game. This renderer return a Texture2D object for easier handling. It saves you some time, compared to the other renders.

How to use it - simple way

Install via Nuget: PM> Install-Package QRCoder.Unity
(QRCoder.Unity@nuget)

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);UnityQRCodeqrCode=newUnityQRCode(qrCodeData);Texture2DqrCodeAsTexture2D=qrCode.GetGraphic(20);

Parameter table

There are 3 overloads:

Overload 1(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation

Overload 3(Return type: Texture2D)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorUnityEngine.ColorThe color of the dark/black modules
lightColorUnityEngine.ColorThe color of the light/white modules

Good to know

This renderer is some kind of experimental. There are some reports that it sometimes is buggy on iOS devices, whilst Android, Windows and Linux should be working fine. So please test your project in an appropriate manner when using this renderer.

2.8 XamlQRCode-Renderer in detail

Classname/Classfile: XamlQRCode / XamlQRCode.cs

When to use?

Use this if you want to print the QR code in an XAML application (e.g. WPF, Silverlight). The XamlQRCode returns a scalable vector XAML object tree which never gets blurry by its nature.

How to use it - simple way

Install via Nuget: PM> Install-Package QRCoder.Xaml
(QRCoder.Xaml@nuget)

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);XamlQRCodeqrCode=newXamlQRCode(qrCodeData);DrawingImageqrCodeAsXaml=qrCode.GetGraphic(20);

Parameter table

There are five overloads:

Overload 1(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size

Overload 2(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
drawQuietZonesboolIf true a white border is drawn around the whole QR Code

Overload 3(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 4(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel per b/w QR code module. This x module count = ViewBox size
darkColorHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Overload 5(Return type: System.Windows.Media.DrawingImage)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the SVG viewbox
darkBrushBrushThe brush of the dark/black modules
lightBrushBrushThe brush of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code

Good to know

The object tree returned can be assigned to an System.Windows.Controls.Image (<Image> in XAML) element's Source property. In the MVVM approach, the Source property can be bound to a model's string property and QR generation code can be implemented as an IValueConverter to convert a string value to QR code and return the System.Windows.Media.DrawingImage generated.

The <Image> element uses anti-aliased rendering by default, which makes the readability of a QR code worse. In order to display it with aliased rendering, set the RenderOptions.EdgeMode attached property to "Aliased".

2.9 PostscriptQRCode-Renderer in detail

Classname/Classfile: PostscriptQRCode / PostscriptQRCode.cs

When to use?

Use this if you want to print the QR code on a postscript printer or if you want to create a pdf file.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PostscriptQRCodeqrCode=newPostscriptQRCode(qrCodeData);stringqrCodeAsPostscript=qrCode.GetGraphic(20);

Parameter table

There are six overloads:

Overload 1(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
epsModeboolfalseIf true, create the file as Encapsulated Postscript (EPS)

Overload 2(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 3(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 4(Return type: string)

Parameter nameTypeDefaultDescription
pointsPerModuleintThe point per b/w QR code module. This x module count = ViewBox size
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 5(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
darkColorColorThe color of the dark/black modules
lightColorColorThe color of the light/white modules
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Overload 6(Return type: string)

Parameter nameTypeDefaultDescription
viewBoxSizeSize of the Postscript viewbox
darkColorHtmlHexstringThe color of the dark/black modules in hex (e.g. #000000) representation
lightColorHtmlHexstringThe color of the light/white modules in hex (e.g. #ffffff) representation
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
epsModeboolfalseIf true create the file as Encapsulated Postscript (EPS)

Good to know

The string returned just contains the plain Postscript. You can save it to file via StreamWriter-class or File.WriteAllText-method.

2.10 PdfByteQRCode-Renderer in detail

Classname/Classfile: PdfByteQRCode / PdfByteQRCode.cs

When to use?

This renderer returns the QR code as byte-array which contains a PDF document. It is available on all platforms that support System.Drawing (e.g. .NET Framework >= 3.5, .NET Standard 2.0, ...) but isn't supported in .NET Standard 1.1 environments. Since many of the platforms have different implementations of PDF classes, but any platform can write a byte[] into a file, this is some way of dealing with PDFs cross-platforms.

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);PdfByteQRCodeqrCode=newPdfByteQRCode(qrCodeData);byte[]qrCodeAsPdfByteArr=qrCode.GetGraphic(20);//From here on, you can implement your platform-dependent byte[]-to-(PDF-)file code 

Parameter table

There are two overloads:

Overload 1(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn

Overload 2(Return type: byte[])

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorHtmlHexstringThe color of the dark modules, as hex string e.g. #000000
lightColorHtmlHexstringThe color of the light modules, as hex string e.g. #ffffff
dpiint150DPI (dots per inch) resolution of the PDF document
jpgQualitylong85Quality of the QR code graphic inside the PDF. From 1 (bad) to 100 (perfect).

Good to know

n/a

2.11 ArtQRCode-Renderer in detail

Classname/Classfile: QRCode/ArtQRCode.cs

When to use?

Use it if you want a pixel-based image (=Bitmap) with a more "artistic" style. You can set background images and define how the module are rendered. (As default they will be rendered as dots/circular).

How to use it - simple way

QRCodeGeneratorqrGenerator=newQRCodeGenerator();QRCodeDataqrCodeData=qrGenerator.CreateQrCode("The text which should be encoded.",QRCodeGenerator.ECCLevel.Q);ArtQRCodeqrCode=newArtQRCode(qrCodeData);BitmapqrCodeImage=qrCode.GetGraphic(10);

Parameter table

There are three different overloads:

Overload 1(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintAmount of px each dark/light module of the QR code shall take place in the final QR code image

Overload 2(Return type: Bitmap)

Parameter nameTypeDefaultDescription
backgroundImageBitmapnullA bitmap object that will be used as background picture

Overload 3(Return type: Bitmap)

Parameter nameTypeDefaultDescription
pixelsPerModuleintThe pixel size each b/w module is drawn
darkColorColorColor of the dark modules
lightColorColorColor of the light modules
backgroundColorColorColor of the background
backgroundImageBitmapnullA bitmap object that will be used as background picture
pixelSizeFactordouble1.0Value between 0.0 to 1.0 that defines how big the module dots are. The bigger the value, the less round the dots will be.
drawQuietZonesbooltrueIf true a white border is drawn around the whole QR Code
quietZoneRenderingStyleQuietZoneStyleQuietZoneStyle.DottedDefines how the quiet zones shall be rendered. (Dotted or flat/filled.)
backgroundImageStyleBackgroundImageStyleBackgroundImageStyle.DataAreaOnlyStyle of the background image (if set). Fill=spanning complete graphic; DataAreaOnly=Don't paint background into quietzone
finderPatternImageBitmapnullOptional image that should be used instead of the default finder patterns

Good to know

This renderer allows the creation of visually appealing/beautiful QR codes, but it should be noted that the official QRCode standard does not provide for such a form. Depending on the background image used or if the pixelSizeFactor-value is too small, the QRCode may be recognized worse or not at all. This risk cannot be avoided and is the responsibility of the respective developer who includes the ArtQRCode in his/her application.

Clone this wiki locally