Lines Matching refs:qrcode

66 testable void initializeFunctionModules(int version, uint8_t qrcode[]);
67 static void drawLightFunctionModules(uint8_t qrcode[], int version);
68 static void drawFormatBits(enum qrcodegen_Ecc ecl, enum qrcodegen_Mask mask, uint8_t qrcode[]);
70 static void fillRectangle(int left, int top, int width, int height, uint8_t qrcode[]);
72 static void drawCodewords(const uint8_t data[], int dataLen, uint8_t qrcode[]);
73 static void applyMask(const uint8_t functionModules[], uint8_t qrcode[], enum qrcodegen_Mask mask);
74 static long getPenaltyScore(const uint8_t qrcode[]);
79 testable bool getModuleBounded(const uint8_t qrcode[], int x, int y);
80 testable void setModuleBounded(uint8_t qrcode[], int x, int y, bool isDark);
81 testable void setModuleUnbounded(uint8_t qrcode[], int x, int y, bool isDark);
129 bool qrcodegen_encodeText(const char *text, uint8_t tempBuffer[], uint8_t qrcode[],
134 return qrcodegen_encodeSegmentsAdvanced(NULL, 0, ecl, minVersion, maxVersion, mask, boostEcl, tempBuffer, qrcode);
158 return qrcodegen_encodeSegmentsAdvanced(&seg, 1, ecl, minVersion, maxVersion, mask, boostEcl, tempBuffer, qrcode);
161 qrcode[0] = 0; // Set size to invalid value for safety
167 bool qrcodegen_encodeBinary(uint8_t dataAndTemp[], size_t dataLen, uint8_t qrcode[],
174 qrcode[0] = 0; // Set size to invalid value for safety
179 return qrcodegen_encodeSegmentsAdvanced(&seg, 1, ecl, minVersion, maxVersion, mask, boostEcl, dataAndTemp, qrcode);
197 enum qrcodegen_Ecc ecl, uint8_t tempBuffer[], uint8_t qrcode[]) {
199 qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX, qrcodegen_Mask_AUTO, true, tempBuffer, qrcode);
205 int minVersion, int maxVersion, enum qrcodegen_Mask mask, bool boostEcl, uint8_t tempBuffer[], uint8_t qrcode[]) {
218 qrcode[0] = 0; // Set size to invalid value for safety
231 memset(qrcode, 0, (size_t)qrcodegen_BUFFER_LEN_FOR_VERSION(version) * sizeof(qrcode[0]));
235 appendBitsToBuffer((unsigned int)seg->mode, 4, qrcode, &bitLen);
236 appendBitsToBuffer((unsigned int)seg->numChars, numCharCountBits(seg->mode, version), qrcode, &bitLen);
239 appendBitsToBuffer((unsigned int)bit, 1, qrcode, &bitLen);
250 appendBitsToBuffer(0, terminatorBits, qrcode, &bitLen);
251 appendBitsToBuffer(0, (8 - bitLen % 8) % 8, qrcode, &bitLen);
256 appendBitsToBuffer(padByte, 8, qrcode, &bitLen);
259 addEccAndInterleave(qrcode, version, ecl, tempBuffer);
260 initializeFunctionModules(version, qrcode);
261 drawCodewords(tempBuffer, getNumRawDataModules(version) / 8, qrcode);
262 drawLightFunctionModules(qrcode, version);
270 applyMask(tempBuffer, qrcode, msk);
271 drawFormatBits(ecl, msk, qrcode);
272 long penalty = getPenaltyScore(qrcode);
277 applyMask(tempBuffer, qrcode, msk); // Undoes the mask due to XOR
281 applyMask(tempBuffer, qrcode, mask); // Apply the final choice of mask
282 drawFormatBits(ecl, mask, qrcode); // Overwrite old format bits
418 testable void initializeFunctionModules(int version, uint8_t qrcode[]) {
421 memset(qrcode, 0, (size_t)((qrsize * qrsize + 7) / 8 + 1) * sizeof(qrcode[0]));
422 qrcode[0] = (uint8_t)qrsize;
425 fillRectangle(6, 0, 1, qrsize, qrcode);
426 fillRectangle(0, 6, qrsize, 1, qrcode);
429 fillRectangle(0, 0, 9, 9, qrcode);
430 fillRectangle(qrsize - 8, 0, 8, 9, qrcode);
431 fillRectangle(0, qrsize - 8, 9, 8, qrcode);
440 fillRectangle(alignPatPos[i] - 2, alignPatPos[j] - 2, 5, 5, qrcode);
446 fillRectangle(qrsize - 11, 0, 3, 6, qrcode);
447 fillRectangle(0, qrsize - 11, 6, 3, qrcode);
455 static void drawLightFunctionModules(uint8_t qrcode[], int version) {
457 int qrsize = qrcodegen_getSize(qrcode);
459 setModuleBounded(qrcode, 6, i, false);
460 setModuleBounded(qrcode, i, 6, false);
470 setModuleUnbounded(qrcode, 3 + dx, 3 + dy, false);
471 setModuleUnbounded(qrcode, qrsize - 4 + dx, 3 + dy, false);
472 setModuleUnbounded(qrcode, 3 + dx, qrsize - 4 + dy, false);
486 setModuleBounded(qrcode, alignPatPos[i] + dx, alignPatPos[j] + dy, dx == 0 && dy == 0);
504 setModuleBounded(qrcode, k, i, (bits & 1) != 0);
505 setModuleBounded(qrcode, i, k, (bits & 1) != 0);
516 static void drawFormatBits(enum qrcodegen_Ecc ecl, enum qrcodegen_Mask mask, uint8_t qrcode[]) {
529 setModuleBounded(qrcode, 8, i, getBit(bits, i));
530 setModuleBounded(qrcode, 8, 7, getBit(bits, 6));
531 setModuleBounded(qrcode, 8, 8, getBit(bits, 7));
532 setModuleBounded(qrcode, 7, 8, getBit(bits, 8));
534 setModuleBounded(qrcode, 14 - i, 8, getBit(bits, i));
537 int qrsize = qrcodegen_getSize(qrcode);
539 setModuleBounded(qrcode, qrsize - 1 - i, 8, getBit(bits, i));
541 setModuleBounded(qrcode, 8, qrsize - 15 + i, getBit(bits, i));
542 setModuleBounded(qrcode, 8, qrsize - 8, true); // Always dark
564 static void fillRectangle(int left, int top, int width, int height, uint8_t qrcode[]) {
567 setModuleBounded(qrcode, left + dx, top + dy, true);
577 static void drawCodewords(const uint8_t data[], int dataLen, uint8_t qrcode[]) {
578 int qrsize = qrcodegen_getSize(qrcode);
589 if (!getModuleBounded(qrcode, x, y) && i < dataLen * 8) {
591 setModuleBounded(qrcode, x, y, dark);
608 static void applyMask(const uint8_t functionModules[], uint8_t qrcode[], enum qrcodegen_Mask mask) {
610 int qrsize = qrcodegen_getSize(qrcode);
627 bool val = getModuleBounded(qrcode, x, y);
628 setModuleBounded(qrcode, x, y, val ^ invert);
636 static long getPenaltyScore(const uint8_t qrcode[]) {
637 int qrsize = qrcodegen_getSize(qrcode);
646 if (getModuleBounded(qrcode, x, y) == runColor) {
656 runColor = getModuleBounded(qrcode, x, y);
668 if (getModuleBounded(qrcode, x, y) == runColor) {
678 runColor = getModuleBounded(qrcode, x, y);
688 bool color = getModuleBounded(qrcode, x, y);
689 if ( color == getModuleBounded(qrcode, x + 1, y) &&
690 color == getModuleBounded(qrcode, x, y + 1) &&
691 color == getModuleBounded(qrcode, x + 1, y + 1))
700 if (getModuleBounded(qrcode, x, y))
752 int qrcodegen_getSize(const uint8_t qrcode[]) {
753 assert(qrcode != NULL);
754 int result = qrcode[0];
762 bool qrcodegen_getModule(const uint8_t qrcode[], int x, int y) {
763 assert(qrcode != NULL);
764 int qrsize = qrcode[0];
765 return (0 <= x && x < qrsize && 0 <= y && y < qrsize) && getModuleBounded(qrcode, x, y);
770 testable bool getModuleBounded(const uint8_t qrcode[], int x, int y) {
771 int qrsize = qrcode[0];
774 return getBit(qrcode[(index >> 3) + 1], index & 7);
779 testable void setModuleBounded(uint8_t qrcode[], int x, int y, bool isDark) {
780 int qrsize = qrcode[0];
786 qrcode[byteIndex] |= 1 << bitIndex;
788 qrcode[byteIndex] &= (1 << bitIndex) ^ 0xFF;
793 testable void setModuleUnbounded(uint8_t qrcode[], int x, int y, bool isDark) {
794 int qrsize = qrcode[0];
796 setModuleBounded(qrcode, x, y, isDark);