A comprehensive C library for generating and reading QR codes, supporting all QR Code Model 2 specifications from version 1 to 40.
This library provides functionality for both generating and reading QR codes. It includes:
- QR Code Generation: Create QR codes from text or binary data
- QR Code Reading: Decode QR codes from image data using ZXing integration
- ✅ All QR Code versions (1-40) supported
- ✅ All 4 error correction levels (Low, Medium, Quartile, High)
- ✅ Multiple encoding modes (Numeric, Alphanumeric, Byte, Kanji, ECI)
- ✅ Automatic mask pattern selection
- ✅ Image reading capabilities for QR code decoding
- ✅ Thread-safe operations
- ✅ No heap allocation required
#include "qrcodegen.h"
// Text encoding
uint8_t qrcode[qrcodegen_BUFFER_LEN_MAX];
uint8_t tempBuffer[qrcodegen_BUFFER_LEN_MAX];
bool ok = qrcodegen_encodeText("Hello, World!", tempBuffer, qrcode,
qrcodegen_Ecc_MEDIUM, qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX,
qrcodegen_Mask_AUTO, true);
if (ok) {
int size = qrcodegen_getSize(qrcode);
// Use qrcodegen_getModule(qrcode, x, y) to access individual modules
}
#include "ImageReaderSource.h"
// Create image source from raw image data
ImageReaderSource source(imageData, width, height, components);
// Process with ZXing decoder
// (Additional ZXing integration code required)
qrcodegen_encodeText()
- Encode text string to QR codeqrcodegen_encodeBinary()
- Encode binary data to QR codeqrcodegen_encodeSegments()
- Encode custom segmentsqrcodegen_getSize()
- Get QR code sizeqrcodegen_getModule()
- Get module state at coordinates
qrcodegen_Ecc_LOW
- ~7% error correctionqrcodegen_Ecc_MEDIUM
- ~15% error correctionqrcodegen_Ecc_QUARTILE
- ~25% error correctionqrcodegen_Ecc_HIGH
- ~30% error correction
This project uses code from:
- QR Code generator library by Project Nayuki (MIT License)
- ZXing library components (Apache License 2.0)
# Compile the library
gcc -c qrcodegen.c -o qrcodegen.o
gcc -c ImageReaderSource.cpp -o ImageReaderSource.o
# Link with your application
gcc your_app.c qrcodegen.o ImageReaderSource.o -o your_app
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
For questions and issues, please refer to the original libraries' documentation: