40 for(i = 0; i < 8; i++) {
41 v = 0x84 | (format & 1);
42 frame[width * (i + 1) + 8] = v;
45 for(i = 0; i < 7; i++) {
46 v = 0x84 | (format & 1);
47 frame[width * 8 + 7 - i] = v;
52 #define MASKMAKER(__exp__) \
55 for(y = 0; y < width; y++) {\
56 for(x = 0; x < width; x++) {\
60 *d = *s ^ ((__exp__) == 0);\
66 static void Mask_mask0(
int width,
const unsigned char *s,
unsigned char *d)
71 static void Mask_mask1(
int width,
const unsigned char *s,
unsigned char *d)
76 static void Mask_mask2(
int width,
const unsigned char *s,
unsigned char *d)
81 static void Mask_mask3(
int width,
const unsigned char *s,
unsigned char *d)
87 typedef void MaskMaker(
int,
const unsigned char *,
unsigned char *);
93 unsigned char *MMask_makeMaskedFrame(
int width,
unsigned char *frame,
int mask)
95 unsigned char *masked;
97 masked = (
unsigned char *)
malloc((
size_t)(width * width));
98 if(masked == NULL)
return NULL;
108 unsigned char *masked;
111 if(mask < 0 || mask >=
maskNum) {
117 masked = (
unsigned char *)
malloc((
size_t)(width * width));
118 if(masked == NULL)
return NULL;
130 int sum1 = 0, sum2 = 0;
132 p = frame + width * (width - 1);
133 for(x = 1; x < width; x++) {
137 p = frame + width * 2 - 1;
138 for(y = 1; y < width; y++) {
143 return (sum1 <= sum2)?(sum1 * 16 + sum2):(sum2 * 16 + sum1);
149 unsigned char *mask, *bestMask;
156 mask = (
unsigned char *)
malloc((
size_t)(width * width));
157 if(mask == NULL)
return NULL;
165 if(score > maxScore) {
169 mask = (
unsigned char *)
malloc((
size_t)(width * width));
170 if(mask == NULL)
break;
static void Mask_mask1(int width, const unsigned char *s, unsigned char *d)
STATIC_IN_RELEASE int MMask_evaluateSymbol(int width, unsigned char *frame)
static void Mask_mask3(int width, const unsigned char *s, unsigned char *d)
#define STATIC_IN_RELEASE
unsigned char * MMask_mask(int version, unsigned char *frame, QRecLevel level)
QRecLevel
Level of error correction.
unsigned char * MMask_makeMask(int version, unsigned char *frame, int mask, QRecLevel level)
void MaskMaker(int, const unsigned char *, unsigned char *)
#define MASKMAKER(__exp__)
static void Mask_mask0(int width, const unsigned char *s, unsigned char *d)
STATIC_IN_RELEASE void MMask_writeFormatInformation(int version, int width, unsigned char *frame, int mask, QRecLevel level)
unsigned int MQRspec_getFormatInfo(int mask, int version, QRecLevel level)
Return BCH encoded format information pattern.
static void Mask_mask2(int width, const unsigned char *s, unsigned char *d)
int MQRspec_getWidth(int version)
Return the width of the symbol for the version.
static MaskMaker * maskMakers[maskNum]