74 unsigned char *dp, *ep;
111 if(raw == NULL)
return NULL;
209 if(raw == NULL)
return NULL;
287 filler->
width = width;
288 filler->
frame = frame;
289 filler->
x = width - 1;
290 filler->
y = width - 1;
301 if(filler->
bit == -1) {
303 return filler->
frame + filler->
y * filler->
width + filler->
x;
311 if(filler->
bit == 0) {
320 if(filler->
dir < 0) {
325 if(!filler->
mqr && x == 6) {
334 if(!filler->
mqr && x == 6) {
339 if(x < 0 || y < 0)
return NULL;
344 if(p[y * w + x] & 0x80) {
348 return &p[y * w + x];
355 unsigned char *frame, *p;
361 if(frame == NULL)
return NULL;
366 for(i = 0; i < length; i++) {
372 *p = (
unsigned char)(i & 0x7f) | 0x80;
380 unsigned char *frame, *p;
386 if(frame == NULL)
return NULL;
390 for(i = 0; i < length; i++) {
393 fprintf(stderr,
"Frame filler run over the frame!\n");
396 *p = (
unsigned char)(i & 0x7f) | 0x80;
412 if(qrcode == NULL)
return NULL;
415 qrcode->
width = width;
433 unsigned char *frame, *masked, *p,
code, bit;
452 if(raw == NULL)
return NULL;
467 for(j = 0; j < 8; j++) {
469 if(p == NULL)
goto EXIT;
470 *p = ((bit & code) != 0);
477 for(j = 0; j < 8; j++) {
479 if(p == NULL)
goto EXIT;
480 *p = 0x02 | ((bit & code) != 0);
488 for(i = 0; i < j; i++) {
490 if(p == NULL)
goto EXIT;
496 masked = (
unsigned char *)
malloc((
size_t)(width * width));
497 memcpy(masked, frame, (
size_t)(width * width));
498 }
else if(mask < 0) {
521 unsigned char *frame, *masked, *p,
code, bit;
540 if(raw == NULL)
return NULL;
560 for(j = 0; j < length; j++) {
562 if(p == NULL)
goto EXIT;
563 *p = ((bit & code) != 0);
571 for(j = 0; j < length; j++) {
573 if(p == NULL)
goto EXIT;
574 *p = 0x02 | ((bit & code) != 0);
583 masked = (
unsigned char *)
malloc((
size_t)(width * width));
584 memcpy(masked, frame, (
size_t)(width * width));
585 }
else if(mask < 0) {
634 if(input == NULL)
return NULL;
661 if(code != NULL)
return code;
673 if(data == NULL || length == 0) {
683 if(input == NULL)
return NULL;
719 if(code != NULL)
return code;
738 if(code != NULL)
return code;
754 if(entry == NULL)
return NULL;
774 while(list != NULL) {
786 while(list != NULL) {
795 static unsigned char QRcode_parity(
const char *str,
int size)
797 unsigned char parity = 0;
800 for(i = 0; i <
size; i++) {
815 while(list != NULL) {
818 if(entry == NULL)
goto ABORT;
823 if(entry == NULL)
goto ABORT;
828 if(tail->
code == NULL) {
846 if(s == NULL)
return NULL;
855 int size,
const unsigned char *data,
873 if(input == NULL)
return NULL;
917 if(major_version != NULL) {
920 if(minor_version != NULL) {
923 if(micro_version != NULL) {
void QRcode_free(QRcode *qrcode)
Free the instance of QRcode class.
EXTRAS_EXPORT void QRinput_free(QRinput *input)
Free the input object.
EXTRAS_EXPORT QRinput * QRinput_new2(int version, QRecLevel level)
Instantiate an input data object.
#define QRspec_rsDataCodes2(__spec__)
EXTRAS_EXPORT int QRinput_append(QRinput *input, QRencodeMode mode, int size, const unsigned char *data)
Append data to an input object.
#define QRspec_rsDataLength(__spec__)
QRcode * QRcode_encodeString8bitMQR(const char *string, int version, QRecLevel level)
Micro QR Code version of QRcode_encodeString8bit().
int QRspec_getDataLength(int version, QRecLevel level)
Return maximum data code length (bytes) for the version.
QRcode_List * QRcode_encodeInputStructured(QRinput_Struct *s)
Create structured symbols from the input data.
#define QRSPEC_VERSION_MAX
Maximum version (size) of QR-code symbol.
qrencode - QR Code encoder
#define QRspec_rsBlockNum1(__spec__)
static void FrameFiller_set(FrameFiller *filler, int width, unsigned char *frame, int mqr)
#define QRspec_rsBlockNum2(__spec__)
char * QRcode_APIVersionString(void)
Return a string that identifies the library version.
#define STATIC_IN_RELEASE
static int RSblock_init(RSblock *blocks, int spec[5], unsigned char *data, unsigned char *ecc)
static QRcode_List * QRcode_encodeInputToStructured(QRinput *input)
unsigned char * MMask_mask(int version, unsigned char *frame, QRecLevel level)
#define QRspec_rsEccCodes1(__spec__)
QRecLevel
Level of error correction.
unsigned char * MMask_makeMask(int version, unsigned char *frame, int mask, QRecLevel level)
static void RSblock_initBlock(RSblock *block, int dl, unsigned char *data, int el, unsigned char *ecc)
STATIC_IN_RELEASE void MQRraw_free(MQRRawCode *raw)
void QRcode_clearCache(void)
unsigned char * FrameFiller_testMQR(int version)
EXTRAS_EXPORT QRinput_Struct * QRinput_splitQRinputToStruct(QRinput *input)
Split a QRinput to QRinput_Struct.
STATIC_IN_RELEASE MQRRawCode * MQRraw_new(QRinput *input)
#define MQRSPEC_VERSION_MAX
Maximum version (size) of QR-code symbol.
QRcode_List * QRcode_encodeStringStructured(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive)
Create structured symbols from the string.
EXTRAS_EXPORT QRinput * QRinput_newMQR(int version, QRecLevel level)
Instantiate an input data object.
void QRcode_List_free(QRcode_List *qrlist)
Free the QRcode_List.
#define QRspec_rsEccLength(__spec__)
EXTRAS_EXPORT void QRinput_Struct_free(QRinput_Struct *s)
Free all of QRinput in the set.
QRencodeMode
Encoding mode.
STATIC_IN_RELEASE QRcode * QRcode_encodeMaskMQR(QRinput *input, int mask)
unsigned char * Mask_makeMask(int width, unsigned char *frame, int mask, QRecLevel level)
unsigned char * MQRspec_newFrame(int version)
Return a copy of initialized frame.
#define QRspec_rsBlockNum(__spec__)
QRcode * QRcode_encodeString8bit(const char *string, int version, QRecLevel level)
Same to QRcode_encodeString(), but encode whole data in 8-bit mode.
QRcode * QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive)
Create a symbol from the string.
unsigned char * FrameFiller_test(int version)
#define QRspec_rsDataCodes1(__spec__)
STATIC_IN_RELEASE QRcode * QRcode_encodeMask(QRinput *input, int mask)
void QRspec_getEccSpec(int version, QRecLevel level, int spec[5])
Return an array of ECC specification.
STATIC_IN_RELEASE unsigned char MQRraw_getCode(MQRRawCode *raw)
Return a code (byte).
unsigned char * Mask_mask(int width, unsigned char *frame, QRecLevel level)
int QRspec_getECCLength(int version, QRecLevel level)
Return maximum error correction code length (bytes) for the version.
static QRcode_List * QRcode_encodeDataStructuredReal(int size, const unsigned char *data, int version, QRecLevel level, int eightbit, QRencodeMode hint, int casesensitive)
Singly-linked list of QRcode.
QRcode * QRcode_encodeInput(QRinput *input)
Create a symbol from the input data.
int QRspec_getRemainder(int version)
Return the numer of remainder bits.
static QRcode * QRcode_encodeDataReal(const unsigned char *data, int length, int version, QRecLevel level, int mqr)
STATIC_IN_RELEASE void QRraw_free(QRRawCode *raw)
unsigned char * data
symbol data
static QRcode_List * QRcode_List_newEntry(void)
void QRcode_APIVersion(int *major_version, int *minor_version, int *micro_version)
Return a string that identifies the library version.
STATIC_IN_RELEASE unsigned char QRraw_getCode(QRRawCode *raw)
Return a code (byte).
voidp calloc(uInt items, uInt size)
STATIC_IN_RELEASE QRcode * QRcode_new(int version, int width, unsigned char *data)
QRcode_List * QRcode_encodeDataStructured(int size, const unsigned char *data, int version, QRecLevel level)
Create structured symbols from byte stream (may include '\0').
int MQRspec_getDataLengthBit(int version, QRecLevel level)
Return maximum data code length (bits) for the version.
static void QRcode_List_freeEntry(QRcode_List *entry)
unsigned char * QRspec_newFrame(int version)
Return a copy of initialized frame.
int width
width of the symbol
static QRcode * QRcode_encodeStringReal(const char *string, int version, QRecLevel level, int mqr, QRencodeMode hint, int casesensitive)
QRcode * QRcode_encodeData(int size, const unsigned char *data, int version, QRecLevel level)
Encode byte stream (may include '\0') in 8-bit mode.
QRcode * QRcode_encodeDataMQR(int size, const unsigned char *data, int version, QRecLevel level)
Micro QR Code version of QRcode_encodeData().
int version
version of the symbol
STATIC_IN_RELEASE QRRawCode * QRraw_new(QRinput *input)
int QRcode_List_size(QRcode_List *qrlist)
Return the number of symbols included in a QRcode_List.
int RSECC_encode(size_t data_length, size_t ecc_length, const unsigned char *data, unsigned char *ecc)
int MQRspec_getECCLength(int version, QRecLevel level)
Return maximum error correction code length (bytes) for the version.
QRcode * QRcode_encodeStringMQR(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive)
Micro QR Code version of QRcode_encodeString().
int MQRspec_getWidth(int version)
Return the width of the symbol for the version.
int QRspec_getWidth(int version)
Return the width of the symbol for the version.
#define QRspec_rsEccCodes2(__spec__)
QRcode_List * QRcode_encodeString8bitStructured(const char *string, int version, QRecLevel level)
Same to QRcode_encodeStringStructured(), but encode whole data in 8-bit mode.
Terminator (NUL character). Internal use only.
static unsigned char * FrameFiller_next(FrameFiller *filler)
int MQRspec_getDataLength(int version, QRecLevel level)
Return maximum data code length (bytes) for the version.
int Split_splitStringToQRinput(const char *string, QRinput *input, QRencodeMode hint, int casesensitive)
Split the input string (null terminated) into QRinput.
struct _QRcode_List * next