QRCode Class
Represents a generated QR code as a boolean matrix of modules.
public sealed class QRCodeProperties
| Name | Description |
|---|---|
| ErrorCorrectionLevel | Gets the error correction level the symbol was built with. |
| Height | Gets the height (number of rows). |
| Size | Gets the side length for square QR codes (same as QRCode.Width). |
| Type | Gets the type of QR code. |
| Version | Gets the QR code version. |
| Width | Gets the width (number of columns). |
ErrorCorrectionLevel
QRCode.csGets the error correction level the symbol was built with.
public ErrorCorrectionLevel ErrorCorrectionLevel { get; }Property value
Remarks
This can differ from the requested level. Micro QR version M1 carries error detection only, and is reported as ErrorCorrectionLevel.L because the enumeration has no weaker member.
Height
QRCode.csSize
QRCode.csGets the side length for square QR codes (same as QRCode.Width).
public int Size { get; }Property value
Type
QRCode.csVersion
QRCode.csWidth
QRCode.csIndexers
| Name | Description |
|---|---|
| this[int, int] | Gets whether the module at the specified position is dark. |
this[int, int]
QRCode.csMethods
| Name | Description |
|---|---|
| Create(ReadOnlySpan<byte>, ErrorCorrectionLevel) | Creates a standard QR code from the specified binary data. |
| Create(ReadOnlySpan<byte>, ErrorCorrectionLevel, QRCodeOptions?) | Creates a standard QR code from the specified binary data. |
| Create(string, ErrorCorrectionLevel) | Creates a standard QR code from the specified text data. |
| Create(string, ErrorCorrectionLevel, QRCodeOptions?) | Creates a standard QR code from the specified text data. |
| CreateMicroQR(string, ErrorCorrectionLevel) | Creates a Micro QR code from the specified text data. Micro QR codes are smaller (versions M1-M4, 11x11 to 17x17 modules) and have a single finder pattern. |
| CreateMicroQR(string, ErrorCorrectionLevel, MicroQRCodeOptions?) | Creates a Micro QR code from the specified text data. Micro QR codes are smaller (versions M1-M4, 11x11 to 17x17 modules) and have a single finder pattern. |
| CreateRMQR(string, ErrorCorrectionLevel) | Creates a Rectangular Micro QR code (rMQR) from the specified text data. rMQR codes are rectangular and optimized for narrow spaces. |
| CreateRMQR(string, ErrorCorrectionLevel, RMQRCodeOptions?) | Creates a Rectangular Micro QR code (rMQR) from the specified text data. rMQR codes are rectangular and optimized for narrow spaces. |
Create overloads
Create(ReadOnlySpan<byte>, ErrorCorrectionLevel)
QRCode.csCreates a standard QR code from the specified binary data.
public static QRCode Create(ReadOnlySpan<byte> data, ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.M)Parameters
dataReadOnlySpan<byte>- The binary data to encode.
errorCorrectionLevelErrorCorrectionLevel- The error correction level.
Returns
Exceptions
ArgumentOutOfRangeExceptionerrorCorrectionLevelis not a definedErrorCorrectionLevelvalue.
Create(ReadOnlySpan<byte>, ErrorCorrectionLevel, QRCodeOptions?)
QRCode.csCreates a standard QR code from the specified binary data.
public static QRCode Create(ReadOnlySpan<byte> data, ErrorCorrectionLevel errorCorrectionLevel, QRCodeOptions? options)Parameters
dataReadOnlySpan<byte>- The binary data to encode.
errorCorrectionLevelErrorCorrectionLevel- The error correction level.
optionsQRCodeOptions?- The options, or
nullfor the defaults.
Returns
Exceptions
ArgumentOutOfRangeExceptionerrorCorrectionLevelis not a definedErrorCorrectionLevelvalue.ArgumentExceptionQRCodeOptions.MinimumVersionis greater thanQRCodeOptions.MaximumVersion.InvalidOperationException- The data does not fit in the largest allowed version.
Remarks
The bytes are encoded as they are, in byte mode, preceded by an ECI designator when QRCodeOptions.EciAssignmentNumber is set.
Create(string, ErrorCorrectionLevel)
QRCode.csCreates a standard QR code from the specified text data.
public static QRCode Create(string data, ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.M)Parameters
datastring- The text data to encode.
errorCorrectionLevelErrorCorrectionLevel- The error correction level.
Returns
Exceptions
ArgumentOutOfRangeExceptionerrorCorrectionLevelis not a definedErrorCorrectionLevelvalue.
Create(string, ErrorCorrectionLevel, QRCodeOptions?)
QRCode.csCreates a standard QR code from the specified text data.
public static QRCode Create(string data, ErrorCorrectionLevel errorCorrectionLevel, QRCodeOptions? options)Parameters
datastring- The text data to encode.
errorCorrectionLevelErrorCorrectionLevel- The error correction level.
optionsQRCodeOptions?- The options, or
nullfor the defaults.
Returns
Exceptions
ArgumentOutOfRangeExceptionerrorCorrectionLevelis not a definedErrorCorrectionLevelvalue.ArgumentExceptionQRCodeOptions.EciAssignmentNumberis notnullorQRCodeOptions.Utf8EciAssignmentNumber, orQRCodeOptions.MinimumVersionis greater thanQRCodeOptions.MaximumVersion.InvalidOperationException- The data does not fit in the largest allowed version.
Remarks
The text is encoded as UTF-8, without an ECI designator unless QRCodeOptions.EciAssignmentNumber is QRCodeOptions.Utf8EciAssignmentNumber.
CreateMicroQR overloads
CreateMicroQR(string, ErrorCorrectionLevel)
QRCode.csCreates a Micro QR code from the specified text data. Micro QR codes are smaller (versions M1-M4, 11x11 to 17x17 modules) and have a single finder pattern.
public static QRCode CreateMicroQR(string data, ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.L)Parameters
datastring- The text data to encode.
errorCorrectionLevelErrorCorrectionLevel- The error correction level. M1 only supports detection; M2/M3 support L/M; M4 supports L/M/Q.
Returns
Exceptions
ArgumentOutOfRangeExceptionerrorCorrectionLevelis notErrorCorrectionLevel.L,ErrorCorrectionLevel.MorErrorCorrectionLevel.Q.
CreateMicroQR(string, ErrorCorrectionLevel, MicroQRCodeOptions?)
QRCode.csCreates a Micro QR code from the specified text data. Micro QR codes are smaller (versions M1-M4, 11x11 to 17x17 modules) and have a single finder pattern.
public static QRCode CreateMicroQR(string data, ErrorCorrectionLevel errorCorrectionLevel, MicroQRCodeOptions? options)Parameters
datastring- The text data to encode.
errorCorrectionLevelErrorCorrectionLevel- The error correction level. M1 only supports detection; M2/M3 support L/M; M4 supports L/M/Q.
optionsMicroQRCodeOptions?- The options, or
nullfor the defaults.
Returns
Exceptions
ArgumentOutOfRangeExceptionerrorCorrectionLevelis notErrorCorrectionLevel.L,ErrorCorrectionLevel.MorErrorCorrectionLevel.Q.ArgumentExceptionMicroQRCodeOptions.MinimumVersionis greater thanMicroQRCodeOptions.MaximumVersion, or no version of this range supportserrorCorrectionLevel.InvalidOperationException- The data does not fit in the largest allowed version, or has characters these versions cannot encode.
CreateRMQR overloads
CreateRMQR(string, ErrorCorrectionLevel)
QRCode.csCreates a Rectangular Micro QR code (rMQR) from the specified text data. rMQR codes are rectangular and optimized for narrow spaces.
public static QRCode CreateRMQR(string data, ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.M)Parameters
datastring- The text data to encode.
errorCorrectionLevelErrorCorrectionLevel- The error correction level. Only M and H are supported.
Returns
Exceptions
ArgumentOutOfRangeExceptionerrorCorrectionLevelis notErrorCorrectionLevel.MorErrorCorrectionLevel.H.
CreateRMQR(string, ErrorCorrectionLevel, RMQRCodeOptions?)
QRCode.csCreates a Rectangular Micro QR code (rMQR) from the specified text data. rMQR codes are rectangular and optimized for narrow spaces.
public static QRCode CreateRMQR(string data, ErrorCorrectionLevel errorCorrectionLevel, RMQRCodeOptions? options)Parameters
datastring- The text data to encode.
errorCorrectionLevelErrorCorrectionLevel- The error correction level. Only M and H are supported.
optionsRMQRCodeOptions?- The options, or
nullfor the defaults.
Returns
Exceptions
ArgumentOutOfRangeExceptionerrorCorrectionLevelis notErrorCorrectionLevel.MorErrorCorrectionLevel.H.ArgumentException- No rMQR size satisfies the size constraints of
options. InvalidOperationException- The data does not fit in the largest allowed size.