diQRcode  4.0.0
Macros | Functions
diQRcode.h File Reference

The C/C++ interface to the diQRcode.dll library. More...

Macros

#define QRCODE_ECC_M   0
 Error correction level M (default)
 
#define QRCODE_ECC_L   1
 Error correction level L.
 
#define QRCODE_ECC_Q   2
 Error correction level Q.
 
#define QRCODE_ECC_H   3
 Error correction level H.
 
#define QRCODE_ESCAPED   0x1000L
 Input string contains #-escaped sequences.
 
#define QRCODE_BASE64   0x2000L
 Encode image output formatted as base64 text.
 
#define QRCODE_NO_NAMECHECK   0x10000L
 Do not check filename extension against file type.
 
#define QRCODE_IMAGE_GIF   0x00
 Output image as a GIF file (default)
 
#define QRCODE_IMAGE_SVG   0x10
 Output image as an SVG file.
 

Functions

long QRCODE_CreateImage (const char *szOutputFile, const char *szInput, long nPixelsPerModule, long nMargin, long nOptions)
 Create an image file of a QR code. More...
 
long QRCODE_CreateGif (const char *szOutputFile, const char *szInput, long nPixelsPerModule, const char *szParams, long nOptions)
 Create a GIF file of a QR code. More...
 
long QRCODE_CreatePdf (const char *szOutputFile, const char *szInput, long nPixelsPerModule, long nPageWidth, long nPageHeight, long nX, long nY, long nOptions)
 Create a PDF file of a QR code. More...
 
long QRCODE_Version (void)
 Get version number of the core DLL. More...
 
long QRCODE_DllInfo (char *szOutput, long nOutChars, long nOptions)
 Get information about the core diQRcode DLL. More...
 
long QRCODE_ErrorLookup (char *szOutput, long nOutChars, long nErrCode)
 Look up description for error code. More...
 

Detailed Description

The C/C++ interface to the diQRcode.dll library.

Output image details:
  • Output file can be a GIF or SVG image file, or a PDF document.
  • The QR "symbol version" (the number of modules in the code) is decided automatically based on the input data. Version 1 (21 x 21) to version 40 (177 x 177) are supported.
  • The "Mode" is always 8-bit mode.
  • The number of pixels per module can be specified (1-16), default = 2 ppm.
  • The margin can be specified for image files, default = 4 modules.
  • The error code (EC) level can be specified from L, M, Q or H (default = M)
Output to szOut buffer
Functions that provide output in szOut require the buffer to be allocated to at least the specified length nOutChars PLUS one extra for the null-terminating byte. These functions always return the total length in bytes of the string they tried to create. To find the required length, pass a NULL szOut or zero nOutChars argument, then add one to the result for the required buffer size.
Escaped character sequences
Use the escaped character sequences #xHH, #uHHHH or #UHHHHHH to represent bytes or Unicode characters in the input text, where H is a hexadecimal digit. The escaped sequence flag must be turned on: add option QRCODE_ESCAPED.
The escape sequence #xHH represents the byte whose numerical value is given by HH interpreted as a hexadecimal number. The sequence will be replaced by the byte value.
The escape sequences #uHHHH and #UHHHHHH represent the Unicode code points U+HHHH and U+HHHHHH, respectively. The sequence will be replaced by the UTF-8 encoding of the code point.
Examples: #x0A will be replaced by the byte 0x0A (ASCII Line Feed, LF). #u00E1 will be replaced by the UTF-8-encoding of the character U+00E1 (Latin Small Letter A with Acute). #u4E2D by the Chinese character zhong U+4E2D, and #U01D160 by the musical symbol eighth note (U+1D160).
Specifying UTF-8 encoded characters assumes your QR code reader can interpret UTF-8-encoded characters. The number of hex characters following #x #u and #U is strictly enforced (exactly 2, 4 or 6, respectively).

Function Documentation

◆ QRCODE_CreateImage()

long QRCODE_CreateImage ( const char *  szOutputFile,
const char *  szInput,
long  nPixelsPerModule,
long  nMargin,
long  nOptions 
)

Create an image file of a QR code.

Parameters
[in]szOutputFileName of output image file to be created.
[in]szInputText input to be encoded.
[in]nPixelsPerModuleNumber of pixels per module (default = 2 ppm).
[in]nMarginSize of margin in modules (default = 4 modules).
[in]nOptionsOption flags. Select exactly one of:
QRCODE_ECC_M (0) for error correction level M (default)
QRCODE_ECC_L for error correction level L
QRCODE_ECC_Q for error correction level Q
QRCODE_ECC_H for error correction level H
and optionally add (using '|' operator):
QRCODE_IMAGE_SVG to output an SVG image (default = GIF).
QRCODE_ESCAPED to indicate #-escaped sequences in the input string.
QRCODE_BASE64 to output the image encoded as base64 text.
Returns
Zero (0) on success or a nonzero error code .

◆ QRCODE_CreateGif()

long QRCODE_CreateGif ( const char *  szOutputFile,
const char *  szInput,
long  nPixelsPerModule,
const char *  szParams,
long  nOptions 
)

Create a GIF file of a QR code.

Parameters
[in]szOutputFileName of output GIF file to be created.
[in]szInputText input to be encoded.
[in]nPixelsPerModuleNumber of pixels per module (default = 2 ppm).
[in]szParamsOptional parameters. Set as "margin=N" to change the margin to N modules (default=4).
[in]nOptionsOption flags. Select exactly one of:
QRCODE_ECC_M (0) for error correction level M (default)
QRCODE_ECC_L for error correction level L
QRCODE_ECC_Q for error correction level Q
QRCODE_ECC_H for error correction level H
and optionally add:
QRCODE_ESCAPED to indicate #-escaped sequences in the input string.
QRCODE_BASE64 to output the image encoded as base64 text.
Returns
Zero (0) on success or a nonzero error code .
Deprecated:
Use QRCODE_CreateImage() instead.

◆ QRCODE_CreatePdf()

long QRCODE_CreatePdf ( const char *  szOutputFile,
const char *  szInput,
long  nPixelsPerModule,
long  nPageWidth,
long  nPageHeight,
long  nX,
long  nY,
long  nOptions 
)

Create a PDF file of a QR code.

Parameters
[in]szOutputFileName of output PDF file to be created.
[in]szInputText input to be encoded.
[in]nPixelsPerModuleNumber of pixels per module (default = 2 ppm).
[in]nPageWidthWidth of PDF page in pixels (if zero then set width to fit QRcode image).
[in]nPageHeightHeight of PDF page in pixels (if zero then set height to fit QRcode image).
[in]nXX-coordinate in pixels of bottom-left of QRcode image from origin at bottom-left of page.
[in]nYY-coordinate in pixels of bottom-left of QRcode image from origin at bottom-left of page.
[in]nOptionsOption flags. Select exactly one of:
QRCODE_ECC_M (0) for error correction level M (default)
QRCODE_ECC_L for error correction level L
QRCODE_ECC_Q for error correction level Q
QRCODE_ECC_H for error correction level H
and optionally add:
QRCODE_ESCAPED to indicate #-escaped sequences in the input string.
Returns
Zero (0) on success or a nonzero error code .
Remarks
The PDF output is created with a DPI of 72 dots (pixels) per inch.
The default output is a PDF page of the exact size of the QRcode image.
Set nPageWidth and nPageHeight to change the size of the PDF page, and (nX, nY) to set the position of the QRcode image.
An A4 page (210 x 297 mm) is 595 x 842 pixels. A US Letter page (8.5 x 11.0 in) is 612 x 792 pixels.
Returns OUT_OF_RANGE_ERROR if QRcode image extends beyond page boundaries.

◆ QRCODE_Version()

long QRCODE_Version ( void  )

Get version number of the core DLL.

Returns
Version number as an integer in the form major*10000+minor*100+revision, e.g. core DLL file version 1.2.x.3 will return 10203

◆ QRCODE_DllInfo()

long QRCODE_DllInfo ( char *  szOutput,
long  nOutChars,
long  nOptions 
)

Get information about the core diQRcode DLL.

Parameters
[out]szOutputBuffer to receive output string.
[in]nOutCharsMaximum length of output string in bytes.
[in]nOptionsFor future use.
Returns
Number of characters in or required for output string.
Remarks
Platform is the platform the core DLL was compiled for: Win32 or X64.
"Platform=Win32; Compiled=Mar 27 2021 03:50:03; Licence=T"

◆ QRCODE_ErrorLookup()

long QRCODE_ErrorLookup ( char *  szOutput,
long  nOutChars,
long  nErrCode 
)

Look up description for error code.

Parameters
[out]szOutputBuffer to receive output string.
[in]nOutCharsMaximum length of output string in bytes.
[in]nErrCodeValue of error code to lookup (may be positive or negative).
Returns
Number of characters in or required for output string, or zero if no corresponding error code.
Remarks
Example:
char buf[256];
long nErrCode = -6;
long r = QRCODE_ErrorLookup(buf, sizeof(buf) - 1, nErrCode);
if (r > 0) printf("Error %ld: %s\n", nErrCode, buf);
long QRCODE_ErrorLookup(char *szOutput, long nOutChars, long nErrCode)
Look up description for error code.
Output:
Error -6: Parameter is wrong or missing (BAD_PARAM_ERROR)
Copyright © 2021 D.I. Management Services Pty Limited t/a CryptoSys ABN 78 083 210 584 Australia. All rights reserved. <https://di-mgt.com.au> <https://cryptosys.net>. Generated on Mon Jun 14 2021 22:51:22 by Doxygen 1.9.1.