| 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 int32_t errorCorrectionLevel, | 403 int32_t errorCorrectionLevel, |
| 404 int32_t& e) { | 404 int32_t& e) { |
| 405 int32_t errorCorrectionCodeWords = | 405 int32_t errorCorrectionCodeWords = |
| 406 CBC_PDF417ErrorCorrection::getErrorCorrectionCodewordCount( | 406 CBC_PDF417ErrorCorrection::getErrorCorrectionCodewordCount( |
| 407 errorCorrectionLevel, e); | 407 errorCorrectionLevel, e); |
| 408 BC_EXCEPTION_CHECK_ReturnVoid(e); | 408 BC_EXCEPTION_CHECK_ReturnVoid(e); |
| 409 CFX_WideString highLevel = | 409 CFX_WideString highLevel = |
| 410 CBC_PDF417HighLevelEncoder::encodeHighLevel(msg, m_compaction, e); | 410 CBC_PDF417HighLevelEncoder::encodeHighLevel(msg, m_compaction, e); |
| 411 BC_EXCEPTION_CHECK_ReturnVoid(e); | 411 BC_EXCEPTION_CHECK_ReturnVoid(e); |
| 412 int32_t sourceCodeWords = highLevel.GetLength(); | 412 int32_t sourceCodeWords = highLevel.GetLength(); |
| 413 CFX_Int32Array* dimension = | 413 CFX_ArrayTemplate<int32_t>* dimension = |
| 414 determineDimensions(sourceCodeWords, errorCorrectionCodeWords, e); | 414 determineDimensions(sourceCodeWords, errorCorrectionCodeWords, e); |
| 415 BC_EXCEPTION_CHECK_ReturnVoid(e); | 415 BC_EXCEPTION_CHECK_ReturnVoid(e); |
| 416 int32_t cols = dimension->GetAt(0); | 416 int32_t cols = dimension->GetAt(0); |
| 417 int32_t rows = dimension->GetAt(1); | 417 int32_t rows = dimension->GetAt(1); |
| 418 delete dimension; | 418 delete dimension; |
| 419 int32_t pad = getNumberOfPadCodewords(sourceCodeWords, | 419 int32_t pad = getNumberOfPadCodewords(sourceCodeWords, |
| 420 errorCorrectionCodeWords, cols, rows); | 420 errorCorrectionCodeWords, cols, rows); |
| 421 if (sourceCodeWords + errorCorrectionCodeWords + 1 > 929) { | 421 if (sourceCodeWords + errorCorrectionCodeWords + 1 > 929) { |
| 422 e = BCExceptionEncodedMessageContainsTooManyCodeWords; | 422 e = BCExceptionEncodedMessageContainsTooManyCodeWords; |
| 423 return; | 423 return; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 if (m_compact) { | 525 if (m_compact) { |
| 526 encodeChar(STOP_PATTERN, 1, logic->getCurrentRow()); | 526 encodeChar(STOP_PATTERN, 1, logic->getCurrentRow()); |
| 527 } else { | 527 } else { |
| 528 pattern = CODEWORD_TABLE[cluster][right]; | 528 pattern = CODEWORD_TABLE[cluster][right]; |
| 529 encodeChar(pattern, 17, logic->getCurrentRow()); | 529 encodeChar(pattern, 17, logic->getCurrentRow()); |
| 530 encodeChar(STOP_PATTERN, 18, logic->getCurrentRow()); | 530 encodeChar(STOP_PATTERN, 18, logic->getCurrentRow()); |
| 531 } | 531 } |
| 532 } | 532 } |
| 533 } | 533 } |
| 534 | 534 |
| 535 CFX_Int32Array* CBC_PDF417::determineDimensions( | 535 CFX_ArrayTemplate<int32_t>* CBC_PDF417::determineDimensions( |
| 536 int32_t sourceCodeWords, | 536 int32_t sourceCodeWords, |
| 537 int32_t errorCorrectionCodeWords, | 537 int32_t errorCorrectionCodeWords, |
| 538 int32_t& e) { | 538 int32_t& e) { |
| 539 FX_FLOAT ratio = 0.0f; | 539 FX_FLOAT ratio = 0.0f; |
| 540 CFX_Int32Array* dimension = nullptr; | 540 CFX_ArrayTemplate<int32_t>* dimension = nullptr; |
| 541 for (int32_t cols = m_minCols; cols <= m_maxCols; cols++) { | 541 for (int32_t cols = m_minCols; cols <= m_maxCols; cols++) { |
| 542 int32_t rows = | 542 int32_t rows = |
| 543 calculateNumberOfRows(sourceCodeWords, errorCorrectionCodeWords, cols); | 543 calculateNumberOfRows(sourceCodeWords, errorCorrectionCodeWords, cols); |
| 544 if (rows < m_minRows) { | 544 if (rows < m_minRows) { |
| 545 break; | 545 break; |
| 546 } | 546 } |
| 547 if (rows > m_maxRows) { | 547 if (rows > m_maxRows) { |
| 548 continue; | 548 continue; |
| 549 } | 549 } |
| 550 FX_FLOAT newRatio = | 550 FX_FLOAT newRatio = |
| 551 ((17 * cols + 69) * DEFAULT_MODULE_WIDTH) / (rows * HEIGHT); | 551 ((17 * cols + 69) * DEFAULT_MODULE_WIDTH) / (rows * HEIGHT); |
| 552 if (dimension && | 552 if (dimension && |
| 553 fabsf(newRatio - PREFERRED_RATIO) > fabsf(ratio - PREFERRED_RATIO)) { | 553 fabsf(newRatio - PREFERRED_RATIO) > fabsf(ratio - PREFERRED_RATIO)) { |
| 554 continue; | 554 continue; |
| 555 } | 555 } |
| 556 ratio = newRatio; | 556 ratio = newRatio; |
| 557 delete dimension; | 557 delete dimension; |
| 558 dimension = new CFX_Int32Array; | 558 dimension = new CFX_ArrayTemplate<int32_t>; |
| 559 dimension->Add(cols); | 559 dimension->Add(cols); |
| 560 dimension->Add(rows); | 560 dimension->Add(rows); |
| 561 } | 561 } |
| 562 if (!dimension) { | 562 if (!dimension) { |
| 563 int32_t rows = calculateNumberOfRows(sourceCodeWords, | 563 int32_t rows = calculateNumberOfRows(sourceCodeWords, |
| 564 errorCorrectionCodeWords, m_minCols); | 564 errorCorrectionCodeWords, m_minCols); |
| 565 if (rows < m_minRows) { | 565 if (rows < m_minRows) { |
| 566 dimension = new CFX_Int32Array; | 566 dimension = new CFX_ArrayTemplate<int32_t>; |
| 567 dimension->Add(m_minCols); | 567 dimension->Add(m_minCols); |
| 568 dimension->Add(m_minRows); | 568 dimension->Add(m_minRows); |
| 569 } else if (rows >= 3 && rows <= 90) { | 569 } else if (rows >= 3 && rows <= 90) { |
| 570 dimension = new CFX_Int32Array; | 570 dimension = new CFX_ArrayTemplate<int32_t>; |
| 571 dimension->Add(m_minCols); | 571 dimension->Add(m_minCols); |
| 572 dimension->Add(rows); | 572 dimension->Add(rows); |
| 573 } | 573 } |
| 574 } | 574 } |
| 575 if (!dimension) { | 575 if (!dimension) { |
| 576 e = BCExceptionUnableToFitMessageInColumns; | 576 e = BCExceptionUnableToFitMessageInColumns; |
| 577 return nullptr; | 577 return nullptr; |
| 578 } | 578 } |
| 579 return dimension; | 579 return dimension; |
| 580 } | 580 } |
| OLD | NEW |