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 372 matching lines...) Loading... |
383 FX_FLOAT CBC_PDF417::PREFERRED_RATIO = 3.0f; | 383 FX_FLOAT CBC_PDF417::PREFERRED_RATIO = 3.0f; |
384 FX_FLOAT CBC_PDF417::DEFAULT_MODULE_WIDTH = 0.357f; | 384 FX_FLOAT CBC_PDF417::DEFAULT_MODULE_WIDTH = 0.357f; |
385 FX_FLOAT CBC_PDF417::HEIGHT = 2.0f; | 385 FX_FLOAT CBC_PDF417::HEIGHT = 2.0f; |
386 CBC_PDF417::CBC_PDF417() { | 386 CBC_PDF417::CBC_PDF417() { |
387 m_compact = FALSE; | 387 m_compact = FALSE; |
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 m_barcodeMatrix = NULL; | 393 m_barcodeMatrix = nullptr; |
394 } | 394 } |
395 CBC_PDF417::CBC_PDF417(FX_BOOL compact) { | 395 CBC_PDF417::CBC_PDF417(FX_BOOL compact) { |
396 m_compact = compact; | 396 m_compact = compact; |
397 m_compaction = AUTO; | 397 m_compaction = AUTO; |
398 m_minCols = 1; | 398 m_minCols = 1; |
399 m_maxCols = 30; | 399 m_maxCols = 30; |
400 m_maxRows = 90; | 400 m_maxRows = 90; |
401 m_minRows = 3; | 401 m_minRows = 3; |
402 m_barcodeMatrix = NULL; | 402 m_barcodeMatrix = nullptr; |
403 } | 403 } |
404 | 404 |
405 CBC_PDF417::~CBC_PDF417() { | 405 CBC_PDF417::~CBC_PDF417() { |
406 delete m_barcodeMatrix; | 406 delete m_barcodeMatrix; |
407 } | 407 } |
408 | 408 |
409 CBC_BarcodeMatrix* CBC_PDF417::getBarcodeMatrix() { | 409 CBC_BarcodeMatrix* CBC_PDF417::getBarcodeMatrix() { |
410 return m_barcodeMatrix; | 410 return m_barcodeMatrix; |
411 } | 411 } |
412 void CBC_PDF417::generateBarcodeLogic(CFX_WideString msg, | 412 void CBC_PDF417::generateBarcodeLogic(CFX_WideString msg, |
(...skipping 119 matching lines...) Loading... |
532 encodeChar(pattern, 17, logic->getCurrentRow()); | 532 encodeChar(pattern, 17, logic->getCurrentRow()); |
533 encodeChar(STOP_PATTERN, 18, logic->getCurrentRow()); | 533 encodeChar(STOP_PATTERN, 18, logic->getCurrentRow()); |
534 } | 534 } |
535 } | 535 } |
536 } | 536 } |
537 CFX_Int32Array* CBC_PDF417::determineDimensions( | 537 CFX_Int32Array* CBC_PDF417::determineDimensions( |
538 int32_t sourceCodeWords, | 538 int32_t sourceCodeWords, |
539 int32_t errorCorrectionCodeWords, | 539 int32_t errorCorrectionCodeWords, |
540 int32_t& e) { | 540 int32_t& e) { |
541 FX_FLOAT ratio = 0.0f; | 541 FX_FLOAT ratio = 0.0f; |
542 CFX_Int32Array* dimension = NULL; | 542 CFX_Int32Array* dimension = nullptr; |
543 for (int32_t cols = m_minCols; cols <= m_maxCols; cols++) { | 543 for (int32_t cols = m_minCols; cols <= m_maxCols; cols++) { |
544 int32_t rows = | 544 int32_t rows = |
545 calculateNumberOfRows(sourceCodeWords, errorCorrectionCodeWords, cols); | 545 calculateNumberOfRows(sourceCodeWords, errorCorrectionCodeWords, cols); |
546 if (rows < m_minRows) { | 546 if (rows < m_minRows) { |
547 break; | 547 break; |
548 } | 548 } |
549 if (rows > m_maxRows) { | 549 if (rows > m_maxRows) { |
550 continue; | 550 continue; |
551 } | 551 } |
552 FX_FLOAT newRatio = | 552 FX_FLOAT newRatio = |
553 ((17 * cols + 69) * DEFAULT_MODULE_WIDTH) / (rows * HEIGHT); | 553 ((17 * cols + 69) * DEFAULT_MODULE_WIDTH) / (rows * HEIGHT); |
554 if (dimension && | 554 if (dimension && |
555 fabsf(newRatio - PREFERRED_RATIO) > fabsf(ratio - PREFERRED_RATIO)) { | 555 fabsf(newRatio - PREFERRED_RATIO) > fabsf(ratio - PREFERRED_RATIO)) { |
556 continue; | 556 continue; |
557 } | 557 } |
558 ratio = newRatio; | 558 ratio = newRatio; |
559 delete dimension; | 559 delete dimension; |
560 dimension = new CFX_Int32Array; | 560 dimension = new CFX_Int32Array; |
561 dimension->Add(cols); | 561 dimension->Add(cols); |
562 dimension->Add(rows); | 562 dimension->Add(rows); |
563 } | 563 } |
564 if (dimension == NULL) { | 564 if (!dimension) { |
565 int32_t rows = calculateNumberOfRows(sourceCodeWords, | 565 int32_t rows = calculateNumberOfRows(sourceCodeWords, |
566 errorCorrectionCodeWords, m_minCols); | 566 errorCorrectionCodeWords, m_minCols); |
567 if (rows < m_minRows) { | 567 if (rows < m_minRows) { |
568 dimension = new CFX_Int32Array; | 568 dimension = new CFX_Int32Array; |
569 dimension->Add(m_minCols); | 569 dimension->Add(m_minCols); |
570 dimension->Add(m_minRows); | 570 dimension->Add(m_minRows); |
571 } else if (rows >= 3 && rows <= 90) { | 571 } else if (rows >= 3 && rows <= 90) { |
572 dimension = new CFX_Int32Array; | 572 dimension = new CFX_Int32Array; |
573 dimension->Add(m_minCols); | 573 dimension->Add(m_minCols); |
574 dimension->Add(rows); | 574 dimension->Add(rows); |
575 } | 575 } |
576 } | 576 } |
577 if (dimension == NULL) { | 577 if (!dimension) { |
578 e = BCExceptionUnableToFitMessageInColumns; | 578 e = BCExceptionUnableToFitMessageInColumns; |
579 return NULL; | 579 return nullptr; |
580 } | 580 } |
581 return dimension; | 581 return dimension; |
582 } | 582 } |
OLD | NEW |