OLD | NEW |
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 2006 Jeremias Maerki in part, and ZXing Authors in part | 8 * Copyright 2006 Jeremias Maerki in part, and ZXing Authors in part |
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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 0x1035c, 0x1034e, 0x10758, 0x183ae, 0x1074c, 0x10746, 0x1032e, 0x1076e, | 374 0x1035c, 0x1034e, 0x10758, 0x183ae, 0x1074c, 0x10746, 0x1032e, 0x1076e, |
375 0x10f50, 0x187ac, 0x10f48, 0x187a6, 0x10f44, 0x10f42, 0x1072c, 0x10f6c, | 375 0x10f50, 0x187ac, 0x10f48, 0x187a6, 0x10f44, 0x10f42, 0x1072c, 0x10f6c, |
376 0x10726, 0x10f66, 0x18fa8, 0x1c7d6, 0x18fa4, 0x18fa2, 0x10f28, 0x18796, | 376 0x10726, 0x10f66, 0x18fa8, 0x1c7d6, 0x18fa4, 0x18fa2, 0x10f28, 0x18796, |
377 0x11f68, 0x18fb6, 0x11f64, 0x10f22, 0x11f62, 0x10716, 0x10f36, 0x11f76, | 377 0x11f68, 0x18fb6, 0x11f64, 0x10f22, 0x11f62, 0x10716, 0x10f36, 0x11f76, |
378 0x1cfd4, 0x1cfd2, 0x18f94, 0x19fb4, 0x18f92, 0x19fb2, 0x10f14, 0x11f34, | 378 0x1cfd4, 0x1cfd2, 0x18f94, 0x19fb4, 0x18f92, 0x19fb2, 0x10f14, 0x11f34, |
379 0x10f12, 0x13f74, 0x11f32, 0x13f72, 0x1cfca, 0x18f8a, 0x19f9a, 0x10f0a, | 379 0x10f12, 0x13f74, 0x11f32, 0x13f72, 0x1cfca, 0x18f8a, 0x19f9a, 0x10f0a, |
380 0x11f1a, 0x13f3a, 0x103ac, 0x103a6, 0x107a8, 0x183d6, 0x107a4, 0x107a2, | 380 0x11f1a, 0x13f3a, 0x103ac, 0x103a6, 0x107a8, 0x183d6, 0x107a4, 0x107a2, |
381 0x10396, 0x107b6, 0x187d4, 0x187d2, 0x10794, 0x10fb4, 0x10792, 0x10fb2, | 381 0x10396, 0x107b6, 0x187d4, 0x187d2, 0x10794, 0x10fb4, 0x10792, 0x10fb2, |
382 0x1c7ea}}; | 382 0x1c7ea}}; |
383 | 383 |
384 CBC_PDF417::CBC_PDF417() : CBC_PDF417(FALSE) {} | 384 CBC_PDF417::CBC_PDF417() : CBC_PDF417(false) {} |
385 | 385 |
386 CBC_PDF417::CBC_PDF417(FX_BOOL compact) | 386 CBC_PDF417::CBC_PDF417(bool compact) |
387 : m_compact(compact), | 387 : m_compact(compact), |
388 m_compaction(AUTO), | 388 m_compaction(AUTO), |
389 m_minCols(1), | 389 m_minCols(1), |
390 m_maxCols(30), | 390 m_maxCols(30), |
391 m_maxRows(90), | 391 m_maxRows(90), |
392 m_minRows(3) {} | 392 m_minRows(3) {} |
393 | 393 |
394 CBC_PDF417::~CBC_PDF417() {} | 394 CBC_PDF417::~CBC_PDF417() {} |
395 | 395 |
396 CBC_BarcodeMatrix* CBC_PDF417::getBarcodeMatrix() { | 396 CBC_BarcodeMatrix* CBC_PDF417::getBarcodeMatrix() { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 m_maxCols = maxCols; | 444 m_maxCols = maxCols; |
445 m_minCols = minCols; | 445 m_minCols = minCols; |
446 m_maxRows = maxRows; | 446 m_maxRows = maxRows; |
447 m_minRows = minRows; | 447 m_minRows = minRows; |
448 } | 448 } |
449 | 449 |
450 void CBC_PDF417::setCompaction(Compaction compaction) { | 450 void CBC_PDF417::setCompaction(Compaction compaction) { |
451 m_compaction = compaction; | 451 m_compaction = compaction; |
452 } | 452 } |
453 | 453 |
454 void CBC_PDF417::setCompact(FX_BOOL compact) { | 454 void CBC_PDF417::setCompact(bool compact) { |
455 m_compact = compact; | 455 m_compact = compact; |
456 } | 456 } |
457 | 457 |
458 int32_t CBC_PDF417::calculateNumberOfRows(int32_t m, int32_t k, int32_t c) { | 458 int32_t CBC_PDF417::calculateNumberOfRows(int32_t m, int32_t k, int32_t c) { |
459 int32_t r = ((m + 1 + k) / c) + 1; | 459 int32_t r = ((m + 1 + k) / c) + 1; |
460 if (c * r >= (m + 1 + k + c)) { | 460 if (c * r >= (m + 1 + k + c)) { |
461 r--; | 461 r--; |
462 } | 462 } |
463 return r; | 463 return r; |
464 } | 464 } |
465 | 465 |
466 int32_t CBC_PDF417::getNumberOfPadCodewords(int32_t m, | 466 int32_t CBC_PDF417::getNumberOfPadCodewords(int32_t m, |
467 int32_t k, | 467 int32_t k, |
468 int32_t c, | 468 int32_t c, |
469 int32_t r) { | 469 int32_t r) { |
470 int32_t n = c * r - k; | 470 int32_t n = c * r - k; |
471 return n > m + 1 ? n - m - 1 : 0; | 471 return n > m + 1 ? n - m - 1 : 0; |
472 } | 472 } |
473 | 473 |
474 void CBC_PDF417::encodeChar(int32_t pattern, | 474 void CBC_PDF417::encodeChar(int32_t pattern, |
475 int32_t len, | 475 int32_t len, |
476 CBC_BarcodeRow* logic) { | 476 CBC_BarcodeRow* logic) { |
477 int32_t map = 1 << (len - 1); | 477 int32_t map = 1 << (len - 1); |
478 FX_BOOL last = ((pattern & map) != 0); | 478 bool last = ((pattern & map) != 0); |
479 int32_t width = 0; | 479 int32_t width = 0; |
480 for (int32_t i = 0; i < len; i++) { | 480 for (int32_t i = 0; i < len; i++) { |
481 FX_BOOL black = ((pattern & map) != 0); | 481 bool black = ((pattern & map) != 0); |
482 if (last == black) { | 482 if (last == black) { |
483 width++; | 483 width++; |
484 } else { | 484 } else { |
485 logic->addBar(last, width); | 485 logic->addBar(last, width); |
486 last = black; | 486 last = black; |
487 width = 1; | 487 width = 1; |
488 } | 488 } |
489 map >>= 1; | 489 map >>= 1; |
490 } | 490 } |
491 logic->addBar(last, width); | 491 logic->addBar(last, width); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 dimension->Add(m_minCols); | 569 dimension->Add(m_minCols); |
570 dimension->Add(rows); | 570 dimension->Add(rows); |
571 } | 571 } |
572 } | 572 } |
573 if (!dimension) { | 573 if (!dimension) { |
574 e = BCExceptionUnableToFitMessageInColumns; | 574 e = BCExceptionUnableToFitMessageInColumns; |
575 return nullptr; | 575 return nullptr; |
576 } | 576 } |
577 return dimension; | 577 return dimension; |
578 } | 578 } |
OLD | NEW |