Barcode Plugin for Xojo

QRCodeGenerator.GenerateToRawBitmapStepScaled Method

Generates a QRCode scaled in incremental steps, 2x, 3x, 4x, etc. This type of scaling for QRCode will not come at loss in quality of the code.

GenerateToRawBitmapStepScaled(
   data as String,
   errorCorrection as ErrorCorrectionType,
   pixelPerModule as UInt8,
   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.
pixelPerModule
How much to step scale the image. 2x, 3x, 4x, etc.
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


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.GenerateToRawBitmapStepScaled(tbQRCodeData.Text, errorCorrection,4,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