OIMAGE.$makeqrcode()

Function group Execute on client Platform(s)
OIMAGE NO All

Syntax

OIMAGE.$makeqrcode(vData, &xQrCode [,iFmt=kOIMAGEfmtPNG, iSizePNG=256, iECL=kOIMAGEerrHigh, iBorder=4, &cErrorText])

OIMAGE.$makeqrcode(vData, &xQrCode [,iFmt=kOIMAGEfmtPNG, iSizePNG=256, iECL=kOIMAGEerrHigh, iBorder=4, &cErrorText, &wCenterImg])

Description

Makes a QR Code for the specified binary or character vData. Returns Boolean true and xImage for success, or false and cErrorText if an error occurs.

vData: Binary or character data to be represented by the QR Code.The method converts character data to UTF-8 before encoding it. The amount of data that can be encoded is limited, and varies according to iECL. See the QR Code standard.

xQrCode: Binary variable that receives the generated QR Code

iFmt: A kOIMAGEfmt... constant that specifies the format of the generated QR Code. kOIMAGEfmtPNG or kOIMAGEfmtSVG

iSizePNG: The width and height in pixels of the QR Code, when generating kOIMAGEfmtPNG. Must be between 32 and 262144 inclusive

iECL: A kOIMAGEerr... constant that specifies the error correction level supported by the generated QR Code:

  1. kOIMAGEerrLow
    The QR Code can tolerate about 7% erroneous codewords

  2. kOIMAGEerrMedium
    The QR Code can tolerate about 15% erroneous codewords

  3. kOIMAGEerrQuartile
    The QR Code can tolerate about 25% erroneous codewords

  4. kOIMAGEHigh
    The QR Code can tolerate about 30% erroneous codewords

iBorder: The number of border modules to surround the QR Code.

cErrorText: Receives the error text if an error occurs.

wCenterImg: Adds an icon image to the center of the generated QR code: see below.

Adding an image

The wCenterImg parameter controls how an icon can be overlaid after a QR code has been created; this only works for kOIMAGEfmtPNG output QR images (not for kOIMAGEfmtSVG). The parameter is a row variable with the following parameters:

row(cIconID,[ixSize=15,ixBorder=2,ixForeColor=kColorBlack,ixBackColor=kColorWhite])

By default, the row requires a single parameter, cIconID, which is the icon to be overlaid in the center of the QR code (this can be an SVG or PNG icon image). The second parameter ixSize controls the size of the icon, which is a percentage of the output QR image size; this defaults to 15% with a maximum value of 30% (a value over 30% may result in an error).

A border can be added to the overlaid icon using a third parameter ixBorder which defaults to 2 pixels. In addition, you can control the center icon area color, and icon color using parameters ixForeColor and ixBackColor, which default to black and white (to match the resulting QR image which is black and white).

For example, to add the account_box icon to the center of a QR code using the default size and border, use the following command:

Do  OIMAGE.$makeqrcode(
   lText,iPicture,kOIMAGEfmtPNG,256,
   iErrorLevel,4,errText,row('account_box'))

To set the size of the overlaid icon to 25% of the QR image size, add a 5 pixel border, and to set the colors of the overlaid icon and border color, use the following command:

Do  OIMAGE.$makeqrcode(
   lText,iPicture,kOIMAGEfmtPNG,256,
   iErrorLevel,4,errText,row('account_box',25,5,kWhite,kRed))

Note the account_box icon is a themed icon so you can set the icon color (but remember the output QR image must be a PNG, i.e. kOIMAGEfmtPNG).