Chromium Code Reviews| Index: xfa/src/fxbarcode/BC_TwoDimWriter.cpp |
| diff --git a/xfa/src/fxbarcode/BC_TwoDimWriter.cpp b/xfa/src/fxbarcode/BC_TwoDimWriter.cpp |
| index d6d66144496022295876c36d7cfa32bb3845bcd9..b8d421b68a9c3e38f53f265cd69df1ae7ab53ca2 100644 |
| --- a/xfa/src/fxbarcode/BC_TwoDimWriter.cpp |
| +++ b/xfa/src/fxbarcode/BC_TwoDimWriter.cpp |
| @@ -4,6 +4,8 @@ |
| // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| +#include <algorithm> |
| + |
| #include "xfa/src/fxbarcode/barcode.h" |
| #include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" |
| #include "xfa/src/fxbarcode/BC_Writer.h" |
| @@ -92,16 +94,15 @@ void CBC_TwoDimWriter::RenderResult(uint8_t* code, |
| int32_t& e) { |
| int32_t inputWidth = codeWidth; |
| int32_t inputHeight = codeHeight; |
| - int32_t tempWidth = inputWidth + (1 << 1); |
| - int32_t tempHeight = inputHeight + (1 << 1); |
| - FX_FLOAT moduleHSize = (FX_FLOAT)FX_MIN(m_ModuleWidth, m_ModuleHeight); |
| - if (moduleHSize > 8) { |
| - moduleHSize = 8; |
| - } else if (moduleHSize < 1) { |
| - moduleHSize = 1; |
| - } |
| - int32_t outputWidth = (int32_t)FX_MAX(tempWidth * moduleHSize, tempWidth); |
| - int32_t outputHeight = (int32_t)FX_MAX(tempHeight * moduleHSize, tempHeight); |
| + int32_t tempWidth = inputWidth + 2; |
| + int32_t tempHeight = inputHeight + 2; |
| + FX_FLOAT moduleHSize = std::min(m_ModuleWidth, m_ModuleHeight); |
| + moduleHSize = std::min(moduleHSize, 8.0f); |
| + moduleHSize = std::max(moduleHSize, 1.0f); |
| + int32_t outputWidth = static_cast<int32_t>( |
| + std::max(static_cast<int32_t>(tempWidth * moduleHSize), tempWidth)); |
|
Tom Sepez
2016/01/09 00:35:52
This code is troubling. moduleHSize is constrained
|
| + int32_t outputHeight = static_cast<int32_t>( |
| + std::max(static_cast<int32_t>(tempHeight * moduleHSize), tempHeight)); |
|
Tom Sepez
2016/01/09 00:35:52
in any event, I don't think the outer cast is requ
|
| int32_t multiX = 1; |
| int32_t multiY = 1; |
| if (m_bFixedSize) { |
| @@ -120,7 +121,7 @@ void CBC_TwoDimWriter::RenderResult(uint8_t* code, |
| multiX = (int32_t)ceil((FX_FLOAT)outputWidth / (FX_FLOAT)tempWidth); |
| multiY = (int32_t)ceil((FX_FLOAT)outputHeight / (FX_FLOAT)tempHeight); |
| if (m_bFixedSize) { |
| - multiX = FX_MIN(multiX, multiY); |
| + multiX = std::min(multiX, multiY); |
| multiY = multiX; |
| } |
| int32_t leftPadding = (outputWidth - (inputWidth * multiX)) / 2; |