Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp

Issue 2048983002: Get rid of NULLs in xfa/fxbarcode/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nits Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 // Original code is licensed as follows: 6 // Original code is licensed as follows:
7 /* 7 /*
8 * Copyright 2008 ZXing authors 8 * Copyright 2008 ZXing authors
9 * 9 *
10 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * Licensed under the Apache License, Version 2.0 (the "License");
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 const int32_t CBC_QRCoderMatrixUtil::TYPE_INFO_COORDINATES[15][2] = { 70 const int32_t CBC_QRCoderMatrixUtil::TYPE_INFO_COORDINATES[15][2] = {
71 {8, 0}, {8, 1}, {8, 2}, {8, 3}, {8, 4}, {8, 5}, {8, 7}, {8, 8}, 71 {8, 0}, {8, 1}, {8, 2}, {8, 3}, {8, 4}, {8, 5}, {8, 7}, {8, 8},
72 {7, 8}, {5, 8}, {4, 8}, {3, 8}, {2, 8}, {1, 8}, {0, 8}, 72 {7, 8}, {5, 8}, {4, 8}, {3, 8}, {2, 8}, {1, 8}, {0, 8},
73 }; 73 };
74 const int32_t CBC_QRCoderMatrixUtil::VERSION_INFO_POLY = 0x1f25; 74 const int32_t CBC_QRCoderMatrixUtil::VERSION_INFO_POLY = 0x1f25;
75 const int32_t CBC_QRCoderMatrixUtil::TYPE_INFO_POLY = 0x0537; 75 const int32_t CBC_QRCoderMatrixUtil::TYPE_INFO_POLY = 0x0537;
76 const int32_t CBC_QRCoderMatrixUtil::TYPE_INFO_MASK_PATTERN = 0x5412; 76 const int32_t CBC_QRCoderMatrixUtil::TYPE_INFO_MASK_PATTERN = 0x5412;
77 77
78 void CBC_QRCoderMatrixUtil::ClearMatrix(CBC_CommonByteMatrix* matrix, 78 void CBC_QRCoderMatrixUtil::ClearMatrix(CBC_CommonByteMatrix* matrix,
79 int32_t& e) { 79 int32_t& e) {
80 if (matrix == NULL) { 80 if (!matrix) {
81 e = BCExceptionNullPointer; 81 e = BCExceptionNullPointer;
82 BC_EXCEPTION_CHECK_ReturnVoid(e); 82 BC_EXCEPTION_CHECK_ReturnVoid(e);
83 } 83 }
84 matrix->clear((uint8_t)-1); 84 matrix->clear((uint8_t)-1);
85 } 85 }
86 void CBC_QRCoderMatrixUtil::BuildMatrix( 86 void CBC_QRCoderMatrixUtil::BuildMatrix(
87 CBC_QRCoderBitVector* dataBits, 87 CBC_QRCoderBitVector* dataBits,
88 CBC_QRCoderErrorCorrectionLevel* ecLevel, 88 CBC_QRCoderErrorCorrectionLevel* ecLevel,
89 int32_t version, 89 int32_t version,
90 int32_t maskPattern, 90 int32_t maskPattern,
91 CBC_CommonByteMatrix* matrix, 91 CBC_CommonByteMatrix* matrix,
92 int32_t& e) { 92 int32_t& e) {
93 if (matrix == NULL) { 93 if (!matrix) {
94 e = BCExceptionNullPointer; 94 e = BCExceptionNullPointer;
95 BC_EXCEPTION_CHECK_ReturnVoid(e); 95 BC_EXCEPTION_CHECK_ReturnVoid(e);
96 } 96 }
97 ClearMatrix(matrix, e); 97 ClearMatrix(matrix, e);
98 BC_EXCEPTION_CHECK_ReturnVoid(e); 98 BC_EXCEPTION_CHECK_ReturnVoid(e);
99 EmbedBasicPatterns(version, matrix, e); 99 EmbedBasicPatterns(version, matrix, e);
100 BC_EXCEPTION_CHECK_ReturnVoid(e); 100 BC_EXCEPTION_CHECK_ReturnVoid(e);
101 EmbedTypeInfo(ecLevel, maskPattern, matrix, e); 101 EmbedTypeInfo(ecLevel, maskPattern, matrix, e);
102 BC_EXCEPTION_CHECK_ReturnVoid(e); 102 BC_EXCEPTION_CHECK_ReturnVoid(e);
103 MaybeEmbedVersionInfo(version, matrix, e); 103 MaybeEmbedVersionInfo(version, matrix, e);
104 BC_EXCEPTION_CHECK_ReturnVoid(e); 104 BC_EXCEPTION_CHECK_ReturnVoid(e);
105 EmbedDataBits(dataBits, maskPattern, matrix, e); 105 EmbedDataBits(dataBits, maskPattern, matrix, e);
106 BC_EXCEPTION_CHECK_ReturnVoid(e); 106 BC_EXCEPTION_CHECK_ReturnVoid(e);
107 } 107 }
108 void CBC_QRCoderMatrixUtil::EmbedBasicPatterns(int32_t version, 108 void CBC_QRCoderMatrixUtil::EmbedBasicPatterns(int32_t version,
109 CBC_CommonByteMatrix* matrix, 109 CBC_CommonByteMatrix* matrix,
110 int32_t& e) { 110 int32_t& e) {
111 if (matrix == NULL) { 111 if (!matrix) {
112 e = BCExceptionNullPointer; 112 e = BCExceptionNullPointer;
113 BC_EXCEPTION_CHECK_ReturnVoid(e); 113 BC_EXCEPTION_CHECK_ReturnVoid(e);
114 } 114 }
115 EmbedPositionDetectionPatternsAndSeparators(matrix, e); 115 EmbedPositionDetectionPatternsAndSeparators(matrix, e);
116 BC_EXCEPTION_CHECK_ReturnVoid(e); 116 BC_EXCEPTION_CHECK_ReturnVoid(e);
117 EmbedDarkDotAtLeftBottomCorner(matrix, e); 117 EmbedDarkDotAtLeftBottomCorner(matrix, e);
118 BC_EXCEPTION_CHECK_ReturnVoid(e); 118 BC_EXCEPTION_CHECK_ReturnVoid(e);
119 MaybeEmbedPositionAdjustmentPatterns(version, matrix, e); 119 MaybeEmbedPositionAdjustmentPatterns(version, matrix, e);
120 BC_EXCEPTION_CHECK_ReturnVoid(e); 120 BC_EXCEPTION_CHECK_ReturnVoid(e);
121 EmbedTimingPatterns(matrix, e); 121 EmbedTimingPatterns(matrix, e);
122 BC_EXCEPTION_CHECK_ReturnVoid(e); 122 BC_EXCEPTION_CHECK_ReturnVoid(e);
123 } 123 }
124 void CBC_QRCoderMatrixUtil::EmbedTypeInfo( 124 void CBC_QRCoderMatrixUtil::EmbedTypeInfo(
125 CBC_QRCoderErrorCorrectionLevel* ecLevel, 125 CBC_QRCoderErrorCorrectionLevel* ecLevel,
126 int32_t maskPattern, 126 int32_t maskPattern,
127 CBC_CommonByteMatrix* matrix, 127 CBC_CommonByteMatrix* matrix,
128 int32_t& e) { 128 int32_t& e) {
129 if (matrix == NULL) { 129 if (!matrix) {
130 e = BCExceptionNullPointer; 130 e = BCExceptionNullPointer;
131 BC_EXCEPTION_CHECK_ReturnVoid(e); 131 BC_EXCEPTION_CHECK_ReturnVoid(e);
132 } 132 }
133 CBC_QRCoderBitVector typeInfoBits; 133 CBC_QRCoderBitVector typeInfoBits;
134 typeInfoBits.Init(); 134 typeInfoBits.Init();
135 MakeTypeInfoBits(ecLevel, maskPattern, &typeInfoBits, e); 135 MakeTypeInfoBits(ecLevel, maskPattern, &typeInfoBits, e);
136 BC_EXCEPTION_CHECK_ReturnVoid(e); 136 BC_EXCEPTION_CHECK_ReturnVoid(e);
137 for (int32_t i = 0; i < typeInfoBits.Size(); i++) { 137 for (int32_t i = 0; i < typeInfoBits.Size(); i++) {
138 int32_t bit = typeInfoBits.At(typeInfoBits.Size() - 1 - i, e); 138 int32_t bit = typeInfoBits.At(typeInfoBits.Size() - 1 - i, e);
139 BC_EXCEPTION_CHECK_ReturnVoid(e); 139 BC_EXCEPTION_CHECK_ReturnVoid(e);
140 int32_t x1 = TYPE_INFO_COORDINATES[i][0]; 140 int32_t x1 = TYPE_INFO_COORDINATES[i][0];
141 int32_t y1 = TYPE_INFO_COORDINATES[i][1]; 141 int32_t y1 = TYPE_INFO_COORDINATES[i][1];
142 matrix->Set(x1, y1, bit); 142 matrix->Set(x1, y1, bit);
143 if (i < 8) { 143 if (i < 8) {
144 int32_t x2 = matrix->GetWidth() - i - 1; 144 int32_t x2 = matrix->GetWidth() - i - 1;
145 int32_t y2 = 8; 145 int32_t y2 = 8;
146 matrix->Set(x2, y2, bit); 146 matrix->Set(x2, y2, bit);
147 } else { 147 } else {
148 int32_t x2 = 8; 148 int32_t x2 = 8;
149 int32_t y2 = matrix->GetHeight() - 7 + (i - 8); 149 int32_t y2 = matrix->GetHeight() - 7 + (i - 8);
150 matrix->Set(x2, y2, bit); 150 matrix->Set(x2, y2, bit);
151 } 151 }
152 } 152 }
153 } 153 }
154 void CBC_QRCoderMatrixUtil::MaybeEmbedVersionInfo(int32_t version, 154 void CBC_QRCoderMatrixUtil::MaybeEmbedVersionInfo(int32_t version,
155 CBC_CommonByteMatrix* matrix, 155 CBC_CommonByteMatrix* matrix,
156 int32_t& e) { 156 int32_t& e) {
157 if (matrix == NULL) { 157 if (!matrix) {
158 e = BCExceptionNullPointer; 158 e = BCExceptionNullPointer;
159 BC_EXCEPTION_CHECK_ReturnVoid(e); 159 BC_EXCEPTION_CHECK_ReturnVoid(e);
160 } 160 }
161 if (version < 7) { 161 if (version < 7) {
162 return; 162 return;
163 } 163 }
164 CBC_QRCoderBitVector versionInfoBits; 164 CBC_QRCoderBitVector versionInfoBits;
165 versionInfoBits.Init(); 165 versionInfoBits.Init();
166 MakeVersionInfoBits(version, &versionInfoBits, e); 166 MakeVersionInfoBits(version, &versionInfoBits, e);
167 BC_EXCEPTION_CHECK_ReturnVoid(e); 167 BC_EXCEPTION_CHECK_ReturnVoid(e);
168 int32_t bitIndex = 6 * 3 - 1; 168 int32_t bitIndex = 6 * 3 - 1;
169 for (int32_t i = 0; i < 6; i++) { 169 for (int32_t i = 0; i < 6; i++) {
170 for (int32_t j = 0; j < 3; j++) { 170 for (int32_t j = 0; j < 3; j++) {
171 int32_t bit = versionInfoBits.At(bitIndex, e); 171 int32_t bit = versionInfoBits.At(bitIndex, e);
172 BC_EXCEPTION_CHECK_ReturnVoid(e); 172 BC_EXCEPTION_CHECK_ReturnVoid(e);
173 bitIndex--; 173 bitIndex--;
174 matrix->Set(i, matrix->GetHeight() - 11 + j, bit); 174 matrix->Set(i, matrix->GetHeight() - 11 + j, bit);
175 matrix->Set(matrix->GetHeight() - 11 + j, i, bit); 175 matrix->Set(matrix->GetHeight() - 11 + j, i, bit);
176 } 176 }
177 } 177 }
178 } 178 }
179 void CBC_QRCoderMatrixUtil::EmbedDataBits(CBC_QRCoderBitVector* dataBits, 179 void CBC_QRCoderMatrixUtil::EmbedDataBits(CBC_QRCoderBitVector* dataBits,
180 int32_t maskPattern, 180 int32_t maskPattern,
181 CBC_CommonByteMatrix* matrix, 181 CBC_CommonByteMatrix* matrix,
182 int32_t& e) { 182 int32_t& e) {
183 if (matrix == NULL || dataBits == NULL) { 183 if (!matrix || !dataBits) {
184 e = BCExceptionNullPointer; 184 e = BCExceptionNullPointer;
185 BC_EXCEPTION_CHECK_ReturnVoid(e); 185 BC_EXCEPTION_CHECK_ReturnVoid(e);
186 } 186 }
187 int32_t bitIndex = 0; 187 int32_t bitIndex = 0;
188 int32_t direction = -1; 188 int32_t direction = -1;
189 int32_t x = matrix->GetWidth() - 1; 189 int32_t x = matrix->GetWidth() - 1;
190 int32_t y = matrix->GetHeight() - 1; 190 int32_t y = matrix->GetHeight() - 1;
191 while (x > 0) { 191 while (x > 0) {
192 if (x == 6) { 192 if (x == 6) {
193 x -= 1; 193 x -= 1;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 while (FindMSBSet(value) >= msbSetInPoly) { 236 while (FindMSBSet(value) >= msbSetInPoly) {
237 value ^= poly << (FindMSBSet(value) - msbSetInPoly); 237 value ^= poly << (FindMSBSet(value) - msbSetInPoly);
238 } 238 }
239 return value; 239 return value;
240 } 240 }
241 void CBC_QRCoderMatrixUtil::MakeTypeInfoBits( 241 void CBC_QRCoderMatrixUtil::MakeTypeInfoBits(
242 CBC_QRCoderErrorCorrectionLevel* ecLevel, 242 CBC_QRCoderErrorCorrectionLevel* ecLevel,
243 int32_t maskPattern, 243 int32_t maskPattern,
244 CBC_QRCoderBitVector* bits, 244 CBC_QRCoderBitVector* bits,
245 int32_t& e) { 245 int32_t& e) {
246 if (bits == NULL) { 246 if (!bits) {
247 e = BCExceptionNullPointer; 247 e = BCExceptionNullPointer;
248 BC_EXCEPTION_CHECK_ReturnVoid(e); 248 BC_EXCEPTION_CHECK_ReturnVoid(e);
249 } 249 }
250 if (!CBC_QRCoder::IsValidMaskPattern(maskPattern)) { 250 if (!CBC_QRCoder::IsValidMaskPattern(maskPattern)) {
251 e = BCExceptionBadMask; 251 e = BCExceptionBadMask;
252 BC_EXCEPTION_CHECK_ReturnVoid(e); 252 BC_EXCEPTION_CHECK_ReturnVoid(e);
253 } 253 }
254 int32_t typeInfo = (ecLevel->GetBits() << 3) | maskPattern; 254 int32_t typeInfo = (ecLevel->GetBits() << 3) | maskPattern;
255 BC_EXCEPTION_CHECK_ReturnVoid(e); 255 BC_EXCEPTION_CHECK_ReturnVoid(e);
256 bits->AppendBits(typeInfo, 5, e); 256 bits->AppendBits(typeInfo, 5, e);
257 int32_t bchCode = CalculateBCHCode(typeInfo, TYPE_INFO_POLY); 257 int32_t bchCode = CalculateBCHCode(typeInfo, TYPE_INFO_POLY);
258 BC_EXCEPTION_CHECK_ReturnVoid(e); 258 BC_EXCEPTION_CHECK_ReturnVoid(e);
259 bits->AppendBits(bchCode, 10, e); 259 bits->AppendBits(bchCode, 10, e);
260 CBC_QRCoderBitVector maskBits; 260 CBC_QRCoderBitVector maskBits;
261 maskBits.Init(); 261 maskBits.Init();
262 maskBits.AppendBits(TYPE_INFO_MASK_PATTERN, 15, e); 262 maskBits.AppendBits(TYPE_INFO_MASK_PATTERN, 15, e);
263 BC_EXCEPTION_CHECK_ReturnVoid(e); 263 BC_EXCEPTION_CHECK_ReturnVoid(e);
264 bits->XOR(&maskBits, e); 264 bits->XOR(&maskBits, e);
265 BC_EXCEPTION_CHECK_ReturnVoid(e); 265 BC_EXCEPTION_CHECK_ReturnVoid(e);
266 if (bits->Size() != 15) { 266 if (bits->Size() != 15) {
267 e = BCExceptionBitSizeNot15; 267 e = BCExceptionBitSizeNot15;
268 BC_EXCEPTION_CHECK_ReturnVoid(e); 268 BC_EXCEPTION_CHECK_ReturnVoid(e);
269 } 269 }
270 } 270 }
271 void CBC_QRCoderMatrixUtil::MakeVersionInfoBits(int32_t version, 271 void CBC_QRCoderMatrixUtil::MakeVersionInfoBits(int32_t version,
272 CBC_QRCoderBitVector* bits, 272 CBC_QRCoderBitVector* bits,
273 int32_t& e) { 273 int32_t& e) {
274 if (bits == NULL) { 274 if (!bits) {
275 e = BCExceptionNullPointer; 275 e = BCExceptionNullPointer;
276 BC_EXCEPTION_CHECK_ReturnVoid(e); 276 BC_EXCEPTION_CHECK_ReturnVoid(e);
277 } 277 }
278 bits->AppendBits(version, 6, e); 278 bits->AppendBits(version, 6, e);
279 BC_EXCEPTION_CHECK_ReturnVoid(e); 279 BC_EXCEPTION_CHECK_ReturnVoid(e);
280 int32_t bchCode = CalculateBCHCode(version, VERSION_INFO_POLY); 280 int32_t bchCode = CalculateBCHCode(version, VERSION_INFO_POLY);
281 bits->AppendBits(bchCode, 12, e); 281 bits->AppendBits(bchCode, 12, e);
282 BC_EXCEPTION_CHECK_ReturnVoid(e); 282 BC_EXCEPTION_CHECK_ReturnVoid(e);
283 if (bits->Size() != 18) { 283 if (bits->Size() != 18) {
284 e = BCExceptionBitSizeNot18; 284 e = BCExceptionBitSizeNot18;
285 BC_EXCEPTION_CHECK_ReturnVoid(e); 285 BC_EXCEPTION_CHECK_ReturnVoid(e);
286 } 286 }
287 } 287 }
288 FX_BOOL CBC_QRCoderMatrixUtil::IsEmpty(int32_t value) { 288 FX_BOOL CBC_QRCoderMatrixUtil::IsEmpty(int32_t value) {
289 return (uint8_t)value == 0xff; 289 return (uint8_t)value == 0xff;
290 } 290 }
291 FX_BOOL CBC_QRCoderMatrixUtil::IsValidValue(int32_t value) { 291 FX_BOOL CBC_QRCoderMatrixUtil::IsValidValue(int32_t value) {
292 return ((uint8_t)value == 0xff || (uint8_t)value == 0x00 || 292 return ((uint8_t)value == 0xff || (uint8_t)value == 0x00 ||
293 (uint8_t)value == 0x01); 293 (uint8_t)value == 0x01);
294 } 294 }
295 void CBC_QRCoderMatrixUtil::EmbedTimingPatterns(CBC_CommonByteMatrix* matrix, 295 void CBC_QRCoderMatrixUtil::EmbedTimingPatterns(CBC_CommonByteMatrix* matrix,
296 int32_t& e) { 296 int32_t& e) {
297 if (matrix == NULL) { 297 if (!matrix) {
298 e = BCExceptionNullPointer; 298 e = BCExceptionNullPointer;
299 BC_EXCEPTION_CHECK_ReturnVoid(e); 299 BC_EXCEPTION_CHECK_ReturnVoid(e);
300 } 300 }
301 for (int32_t i = 8; i < matrix->GetWidth() - 8; i++) { 301 for (int32_t i = 8; i < matrix->GetWidth() - 8; i++) {
302 int32_t bit = (i + 1) % 2; 302 int32_t bit = (i + 1) % 2;
303 if (!IsValidValue(matrix->Get(i, 6))) { 303 if (!IsValidValue(matrix->Get(i, 6))) {
304 e = BCExceptionInvalidateImageData; 304 e = BCExceptionInvalidateImageData;
305 BC_EXCEPTION_CHECK_ReturnVoid(e); 305 BC_EXCEPTION_CHECK_ReturnVoid(e);
306 } 306 }
307 if (IsEmpty(matrix->Get(i, 6))) { 307 if (IsEmpty(matrix->Get(i, 6))) {
308 matrix->Set(i, 6, bit); 308 matrix->Set(i, 6, bit);
309 } 309 }
310 if (!IsValidValue(matrix->Get(6, i))) { 310 if (!IsValidValue(matrix->Get(6, i))) {
311 e = BCExceptionInvalidateImageData; 311 e = BCExceptionInvalidateImageData;
312 BC_EXCEPTION_CHECK_ReturnVoid(e); 312 BC_EXCEPTION_CHECK_ReturnVoid(e);
313 } 313 }
314 if (IsEmpty(matrix->Get(6, i))) { 314 if (IsEmpty(matrix->Get(6, i))) {
315 matrix->Set(6, i, bit); 315 matrix->Set(6, i, bit);
316 } 316 }
317 } 317 }
318 } 318 }
319 void CBC_QRCoderMatrixUtil::EmbedDarkDotAtLeftBottomCorner( 319 void CBC_QRCoderMatrixUtil::EmbedDarkDotAtLeftBottomCorner(
320 CBC_CommonByteMatrix* matrix, 320 CBC_CommonByteMatrix* matrix,
321 int32_t& e) { 321 int32_t& e) {
322 if (matrix == NULL) { 322 if (!matrix) {
323 e = BCExceptionNullPointer; 323 e = BCExceptionNullPointer;
324 BC_EXCEPTION_CHECK_ReturnVoid(e); 324 BC_EXCEPTION_CHECK_ReturnVoid(e);
325 } 325 }
326 if (matrix->Get(8, matrix->GetHeight() - 8) == 0) { 326 if (matrix->Get(8, matrix->GetHeight() - 8) == 0) {
327 e = BCExceptionHeight_8BeZero; 327 e = BCExceptionHeight_8BeZero;
328 BC_EXCEPTION_CHECK_ReturnVoid(e); 328 BC_EXCEPTION_CHECK_ReturnVoid(e);
329 } 329 }
330 matrix->Set(8, matrix->GetHeight() - 8, 1); 330 matrix->Set(8, matrix->GetHeight() - 8, 1);
331 } 331 }
332 void CBC_QRCoderMatrixUtil::EmbedHorizontalSeparationPattern( 332 void CBC_QRCoderMatrixUtil::EmbedHorizontalSeparationPattern(
333 int32_t xStart, 333 int32_t xStart,
334 int32_t yStart, 334 int32_t yStart,
335 CBC_CommonByteMatrix* matrix, 335 CBC_CommonByteMatrix* matrix,
336 int32_t& e) { 336 int32_t& e) {
337 if (matrix == NULL) { 337 if (!matrix) {
338 e = BCExceptionNullPointer; 338 e = BCExceptionNullPointer;
339 BC_EXCEPTION_CHECK_ReturnVoid(e); 339 BC_EXCEPTION_CHECK_ReturnVoid(e);
340 } 340 }
341 for (int32_t x = 0; x < 8; x++) { 341 for (int32_t x = 0; x < 8; x++) {
342 if (!IsEmpty(matrix->Get(xStart + x, yStart))) { 342 if (!IsEmpty(matrix->Get(xStart + x, yStart))) {
343 e = BCExceptionInvalidateData; 343 e = BCExceptionInvalidateData;
344 BC_EXCEPTION_CHECK_ReturnVoid(e) 344 BC_EXCEPTION_CHECK_ReturnVoid(e)
345 } 345 }
346 matrix->Set(xStart + x, yStart, HORIZONTAL_SEPARATION_PATTERN[0][x]); 346 matrix->Set(xStart + x, yStart, HORIZONTAL_SEPARATION_PATTERN[0][x]);
347 } 347 }
348 } 348 }
349 void CBC_QRCoderMatrixUtil::EmbedVerticalSeparationPattern( 349 void CBC_QRCoderMatrixUtil::EmbedVerticalSeparationPattern(
350 int32_t xStart, 350 int32_t xStart,
351 int32_t yStart, 351 int32_t yStart,
352 CBC_CommonByteMatrix* matrix, 352 CBC_CommonByteMatrix* matrix,
353 int32_t& e) { 353 int32_t& e) {
354 if (matrix == NULL) { 354 if (!matrix) {
355 e = BCExceptionNullPointer; 355 e = BCExceptionNullPointer;
356 BC_EXCEPTION_CHECK_ReturnVoid(e); 356 BC_EXCEPTION_CHECK_ReturnVoid(e);
357 } 357 }
358 for (int32_t y = 0; y < 7; y++) { 358 for (int32_t y = 0; y < 7; y++) {
359 if (!IsEmpty(matrix->Get(xStart, yStart + y))) { 359 if (!IsEmpty(matrix->Get(xStart, yStart + y))) {
360 e = BCExceptionInvalidateData; 360 e = BCExceptionInvalidateData;
361 BC_EXCEPTION_CHECK_ReturnVoid(e); 361 BC_EXCEPTION_CHECK_ReturnVoid(e);
362 } 362 }
363 matrix->Set(xStart, yStart + y, VERTICAL_SEPARATION_PATTERN[y][0]); 363 matrix->Set(xStart, yStart + y, VERTICAL_SEPARATION_PATTERN[y][0]);
364 } 364 }
365 } 365 }
366 void CBC_QRCoderMatrixUtil::EmbedPositionAdjustmentPattern( 366 void CBC_QRCoderMatrixUtil::EmbedPositionAdjustmentPattern(
367 int32_t xStart, 367 int32_t xStart,
368 int32_t yStart, 368 int32_t yStart,
369 CBC_CommonByteMatrix* matrix, 369 CBC_CommonByteMatrix* matrix,
370 int32_t& e) { 370 int32_t& e) {
371 if (matrix == NULL) { 371 if (!matrix) {
372 e = BCExceptionNullPointer; 372 e = BCExceptionNullPointer;
373 BC_EXCEPTION_CHECK_ReturnVoid(e); 373 BC_EXCEPTION_CHECK_ReturnVoid(e);
374 } 374 }
375 for (int32_t y = 0; y < 5; y++) { 375 for (int32_t y = 0; y < 5; y++) {
376 for (int32_t x = 0; x < 5; x++) { 376 for (int32_t x = 0; x < 5; x++) {
377 if (!IsEmpty(matrix->Get(xStart + x, y + yStart))) { 377 if (!IsEmpty(matrix->Get(xStart + x, y + yStart))) {
378 e = BCExceptionInvalidateData; 378 e = BCExceptionInvalidateData;
379 BC_EXCEPTION_CHECK_ReturnVoid(e); 379 BC_EXCEPTION_CHECK_ReturnVoid(e);
380 } 380 }
381 matrix->Set(xStart + x, yStart + y, POSITION_ADJUSTMENT_PATTERN[y][x]); 381 matrix->Set(xStart + x, yStart + y, POSITION_ADJUSTMENT_PATTERN[y][x]);
382 } 382 }
383 } 383 }
384 } 384 }
385 void CBC_QRCoderMatrixUtil::EmbedPositionDetectionPattern( 385 void CBC_QRCoderMatrixUtil::EmbedPositionDetectionPattern(
386 int32_t xStart, 386 int32_t xStart,
387 int32_t yStart, 387 int32_t yStart,
388 CBC_CommonByteMatrix* matrix, 388 CBC_CommonByteMatrix* matrix,
389 int32_t& e) { 389 int32_t& e) {
390 if (matrix == NULL) { 390 if (!matrix) {
391 e = BCExceptionNullPointer; 391 e = BCExceptionNullPointer;
392 BC_EXCEPTION_CHECK_ReturnVoid(e); 392 BC_EXCEPTION_CHECK_ReturnVoid(e);
393 } 393 }
394 for (int32_t y = 0; y < 7; y++) { 394 for (int32_t y = 0; y < 7; y++) {
395 for (int32_t x = 0; x < 7; x++) { 395 for (int32_t x = 0; x < 7; x++) {
396 if (!IsEmpty(matrix->Get(xStart + x, yStart + y))) { 396 if (!IsEmpty(matrix->Get(xStart + x, yStart + y))) {
397 e = BCExceptionInvalidateData; 397 e = BCExceptionInvalidateData;
398 BC_EXCEPTION_CHECK_ReturnVoid(e); 398 BC_EXCEPTION_CHECK_ReturnVoid(e);
399 } 399 }
400 matrix->Set(xStart + x, yStart + y, POSITION_DETECTION_PATTERN[y][x]); 400 matrix->Set(xStart + x, yStart + y, POSITION_DETECTION_PATTERN[y][x]);
401 } 401 }
402 } 402 }
403 } 403 }
404 void CBC_QRCoderMatrixUtil::EmbedPositionDetectionPatternsAndSeparators( 404 void CBC_QRCoderMatrixUtil::EmbedPositionDetectionPatternsAndSeparators(
405 CBC_CommonByteMatrix* matrix, 405 CBC_CommonByteMatrix* matrix,
406 int32_t& e) { 406 int32_t& e) {
407 if (matrix == NULL) { 407 if (!matrix) {
408 e = BCExceptionNullPointer; 408 e = BCExceptionNullPointer;
409 BC_EXCEPTION_CHECK_ReturnVoid(e); 409 BC_EXCEPTION_CHECK_ReturnVoid(e);
410 } 410 }
411 int32_t pdpWidth = 7; 411 int32_t pdpWidth = 7;
412 EmbedPositionDetectionPattern(0, 0, matrix, e); 412 EmbedPositionDetectionPattern(0, 0, matrix, e);
413 BC_EXCEPTION_CHECK_ReturnVoid(e); 413 BC_EXCEPTION_CHECK_ReturnVoid(e);
414 EmbedPositionDetectionPattern(matrix->GetWidth() - pdpWidth, 0, matrix, e); 414 EmbedPositionDetectionPattern(matrix->GetWidth() - pdpWidth, 0, matrix, e);
415 BC_EXCEPTION_CHECK_ReturnVoid(e); 415 BC_EXCEPTION_CHECK_ReturnVoid(e);
416 EmbedPositionDetectionPattern(0, matrix->GetWidth() - pdpWidth, matrix, e); 416 EmbedPositionDetectionPattern(0, matrix->GetWidth() - pdpWidth, matrix, e);
417 BC_EXCEPTION_CHECK_ReturnVoid(e); 417 BC_EXCEPTION_CHECK_ReturnVoid(e);
(...skipping 12 matching lines...) Expand all
430 e); 430 e);
431 BC_EXCEPTION_CHECK_ReturnVoid(e); 431 BC_EXCEPTION_CHECK_ReturnVoid(e);
432 EmbedVerticalSeparationPattern(vspSize, matrix->GetHeight() - vspSize, matrix, 432 EmbedVerticalSeparationPattern(vspSize, matrix->GetHeight() - vspSize, matrix,
433 e); 433 e);
434 BC_EXCEPTION_CHECK_ReturnVoid(e); 434 BC_EXCEPTION_CHECK_ReturnVoid(e);
435 } 435 }
436 void CBC_QRCoderMatrixUtil::MaybeEmbedPositionAdjustmentPatterns( 436 void CBC_QRCoderMatrixUtil::MaybeEmbedPositionAdjustmentPatterns(
437 int32_t version, 437 int32_t version,
438 CBC_CommonByteMatrix* matrix, 438 CBC_CommonByteMatrix* matrix,
439 int32_t& e) { 439 int32_t& e) {
440 if (matrix == NULL) { 440 if (!matrix) {
441 e = BCExceptionNullPointer; 441 e = BCExceptionNullPointer;
442 BC_EXCEPTION_CHECK_ReturnVoid(e); 442 BC_EXCEPTION_CHECK_ReturnVoid(e);
443 } 443 }
444 if (version < 2) { 444 if (version < 2) {
445 return; 445 return;
446 } 446 }
447 int32_t index = version - 1; 447 int32_t index = version - 1;
448 int32_t const* coordinates = 448 int32_t const* coordinates =
449 &(POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index][0]); 449 &(POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index][0]);
450 int32_t numCoordinate = 7; 450 int32_t numCoordinate = 7;
(...skipping 14 matching lines...) Expand all
465 int32_t CBC_QRCoderMatrixUtil::FindMSBSet(int32_t value) { 465 int32_t CBC_QRCoderMatrixUtil::FindMSBSet(int32_t value) {
466 int32_t numDigits = 0; 466 int32_t numDigits = 0;
467 while (value != 0) { 467 while (value != 0) {
468 value >>= 1; 468 value >>= 1;
469 ++numDigits; 469 ++numDigits;
470 } 470 }
471 return numDigits; 471 return numDigits;
472 } 472 }
473 CBC_QRCoderMatrixUtil::CBC_QRCoderMatrixUtil() {} 473 CBC_QRCoderMatrixUtil::CBC_QRCoderMatrixUtil() {}
474 CBC_QRCoderMatrixUtil::~CBC_QRCoderMatrixUtil() {} 474 CBC_QRCoderMatrixUtil::~CBC_QRCoderMatrixUtil() {}
OLDNEW
« no previous file with comments | « xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.cpp ('k') | xfa/fxbarcode/qrcode/BC_QRCoderMode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698