QRCodeGenerator.GenerateToRawBitmapScaled Method
Generates a QRCode scaled into desired size. This uses image processing scaling which is not the best for QRCodes.

GenerateToRawBitmapScaled(
data
as String,
errorCorrection
as ErrorCorrectionType,
size
as UInt32,
borderSize
as UInt8)
as RawBitmap
Parameters
- data
- The data to put in the QRCode.
- errorCorrection
- Error correction level to use for the QRCode. (More error correction means bigger QRCode). This can be any value that is defined in the ErrorCorrectionType enum.
- size
- The desired size of the returned QRCode. (This is total image size including border)
- borderSize
- Size of the white border to put around the QRCode in pixels.
Returns
- RawBitmap
- The generated QRCode as RawBitmap or nil if there was a error. If there was error then you can see the LastError property to check which error occurred.
Remarks
Be aware that the quality of the QRCode reduces using this scaling. You can scale using the GenerateToRawBitmapStepScaled method to scale without loss. Though that one will scale in fixed steps, 2x, 3x, etc.
Dim qr as QRCodeGenerator = new QRCodeGenerator()
Dim bitmap as RawBitmap
Dim errorCorrection as QRCodeGenerator.ErrorCorrectionType
if optLow.Value then
errorCorrection = QRCodeGenerator.ErrorCorrectionType.LOW
elseif optMedium.Value then
errorCorrection =QRCodeGenerator.ErrorCorrectionType.MEDIUM
elseif optQuartile.Value then
errorCorrection = QRCodeGenerator.ErrorCorrectionType.QUARTILE
else
errorCorrection = QRCodeGenerator.ErrorCorrectionType.HIGH
end if
bitmap = qr.GenerateToRawBitmapScaled(tbQRCodeData.Text, errorCorrection,300,Slider1.Value)
if bitmap <> nil then
qrCodeImage = RawBitmapConverter.ToPicture(bitmap)
qrCodeBitmap = bitmap
Canvas1.Invalidate()
else
if qr.LastError = QRCodeGenerator.ErrorCodeType.DATA_TO_LONG_ERROR then
MsgBox "Could not generate QRCode, data was to long"
elseif qr.LastError = QRCodeGenerator.ErrorCodeType.COULD_NOT_CONVERT_DATA_TO_UTF8_ERROR then
MsgBox "Could not generate QRCode because data could not be converted to UTF8"
elseif qr.LastError = QRCodeGenerator.ErrorCodeType.NO_DATA_SUPPLIED_ERROR then
MsgBox "Could not generate QRCode because no data was supplied"
elseif qr.LastError = QRCodeGenerator.ErrorCodeType.SIZE_SMALLER_THAN_MIN_SIZE then
MsgBox "Could not generate QRCode the requested size of the image is to small"
else
MsgBox "Could not generate QRCode because of unknown error"
end if
end if
See Also
QRCodeGenerator Class