summaryrefslogtreecommitdiff
path: root/fxbarcode/pdf417
diff options
context:
space:
mode:
Diffstat (limited to 'fxbarcode/pdf417')
-rw-r--r--fxbarcode/pdf417/BC_PDF417Writer.cpp41
-rw-r--r--fxbarcode/pdf417/BC_PDF417Writer.h4
2 files changed, 15 insertions, 30 deletions
diff --git a/fxbarcode/pdf417/BC_PDF417Writer.cpp b/fxbarcode/pdf417/BC_PDF417Writer.cpp
index ca96f69926..5cf9037601 100644
--- a/fxbarcode/pdf417/BC_PDF417Writer.cpp
+++ b/fxbarcode/pdf417/BC_PDF417Writer.cpp
@@ -23,6 +23,7 @@
#include "fxbarcode/pdf417/BC_PDF417Writer.h"
#include <algorithm>
+#include <utility>
#include "fxbarcode/BC_TwoDimWriter.h"
#include "fxbarcode/common/BC_CommonBitArray.h"
@@ -49,8 +50,8 @@ void CBC_PDF417Writer::SetTruncated(bool truncated) {
}
uint8_t* CBC_PDF417Writer::Encode(const WideString& contents,
- int32_t& outWidth,
- int32_t& outHeight) {
+ int32_t* outWidth,
+ int32_t* outHeight) {
CBC_PDF417 encoder;
int32_t col = (m_Width / m_ModuleWidth - 69) / 17;
int32_t row = m_Height / (m_ModuleWidth * 20);
@@ -64,34 +65,18 @@ uint8_t* CBC_PDF417Writer::Encode(const WideString& contents,
return nullptr;
CBC_BarcodeMatrix* barcodeMatrix = encoder.getBarcodeMatrix();
- std::vector<uint8_t> originalScale = barcodeMatrix->getMatrix();
- int32_t width = outWidth;
- int32_t height = outHeight;
- outWidth = barcodeMatrix->getWidth();
- outHeight = barcodeMatrix->getHeight();
+ std::vector<uint8_t> matrixData = barcodeMatrix->getMatrix();
+ int32_t matrixWidth = barcodeMatrix->getWidth();
+ int32_t matrixHeight = barcodeMatrix->getHeight();
- bool rotated = false;
- if ((height > width) ^ (outWidth < outHeight)) {
- rotateArray(originalScale, outHeight, outWidth);
- rotated = true;
- int32_t temp = outHeight;
- outHeight = outWidth;
- outWidth = temp;
+ if (matrixWidth < matrixHeight) {
+ rotateArray(matrixData, matrixHeight, matrixWidth);
+ std::swap(matrixWidth, matrixHeight);
}
- int32_t scaleX = width / outWidth;
- int32_t scaleY = height / outHeight;
- int32_t scale = std::min(scaleX, scaleY);
- if (scale > 1) {
- originalScale = barcodeMatrix->getScaledMatrix(scale);
- if (rotated) {
- rotateArray(originalScale, outHeight, outWidth);
- int32_t temp = outHeight;
- outHeight = outWidth;
- outWidth = temp;
- }
- }
- uint8_t* result = FX_Alloc2D(uint8_t, outHeight, outWidth);
- memcpy(result, originalScale.data(), outHeight * outWidth);
+ uint8_t* result = FX_Alloc2D(uint8_t, matrixHeight, matrixWidth);
+ memcpy(result, matrixData.data(), matrixHeight * matrixWidth);
+ *outWidth = matrixWidth;
+ *outHeight = matrixHeight;
return result;
}
diff --git a/fxbarcode/pdf417/BC_PDF417Writer.h b/fxbarcode/pdf417/BC_PDF417Writer.h
index ef5961653e..1bb3a27d06 100644
--- a/fxbarcode/pdf417/BC_PDF417Writer.h
+++ b/fxbarcode/pdf417/BC_PDF417Writer.h
@@ -19,8 +19,8 @@ class CBC_PDF417Writer : public CBC_TwoDimWriter {
~CBC_PDF417Writer() override;
uint8_t* Encode(const WideString& contents,
- int32_t& outWidth,
- int32_t& outHeight);
+ int32_t* outWidth,
+ int32_t* outHeight);
// CBC_TwoDimWriter
bool SetErrorCorrectionLevel(int32_t level) override;