diff options
author | Lei Zhang <thestig@chromium.org> | 2017-04-20 15:58:56 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-04-21 00:54:04 +0000 |
commit | 1badb85e5c3a4b4cd42ca1a2b223d6b3bc67cc4a (patch) | |
tree | 55bf63857592387531797b0f08e0a6effc0f40c9 /fxbarcode/pdf417 | |
parent | aeee187c927c07f47a9e5886a417dcc58badefb6 (diff) | |
download | pdfium-1badb85e5c3a4b4cd42ca1a2b223d6b3bc67cc4a.tar.xz |
Change more fxbarcode to use return values.
Change-Id: Idcc05fb8c5a1448f552b4db5ae131ad82aef4d59
Reviewed-on: https://pdfium-review.googlesource.com/4258
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fxbarcode/pdf417')
-rw-r--r-- | fxbarcode/pdf417/BC_PDF417Writer.cpp | 26 | ||||
-rw-r--r-- | fxbarcode/pdf417/BC_PDF417Writer.h | 3 |
2 files changed, 14 insertions, 15 deletions
diff --git a/fxbarcode/pdf417/BC_PDF417Writer.cpp b/fxbarcode/pdf417/BC_PDF417Writer.cpp index 5344b8aecf..6f06321e82 100644 --- a/fxbarcode/pdf417/BC_PDF417Writer.cpp +++ b/fxbarcode/pdf417/BC_PDF417Writer.cpp @@ -20,13 +20,16 @@ * limitations under the License. */ +#include "fxbarcode/pdf417/BC_PDF417Writer.h" + +#include <algorithm> + #include "fxbarcode/BC_TwoDimWriter.h" #include "fxbarcode/common/BC_CommonBitArray.h" #include "fxbarcode/common/BC_CommonBitMatrix.h" #include "fxbarcode/pdf417/BC_PDF417.h" #include "fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h" #include "fxbarcode/pdf417/BC_PDF417Compaction.h" -#include "fxbarcode/pdf417/BC_PDF417Writer.h" CBC_PDF417Writer::CBC_PDF417Writer() { m_bFixedSize = false; @@ -44,23 +47,24 @@ bool CBC_PDF417Writer::SetErrorCorrectionLevel(int32_t level) { void CBC_PDF417Writer::SetTruncated(bool truncated) { m_bTruncated = truncated; } + uint8_t* CBC_PDF417Writer::Encode(const CFX_WideString& contents, int32_t& outWidth, - int32_t& outHeight, - int32_t& e) { + int32_t& outHeight) { CBC_PDF417 encoder; int32_t col = (m_Width / m_ModuleWidth - 69) / 17; int32_t row = m_Height / (m_ModuleWidth * 20); - if (row >= 3 && row <= 90 && col >= 1 && col <= 30) { + if (row >= 3 && row <= 90 && col >= 1 && col <= 30) encoder.setDimensions(col, col, row, row); - } else if (col >= 1 && col <= 30) { + else if (col >= 1 && col <= 30) encoder.setDimensions(col, col, 90, 3); - } else if (row >= 3 && row <= 90) { + else if (row >= 3 && row <= 90) encoder.setDimensions(30, 1, row, row); - } + int32_t e = BCExceptionNO; encoder.generateBarcodeLogic(contents, m_iCorrectLevel, e); if (e != BCExceptionNO) return nullptr; + int32_t lineThickness = 2; int32_t aspectRatio = 4; CBC_BarcodeMatrix* barcodeMatrix = encoder.getBarcodeMatrix(); @@ -80,12 +84,7 @@ uint8_t* CBC_PDF417Writer::Encode(const CFX_WideString& contents, } int32_t scaleX = width / outWidth; int32_t scaleY = height / outHeight; - int32_t scale; - if (scaleX < scaleY) { - scale = scaleX; - } else { - scale = scaleY; - } + int32_t scale = std::min(scaleX, scaleY); if (scale > 1) { originalScale = barcodeMatrix->getScaledMatrix( scale * lineThickness, scale * aspectRatio * lineThickness); @@ -100,6 +99,7 @@ uint8_t* CBC_PDF417Writer::Encode(const CFX_WideString& contents, memcpy(result, originalScale.data(), outHeight * outWidth); return result; } + void CBC_PDF417Writer::rotateArray(std::vector<uint8_t>& bitarray, int32_t height, int32_t width) { diff --git a/fxbarcode/pdf417/BC_PDF417Writer.h b/fxbarcode/pdf417/BC_PDF417Writer.h index ddfdc9be24..39418715ce 100644 --- a/fxbarcode/pdf417/BC_PDF417Writer.h +++ b/fxbarcode/pdf417/BC_PDF417Writer.h @@ -20,8 +20,7 @@ class CBC_PDF417Writer : public CBC_TwoDimWriter { uint8_t* Encode(const CFX_WideString& contents, int32_t& outWidth, - int32_t& outHeight, - int32_t& e); + int32_t& outHeight); // CBC_TwoDimWriter bool SetErrorCorrectionLevel(int32_t level) override; |