Encoding (4 functions)
qrcodegen_encodeText encode
One-step text encoding (optimal mode auto-selected); the caller provides the module and temp buffers (qrcodegen_BUFFER_LEN_MAX or computed by calcSegmentBufferSize). Four ECC levels (LOW/MEDIUM/QUARTILE/HIGH); min/maxVersion 0 means auto.
qrcodegen_encodeBinary / encodeSegments / encodeSegmentsAdvanced encode
Binary data / segmented / advanced entries (manual mask, boostEcl control) — segmented encoding mixes numeric and text for optimal compression.
PNG output (xs helper layer)
qrcodegen_png render
One-step module-matrix to 1-bit grayscale PNG: scale×scale pixels per module, border modules of quiet zone on all sides (spec recommends ≥ 4). IDAT compressed via xrt's XDEFLATE_ZLIB stream (zlib header/adler32 from xrt), per-chunk CRC32 local. Returns an xrtMalloc buffer (free with xrtFree); *pOutSize receives the length; invalid parameters return NULL.
uint8_t aQr[qrcodegen_BUFFER_LEN_MAX];
uint8_t aTemp[qrcodegen_BUFFER_LEN_MAX];
size_t iSize;
unsigned char* pPng;
if ( qrcodegen_encodeText("https://xs.xywhsoft.com",
aTemp, aQr, qrcodegen_Ecc_MEDIUM,
qrcodegen_Mode_BYTE, qrcodegen_Mode_BYTE, 0, 0,
qrcodegen_Mask_AUTO, true) ) {
pPng = qrcodegen_png(aQr, 4, 4, &iSize);
/* pPng: PNG bytes (357 bytes @ 33 modules + 4 quiet × 4px) */
xrtFree(pPng);
}
Reads & detection (4 functions)
qrcodegen_getSize / getModule read
Matrix side length and per-module value (true=dark) — for custom renderers (SVG, terminal art, canvas) or writing pixel buffers directly.
qrcodegen_isNumeric / isAlphanumeric / calcSegmentBufferSize detect
Mode detection (numeric/alphanumeric) for segmented encoding decisions; calcSegmentBufferSize computes the temp buffer needed for a segment.