diff options
author | Henrique Nakashima <hnakashima@chromium.org> | 2018-08-16 15:47:56 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-08-16 15:47:56 +0000 |
commit | 2a3377ce9a39d47d29c95d5db64690ad749d8c94 (patch) | |
tree | fb5d0513bb9a115396083d84542e31c926172ace /fxbarcode/pdf417 | |
parent | 5f4cd74d2693e23b27237b935f28a87611e25e6b (diff) | |
download | pdfium-2a3377ce9a39d47d29c95d5db64690ad749d8c94.tar.xz |
Optimize rendering of two dimensional barcodes: deduplicate regions.
Reduce the logical size of the barcode by removing unnecessary
region duplication.
As far as I can tell, the line thickness is useless and the aspect
ratio causes arbitrary changes in rounding, but ultimately the
dimensions of a barcode are defined by its width and height, rather
than by this ratio.
The improvement with this CL is from ~580ms to ~390ms per barcode,
so about 1.5x. Combined with
https://pdfium-review.googlesource.com/c/pdfium/+/40010
the improvement is to ~15ms, which is about 39x.
This also fixes the rendering of the barcode in the pixel and
corpus tests. You can verify this pointing a barcode reader app at
the screen. It does not however fix every case, as the unit test is
still unreadable.
Bug: 872907, pdfium:1135
Change-Id: Ic28e60f54719552cfe69ace7ebc3f730c338a129
Reviewed-on: https://pdfium-review.googlesource.com/40030
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'fxbarcode/pdf417')
-rw-r--r-- | fxbarcode/pdf417/BC_PDF417Writer.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/fxbarcode/pdf417/BC_PDF417Writer.cpp b/fxbarcode/pdf417/BC_PDF417Writer.cpp index 4fec974737..026c89a59d 100644 --- a/fxbarcode/pdf417/BC_PDF417Writer.cpp +++ b/fxbarcode/pdf417/BC_PDF417Writer.cpp @@ -63,15 +63,13 @@ uint8_t* CBC_PDF417Writer::Encode(const WideString& contents, if (!encoder.generateBarcodeLogic(contents, m_iCorrectLevel)) return nullptr; - int32_t lineThickness = 2; - int32_t aspectRatio = 4; CBC_BarcodeMatrix* barcodeMatrix = encoder.getBarcodeMatrix(); - std::vector<uint8_t> originalScale = barcodeMatrix->getScaledMatrix( - lineThickness, aspectRatio * lineThickness); + std::vector<uint8_t> originalScale = barcodeMatrix->getMatrix(); int32_t width = outWidth; int32_t height = outHeight; outWidth = barcodeMatrix->getWidth(); outHeight = barcodeMatrix->getHeight(); + bool rotated = false; if ((height > width) ^ (outWidth < outHeight)) { rotateArray(originalScale, outHeight, outWidth); @@ -84,8 +82,7 @@ uint8_t* CBC_PDF417Writer::Encode(const WideString& contents, int32_t scaleY = height / outHeight; int32_t scale = std::min(scaleX, scaleY); if (scale > 1) { - originalScale = barcodeMatrix->getScaledMatrix( - scale * lineThickness, scale * aspectRatio * lineThickness); + originalScale = barcodeMatrix->getScaledMatrix(scale); if (rotated) { rotateArray(originalScale, outHeight, outWidth); int32_t temp = outHeight; |