BarcodeLogo Class
A logo drawn over the center of a QR code (QRCodeRenderOptions.Logo).
public sealed class BarcodeLogoRemarks
The image keeps its proportions and is centered in a square of BarcodeLogo.SizePercent of the side of the drawing. By default, the modules under the logo are not drawn (BarcodeLogo.ClearModules): the logo sits on a clean area, snapped to whole modules, instead of over half-visible modules.
The scanner recovers the missing modules with the error correction of the QR code, so create the QR code with ErrorCorrectionLevel.H and keep the logo small. When the modules are cleared, rendering checks that the error correction can recover them, and throws an ArgumentOutOfRangeException when it cannot.
Constructors
| Name | Description |
|---|---|
| BarcodeLogo(ReadOnlyMemory<byte>) | Initializes a new instance of the BarcodeLogo class. |
BarcodeLogo(ReadOnlyMemory<byte>)
BarcodeLogo.csInitializes a new instance of the BarcodeLogo class.
public BarcodeLogo(ReadOnlyMemory<byte> data)Parameters
dataReadOnlyMemory<byte>- The bytes of a PNG, JPEG, GIF or WebP file.
Properties
| Name | Description |
|---|---|
| BackdropCornerRadius | Gets or sets the radius of the corners of the backdrop, in modules. Default is 0: square corners. |
| BackdropPaint | Gets or sets the paint of the cleared area, drawn under the logo. Default is null: the light paint of the QR code shows. |
| ClearModules | Gets or sets a value indicating whether the modules under the logo are not drawn. Default is true. |
| Data | Gets the bytes of the image: a PNG, JPEG, GIF or WebP file. |
| MarginModules | Gets or sets the number of modules cleared around the logo, on each side. Default is 0. |
| SizePercent | Gets or sets the size of the logo, as a percentage of the smallest side of the drawing, quiet zone included. Default is 20. |
BackdropCornerRadius
BarcodeLogo.csGets or sets the radius of the corners of the backdrop, in modules. Default is 0: square corners.
public double BackdropCornerRadius { get; set; }Property value
Remarks
The radius is at most half the smallest side of the backdrop. Only the backdrop is rounded: the cleared area stays a rectangle of whole modules. Valid values are 0 or more.
BackdropPaint
BarcodeLogo.csGets or sets the paint of the cleared area, drawn under the logo. Default is null: the light paint of the QR code shows.
public ScenePaint? BackdropPaint { get; set; }Property value
Remarks
Set a backdrop when the QR code has no light paint (a transparent background), or to draw the logo on a color of its own. Keep it light: a dark backdrop reads as dark modules. Ignored when BarcodeLogo.ClearModules is false.
ClearModules
BarcodeLogo.csGets or sets a value indicating whether the modules under the logo are not drawn. Default is true.
public bool ClearModules { get; set; }Property value
Remarks
The cleared area is the smallest rectangle of whole modules that contains the logo, grown by BarcodeLogo.MarginModules on each side. A logo that is not square covers a band of its square, and only that band is cleared; an image with Exif metadata clears its whole square, as viewers that apply its orientation can turn it. Its modules are not drawn, so the light paint of the QR code shows under the logo, or BarcodeLogo.BackdropPaint when it is set.
Rendering throws an ArgumentOutOfRangeException when the area covers a finder pattern, a timing pattern, the format information or the version information, which the scanner needs to locate and read the code, or when an error correction block of the QR code has more codewords in the area than its error correction level can recover. The alignment patterns in the area are cleared, like the data. Set false to draw the modules under the logo, without this check.
Data
BarcodeLogo.csGets the bytes of the image: a PNG, JPEG, GIF or WebP file.
public ReadOnlyMemory<byte> Data { get; }Property value
Remarks
SVG output embeds the bytes as a data URI, and image and PDF output decode them, so every output draws the same logo. Rendering throws an ArgumentException when the data is not one of these formats.
MarginModules
BarcodeLogo.csGets or sets the number of modules cleared around the logo, on each side. Default is 0.
public int MarginModules { get; set; }Property value
Remarks
The cleared area already ends on module boundaries, so there is up to a module of space between the logo and the nearest dark module. A margin of 1 separates them more clearly, but clears more modules. Ignored when BarcodeLogo.ClearModules is false. Valid values are 0 or more.