From 080dfd89269a95713d31d66829016d4885afe76b Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Sun, 16 Apr 2017 01:30:59 -0700 Subject: Remove dead barcode bitmap rendering code. Change-Id: Idb5ef2aed456e84e0781c374b211560ab7d4fa3d Reviewed-on: https://pdfium-review.googlesource.com/4257 Reviewed-by: Tom Sepez Commit-Queue: Lei Zhang --- fxbarcode/BC_TwoDimWriter.cpp | 30 -------- fxbarcode/BC_TwoDimWriter.h | 2 - fxbarcode/cbc_codabar.cpp | 12 ---- fxbarcode/cbc_codabar.h | 2 - fxbarcode/cbc_code128.cpp | 7 -- fxbarcode/cbc_code128.h | 2 - fxbarcode/cbc_code39.cpp | 10 --- fxbarcode/cbc_code39.h | 2 - fxbarcode/cbc_codebase.h | 2 - fxbarcode/cbc_datamatrix.cpp | 7 -- fxbarcode/cbc_datamatrix.h | 2 - fxbarcode/cbc_ean13.cpp | 7 -- fxbarcode/cbc_ean13.h | 2 - fxbarcode/cbc_ean8.cpp | 7 -- fxbarcode/cbc_ean8.h | 2 - fxbarcode/cbc_pdf417i.cpp | 7 -- fxbarcode/cbc_pdf417i.h | 2 - fxbarcode/cbc_qrcode.cpp | 6 -- fxbarcode/cbc_qrcode.h | 2 - fxbarcode/cbc_upca.cpp | 7 -- fxbarcode/cbc_upca.h | 2 - fxbarcode/oned/BC_OneDimWriter.cpp | 73 ++----------------- fxbarcode/oned/BC_OneDimWriter.h | 11 --- fxbarcode/oned/BC_OnedEAN13Writer.cpp | 104 +++++++++------------------ fxbarcode/oned/BC_OnedEAN13Writer.h | 1 - fxbarcode/oned/BC_OnedEAN8Writer.cpp | 66 ++++++----------- fxbarcode/oned/BC_OnedEAN8Writer.h | 1 - fxbarcode/oned/BC_OnedUPCAWriter.cpp | 132 ++++++++++++---------------------- fxbarcode/oned/BC_OnedUPCAWriter.h | 1 - 29 files changed, 105 insertions(+), 406 deletions(-) diff --git a/fxbarcode/BC_TwoDimWriter.cpp b/fxbarcode/BC_TwoDimWriter.cpp index 8043244b2b..9906f35bd5 100644 --- a/fxbarcode/BC_TwoDimWriter.cpp +++ b/fxbarcode/BC_TwoDimWriter.cpp @@ -57,36 +57,6 @@ int32_t CBC_TwoDimWriter::GetErrorCorrectionLevel() const { return m_iCorrectLevel; } -void CBC_TwoDimWriter::RenderBitmapResult( - CFX_RetainPtr& pOutBitmap, - int32_t& e) { - if (m_bFixedSize) { - pOutBitmap = CreateDIBitmap(m_Width, m_Height); - } else { - pOutBitmap = CreateDIBitmap(m_output->GetWidth(), m_output->GetHeight()); - } - if (!pOutBitmap) { - e = BCExceptionFailToCreateBitmap; - return; - } - pOutBitmap->Clear(m_backgroundColor); - int32_t leftPos = 0; - int32_t topPos = 0; - if (m_bFixedSize) { - leftPos = (m_Width - m_output->GetWidth()) / 2; - topPos = (m_Height - m_output->GetHeight()) / 2; - } - for (int32_t x = 0; x < m_output->GetWidth(); x++) { - for (int32_t y = 0; y < m_output->GetHeight(); y++) { - if (m_output->Get(x, y)) { - pOutBitmap->SetPixel(leftPos + x, topPos + y, m_barColor); - } - } - } - if (!m_bFixedSize) - pOutBitmap = pOutBitmap->StretchTo(m_Width, m_Height); -} - void CBC_TwoDimWriter::RenderResult(uint8_t* code, int32_t codeWidth, int32_t codeHeight, diff --git a/fxbarcode/BC_TwoDimWriter.h b/fxbarcode/BC_TwoDimWriter.h index f77546ee07..f7d02de2b1 100644 --- a/fxbarcode/BC_TwoDimWriter.h +++ b/fxbarcode/BC_TwoDimWriter.h @@ -24,8 +24,6 @@ class CBC_TwoDimWriter : public CBC_Writer { int32_t codeWidth, int32_t codeHeight, int32_t& e); - virtual void RenderBitmapResult(CFX_RetainPtr& pOutBitmap, - int32_t& e); virtual void RenderDeviceResult(CFX_RenderDevice* device, const CFX_Matrix* matrix); virtual bool SetErrorCorrectionLevel(int32_t level) = 0; diff --git a/fxbarcode/cbc_codabar.cpp b/fxbarcode/cbc_codabar.cpp index 4072f32712..c10491707f 100644 --- a/fxbarcode/cbc_codabar.cpp +++ b/fxbarcode/cbc_codabar.cpp @@ -93,18 +93,6 @@ bool CBC_Codabar::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_Codabar::RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) { - CFX_WideString renderCon = - static_cast(m_pBCWriter.get()) - ->encodedContents(m_renderContents.AsStringC()); - static_cast(m_pBCWriter.get()) - ->RenderBitmapResult(pOutBitmap, renderCon.AsStringC(), e); - if (e != BCExceptionNO) - return false; - return true; -} - BC_TYPE CBC_Codabar::GetType() { return BC_CODABAR; } diff --git a/fxbarcode/cbc_codabar.h b/fxbarcode/cbc_codabar.h index 64b7ae8f45..253a7aaaf1 100644 --- a/fxbarcode/cbc_codabar.h +++ b/fxbarcode/cbc_codabar.h @@ -24,8 +24,6 @@ class CBC_Codabar : public CBC_OneCode { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) override; BC_TYPE GetType() override; bool SetStartChar(char start); diff --git a/fxbarcode/cbc_code128.cpp b/fxbarcode/cbc_code128.cpp index 91d53d462b..5a4f556513 100644 --- a/fxbarcode/cbc_code128.cpp +++ b/fxbarcode/cbc_code128.cpp @@ -78,13 +78,6 @@ bool CBC_Code128::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_Code128::RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) { - static_cast(m_pBCWriter.get()) - ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e); - return e == BCExceptionNO; -} - BC_TYPE CBC_Code128::GetType() { return BC_CODE128; } diff --git a/fxbarcode/cbc_code128.h b/fxbarcode/cbc_code128.h index 6cd6ac56aa..4bff4a7aa4 100644 --- a/fxbarcode/cbc_code128.h +++ b/fxbarcode/cbc_code128.h @@ -24,8 +24,6 @@ class CBC_Code128 : public CBC_OneCode { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) override; BC_TYPE GetType() override; bool SetTextLocation(BC_TEXT_LOC loction); diff --git a/fxbarcode/cbc_code39.cpp b/fxbarcode/cbc_code39.cpp index 58e78daadd..94b7602974 100644 --- a/fxbarcode/cbc_code39.cpp +++ b/fxbarcode/cbc_code39.cpp @@ -70,16 +70,6 @@ bool CBC_Code39::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_Code39::RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) { - CFX_WideString renderCon = - static_cast(m_pBCWriter.get()) - ->encodedContents(m_renderContents.AsStringC(), e); - static_cast(m_pBCWriter.get()) - ->RenderBitmapResult(pOutBitmap, renderCon.AsStringC(), e); - return e == BCExceptionNO; -} - BC_TYPE CBC_Code39::GetType() { return BC_CODE39; } diff --git a/fxbarcode/cbc_code39.h b/fxbarcode/cbc_code39.h index a83a7b77e6..f1e6acc848 100644 --- a/fxbarcode/cbc_code39.h +++ b/fxbarcode/cbc_code39.h @@ -25,8 +25,6 @@ class CBC_Code39 : public CBC_OneCode { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) override; BC_TYPE GetType() override; bool SetTextLocation(BC_TEXT_LOC location); diff --git a/fxbarcode/cbc_codebase.h b/fxbarcode/cbc_codebase.h index 559f64e4f1..370ff2c723 100644 --- a/fxbarcode/cbc_codebase.h +++ b/fxbarcode/cbc_codebase.h @@ -31,8 +31,6 @@ class CBC_CodeBase { virtual bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) = 0; - virtual bool RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) = 0; bool SetCharEncoding(int32_t encoding); bool SetModuleHeight(int32_t moduleHeight); diff --git a/fxbarcode/cbc_datamatrix.cpp b/fxbarcode/cbc_datamatrix.cpp index ea12315102..3c6f638614 100644 --- a/fxbarcode/cbc_datamatrix.cpp +++ b/fxbarcode/cbc_datamatrix.cpp @@ -53,13 +53,6 @@ bool CBC_DataMatrix::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_DataMatrix::RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) { - static_cast(m_pBCWriter.get()) - ->RenderBitmapResult(pOutBitmap, e); - return e == BCExceptionNO; -} - BC_TYPE CBC_DataMatrix::GetType() { return BC_DATAMATRIX; } diff --git a/fxbarcode/cbc_datamatrix.h b/fxbarcode/cbc_datamatrix.h index b03467974a..0bd8063bcf 100644 --- a/fxbarcode/cbc_datamatrix.h +++ b/fxbarcode/cbc_datamatrix.h @@ -25,8 +25,6 @@ class CBC_DataMatrix : public CBC_CodeBase { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) override; BC_TYPE GetType() override; }; diff --git a/fxbarcode/cbc_ean13.cpp b/fxbarcode/cbc_ean13.cpp index 0366e03523..0ac7fdbe6e 100644 --- a/fxbarcode/cbc_ean13.cpp +++ b/fxbarcode/cbc_ean13.cpp @@ -83,13 +83,6 @@ bool CBC_EAN13::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_EAN13::RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) { - static_cast(m_pBCWriter.get()) - ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e); - return e == BCExceptionNO; -} - BC_TYPE CBC_EAN13::GetType() { return BC_EAN13; } diff --git a/fxbarcode/cbc_ean13.h b/fxbarcode/cbc_ean13.h index 105ded27c7..86e5ea207a 100644 --- a/fxbarcode/cbc_ean13.h +++ b/fxbarcode/cbc_ean13.h @@ -25,8 +25,6 @@ class CBC_EAN13 : public CBC_OneCode { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) override; BC_TYPE GetType() override; private: diff --git a/fxbarcode/cbc_ean8.cpp b/fxbarcode/cbc_ean8.cpp index 0ba9b20904..f267dbe22d 100644 --- a/fxbarcode/cbc_ean8.cpp +++ b/fxbarcode/cbc_ean8.cpp @@ -82,13 +82,6 @@ bool CBC_EAN8::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_EAN8::RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) { - static_cast(m_pBCWriter.get()) - ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e); - return e == BCExceptionNO; -} - BC_TYPE CBC_EAN8::GetType() { return BC_EAN8; } diff --git a/fxbarcode/cbc_ean8.h b/fxbarcode/cbc_ean8.h index 16480ef298..7ddd2dea8b 100644 --- a/fxbarcode/cbc_ean8.h +++ b/fxbarcode/cbc_ean8.h @@ -24,8 +24,6 @@ class CBC_EAN8 : public CBC_OneCode { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) override; BC_TYPE GetType() override; private: diff --git a/fxbarcode/cbc_pdf417i.cpp b/fxbarcode/cbc_pdf417i.cpp index 6a79aa3f57..5536c307c7 100644 --- a/fxbarcode/cbc_pdf417i.cpp +++ b/fxbarcode/cbc_pdf417i.cpp @@ -63,13 +63,6 @@ bool CBC_PDF417I::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_PDF417I::RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) { - static_cast(m_pBCWriter.get()) - ->RenderBitmapResult(pOutBitmap, e); - return e == BCExceptionNO; -} - BC_TYPE CBC_PDF417I::GetType() { return BC_PDF417; } diff --git a/fxbarcode/cbc_pdf417i.h b/fxbarcode/cbc_pdf417i.h index da1c88d3f2..957154d888 100644 --- a/fxbarcode/cbc_pdf417i.h +++ b/fxbarcode/cbc_pdf417i.h @@ -24,8 +24,6 @@ class CBC_PDF417I : public CBC_CodeBase { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) override; BC_TYPE GetType() override; bool SetErrorCorrectionLevel(int32_t level); diff --git a/fxbarcode/cbc_qrcode.cpp b/fxbarcode/cbc_qrcode.cpp index 0e0191dc3e..3da35b2c7b 100644 --- a/fxbarcode/cbc_qrcode.cpp +++ b/fxbarcode/cbc_qrcode.cpp @@ -57,12 +57,6 @@ bool CBC_QRCode::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_QRCode::RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) { - writer()->RenderBitmapResult(pOutBitmap, e); - return e == BCExceptionNO; -} - BC_TYPE CBC_QRCode::GetType() { return BC_QR_CODE; } diff --git a/fxbarcode/cbc_qrcode.h b/fxbarcode/cbc_qrcode.h index d8d871203d..c3388d17f4 100644 --- a/fxbarcode/cbc_qrcode.h +++ b/fxbarcode/cbc_qrcode.h @@ -26,8 +26,6 @@ class CBC_QRCode : public CBC_CodeBase { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) override; BC_TYPE GetType() override; bool SetErrorCorrectionLevel(int32_t level); diff --git a/fxbarcode/cbc_upca.cpp b/fxbarcode/cbc_upca.cpp index 6c8e821a10..98e71615c2 100644 --- a/fxbarcode/cbc_upca.cpp +++ b/fxbarcode/cbc_upca.cpp @@ -86,13 +86,6 @@ bool CBC_UPCA::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_UPCA::RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) { - static_cast(m_pBCWriter.get()) - ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e); - return e == BCExceptionNO; -} - BC_TYPE CBC_UPCA::GetType() { return BC_UPCA; } diff --git a/fxbarcode/cbc_upca.h b/fxbarcode/cbc_upca.h index e27596ca9a..221c1d4242 100644 --- a/fxbarcode/cbc_upca.h +++ b/fxbarcode/cbc_upca.h @@ -24,8 +24,6 @@ class CBC_UPCA : public CBC_OneCode { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) override; BC_TYPE GetType() override; private: diff --git a/fxbarcode/oned/BC_OneDimWriter.cpp b/fxbarcode/oned/BC_OneDimWriter.cpp index f6b33f37a9..57b6c22a93 100644 --- a/fxbarcode/oned/BC_OneDimWriter.cpp +++ b/fxbarcode/oned/BC_OneDimWriter.cpp @@ -223,38 +223,13 @@ void CBC_OneDimWriter::ShowDeviceChars(CFX_RenderDevice* device, m_fontColor, FXTEXT_CLEARTYPE); } -void CBC_OneDimWriter::ShowBitmapChars( - const CFX_RetainPtr& pOutBitmap, - const CFX_ByteString str, - float geWidth, - FXTEXT_CHARPOS* pCharPos, - float locX, - float locY, - int32_t barWidth) { - int32_t iFontSize = (int32_t)fabs(m_fFontSize); - int32_t iTextHeight = iFontSize + 1; - CFX_FxgeDevice ge; - ge.Create((int)geWidth, iTextHeight, m_colorSpace, nullptr); - FX_RECT geRect(0, 0, (int)geWidth, iTextHeight); - ge.FillRect(&geRect, m_backgroundColor); - CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, - static_cast(iFontSize)); - ge.DrawNormalText(str.GetLength(), pCharPos, m_pFont, - static_cast(iFontSize), &affine_matrix, m_fontColor, - FXTEXT_CLEARTYPE); - CFX_FxgeDevice geBitmap; - geBitmap.Attach(pOutBitmap, false, nullptr, false); - geBitmap.SetDIBits(ge.GetBitmap(), (int)locX, (int)locY); -} - void CBC_OneDimWriter::ShowChars(const CFX_WideStringC& contents, - const CFX_RetainPtr& pOutBitmap, CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t barWidth, int32_t multiple, int32_t& e) { - if (!device && !pOutBitmap) { + if (!device) { e = BCExceptionIllegalArgument; return; } @@ -306,51 +281,11 @@ void CBC_OneDimWriter::ShowChars(const CFX_WideStringC& contents, geWidth = (float)barWidth; break; } - if (device) { - ShowDeviceChars(device, matrix, str, geWidth, pCharPos, (float)locX, - (float)locY, barWidth); - } else { - ShowBitmapChars(pOutBitmap, str, geWidth, pCharPos, (float)locX, - (float)locY, barWidth); - } + ShowDeviceChars(device, matrix, str, geWidth, pCharPos, (float)locX, + (float)locY, barWidth); FX_Free(pCharPos); } -void CBC_OneDimWriter::RenderBitmapResult( - CFX_RetainPtr& pOutBitmap, - const CFX_WideStringC& contents, - int32_t& e) { - if (!m_output) - if (e != BCExceptionNO) - return; - - pOutBitmap = CreateDIBitmap(m_output->GetWidth(), m_output->GetHeight()); - pOutBitmap->Clear(m_backgroundColor); - if (!pOutBitmap) { - e = BCExceptionFailToCreateBitmap; - return; - } - for (int32_t x = 0; x < m_output->GetWidth(); x++) { - for (int32_t y = 0; y < m_output->GetHeight(); y++) { - if (m_output->Get(x, y)) { - pOutBitmap->SetPixel(x, y, m_barColor); - } - } - } - int32_t i = 0; - for (; i < contents.GetLength(); i++) { - if (contents.GetAt(i) != ' ') - break; - } - if (m_locTextLoc != BC_TEXT_LOC_NONE && i < contents.GetLength()) { - ShowChars(contents, pOutBitmap, nullptr, nullptr, m_barWidth, m_multiple, - e); - if (e != BCExceptionNO) - return; - } - pOutBitmap = pOutBitmap->StretchTo(m_Width, m_Height); -} - void CBC_OneDimWriter::RenderDeviceResult(CFX_RenderDevice* device, const CFX_Matrix* matrix, const CFX_WideStringC& contents, @@ -382,7 +317,7 @@ void CBC_OneDimWriter::RenderDeviceResult(CFX_RenderDevice* device, break; } if (m_locTextLoc != BC_TEXT_LOC_NONE && i < contents.GetLength()) { - ShowChars(contents, nullptr, device, matrix, m_barWidth, m_multiple, e); + ShowChars(contents, device, matrix, m_barWidth, m_multiple, e); if (e != BCExceptionNO) return; } diff --git a/fxbarcode/oned/BC_OneDimWriter.h b/fxbarcode/oned/BC_OneDimWriter.h index 11a1ed4fdf..15ae8e7bc8 100644 --- a/fxbarcode/oned/BC_OneDimWriter.h +++ b/fxbarcode/oned/BC_OneDimWriter.h @@ -42,9 +42,6 @@ class CBC_OneDimWriter : public CBC_Writer { int32_t codeLength, bool isDevice, int32_t& e); - virtual void RenderBitmapResult(CFX_RetainPtr& pOutBitmap, - const CFX_WideStringC& contents, - int32_t& e); virtual void RenderDeviceResult(CFX_RenderDevice* device, const CFX_Matrix* matrix, const CFX_WideStringC& contents, @@ -68,19 +65,11 @@ class CBC_OneDimWriter : public CBC_Writer { int32_t fontSize, float& charsLen); virtual void ShowChars(const CFX_WideStringC& contents, - const CFX_RetainPtr& pOutBitmap, CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t barWidth, int32_t multiple, int32_t& e); - virtual void ShowBitmapChars(const CFX_RetainPtr& pOutBitmap, - const CFX_ByteString str, - float geWidth, - FXTEXT_CHARPOS* pCharPos, - float locX, - float locY, - int32_t barWidth); virtual void ShowDeviceChars(CFX_RenderDevice* device, const CFX_Matrix* matrix, const CFX_ByteString str, diff --git a/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/fxbarcode/oned/BC_OnedEAN13Writer.cpp index 21b0f9a63f..a11938a4d9 100644 --- a/fxbarcode/oned/BC_OnedEAN13Writer.cpp +++ b/fxbarcode/oned/BC_OnedEAN13Writer.cpp @@ -169,13 +169,12 @@ uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents, void CBC_OnedEAN13Writer::ShowChars( const CFX_WideStringC& contents, - const CFX_RetainPtr& pOutBitmap, CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t barWidth, int32_t multiple, int32_t& e) { - if (!device && !pOutBitmap) { + if (!device) { e = BCExceptionIllegalArgument; return; } @@ -185,64 +184,48 @@ void CBC_OnedEAN13Writer::ShowChars( int32_t iLen = str.GetLength(); FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen); memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen); - CFX_FxgeDevice geBitmap; - if (pOutBitmap) - geBitmap.Attach(pOutBitmap, false, nullptr, false); int32_t iFontSize = (int32_t)fabs(m_fFontSize); int32_t iTextHeight = iFontSize + 1; CFX_ByteString tempStr = str.Mid(1, 6); int32_t strWidth = multiple * 42; - if (!pOutBitmap) { - CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); - CFX_FloatRect rect((float)leftPosition, (float)(m_Height - iTextHeight), - (float)(leftPosition + strWidth - 0.5), (float)m_Height); - matr.Concat(*matrix); - matr.TransformRect(rect); - FX_RECT re = rect.GetOuterRect(); - device->FillRect(&re, m_backgroundColor); - CFX_FloatRect rect1((float)(leftPosition + 47 * multiple), - (float)(m_Height - iTextHeight), - (float)(leftPosition + 47 * multiple + strWidth - 0.5), - (float)m_Height); - CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); - matr1.Concat(*matrix); - matr1.TransformRect(rect1); - re = rect1.GetOuterRect(); - device->FillRect(&re, m_backgroundColor); - int32_t strWidth1 = multiple * 7; - CFX_Matrix matr2(m_outputHScale, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f); - CFX_FloatRect rect2(0.0f, (float)(m_Height - iTextHeight), - (float)strWidth1 - 0.5f, (float)m_Height); - matr2.Concat(*matrix); - matr2.TransformRect(rect2); - re = rect2.GetOuterRect(); - device->FillRect(&re, m_backgroundColor); - } + + CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); + CFX_FloatRect rect((float)leftPosition, (float)(m_Height - iTextHeight), + (float)(leftPosition + strWidth - 0.5), (float)m_Height); + matr.Concat(*matrix); + matr.TransformRect(rect); + FX_RECT re = rect.GetOuterRect(); + device->FillRect(&re, m_backgroundColor); + CFX_FloatRect rect1( + (float)(leftPosition + 47 * multiple), (float)(m_Height - iTextHeight), + (float)(leftPosition + 47 * multiple + strWidth - 0.5), (float)m_Height); + CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); + matr1.Concat(*matrix); + matr1.TransformRect(rect1); + re = rect1.GetOuterRect(); + device->FillRect(&re, m_backgroundColor); + int32_t strWidth1 = multiple * 7; + CFX_Matrix matr2(m_outputHScale, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f); + CFX_FloatRect rect2(0.0f, (float)(m_Height - iTextHeight), + (float)strWidth1 - 0.5f, (float)m_Height); + matr2.Concat(*matrix); + matr2.TransformRect(rect2); + re = rect2.GetOuterRect(); + device->FillRect(&re, m_backgroundColor); + float blank = 0.0; iLen = tempStr.GetLength(); - if (!pOutBitmap) { - strWidth = (int32_t)(strWidth * m_outputHScale); - } + strWidth = (int32_t)(strWidth * m_outputHScale); + CalcTextInfo(tempStr, pCharPos + 1, m_pFont, (float)strWidth, iFontSize, blank); - CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (float)iFontSize); - CFX_FxgeDevice ge; - if (pOutBitmap) { - ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr); - FX_RECT rect(0, 0, strWidth, iTextHeight); - ge.FillRect(&rect, m_backgroundColor); - ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, - static_cast(iFontSize), &affine_matrix, - m_fontColor, FXTEXT_CLEARTYPE); - geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); - } else { + { CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, (float)leftPosition * m_outputHScale, (float)(m_Height - iTextHeight) + iFontSize); - if (matrix) { + if (matrix) affine_matrix1.Concat(*matrix); - } device->DrawNormalText(iLen, pCharPos + 1, m_pFont, static_cast(iFontSize), &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); @@ -251,22 +234,13 @@ void CBC_OnedEAN13Writer::ShowChars( iLen = tempStr.GetLength(); CalcTextInfo(tempStr, pCharPos + 7, m_pFont, (float)strWidth, iFontSize, blank); - if (pOutBitmap) { - FX_RECT rect1(0, 0, strWidth, iTextHeight); - ge.FillRect(&rect1, m_backgroundColor); - ge.DrawNormalText(iLen, pCharPos + 7, m_pFont, - static_cast(iFontSize), &affine_matrix, - m_fontColor, FXTEXT_CLEARTYPE); - geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 47 * multiple, - m_Height - iTextHeight); - } else { + { CFX_Matrix affine_matrix1( 1.0, 0.0, 0.0, -1.0, (float)(leftPosition + 47 * multiple) * m_outputHScale, (float)(m_Height - iTextHeight + iFontSize)); - if (matrix) { + if (matrix) affine_matrix1.Concat(*matrix); - } device->DrawNormalText(iLen, pCharPos + 7, m_pFont, static_cast(iFontSize), &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); @@ -274,22 +248,14 @@ void CBC_OnedEAN13Writer::ShowChars( tempStr = str.Mid(0, 1); iLen = tempStr.GetLength(); strWidth = multiple * 7; - if (!pOutBitmap) - strWidth = (int32_t)(strWidth * m_outputHScale); + strWidth = (int32_t)(strWidth * m_outputHScale); CalcTextInfo(tempStr, pCharPos, m_pFont, (float)strWidth, iFontSize, blank); - if (pOutBitmap) { - ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr); - ge.GetBitmap()->Clear(m_backgroundColor); - ge.DrawNormalText(iLen, pCharPos, m_pFont, static_cast(iFontSize), - &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); - geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight); - } else { + { CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0.0, (float)(m_Height - iTextHeight + iFontSize)); - if (matrix) { + if (matrix) affine_matrix1.Concat(*matrix); - } device->DrawNormalText(iLen, pCharPos, m_pFont, static_cast(iFontSize), &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); diff --git a/fxbarcode/oned/BC_OnedEAN13Writer.h b/fxbarcode/oned/BC_OnedEAN13Writer.h index 1e99159132..377d18a916 100644 --- a/fxbarcode/oned/BC_OnedEAN13Writer.h +++ b/fxbarcode/oned/BC_OnedEAN13Writer.h @@ -46,7 +46,6 @@ class CBC_OnedEAN13Writer : public CBC_OneDimWriter { protected: void ShowChars(const CFX_WideStringC& contents, - const CFX_RetainPtr& pOutBitmap, CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t barWidth, diff --git a/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/fxbarcode/oned/BC_OnedEAN8Writer.cpp index 5aea9f3c89..5ebc699c2c 100644 --- a/fxbarcode/oned/BC_OnedEAN8Writer.cpp +++ b/fxbarcode/oned/BC_OnedEAN8Writer.cpp @@ -167,13 +167,12 @@ uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, void CBC_OnedEAN8Writer::ShowChars( const CFX_WideStringC& contents, - const CFX_RetainPtr& pOutBitmap, CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t barWidth, int32_t multiple, int32_t& e) { - if (!device && !pOutBitmap) { + if (!device) { e = BCExceptionIllegalArgument; return; } @@ -187,43 +186,29 @@ void CBC_OnedEAN8Writer::ShowChars( int32_t iLen = tempStr.GetLength(); int32_t strWidth = 7 * multiple * 4; float blank = 0.0; - CFX_FxgeDevice geBitmap; - if (pOutBitmap) - geBitmap.Attach(pOutBitmap, false, nullptr, false); int32_t iFontSize = (int32_t)fabs(m_fFontSize); int32_t iTextHeight = iFontSize + 1; - if (!pOutBitmap) { - CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); - CFX_FloatRect rect((float)leftPosition, (float)(m_Height - iTextHeight), - (float)(leftPosition + strWidth - 0.5), (float)m_Height); - matr.Concat(*matrix); - matr.TransformRect(rect); - FX_RECT re = rect.GetOuterRect(); - device->FillRect(&re, m_backgroundColor); - CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); - CFX_FloatRect rect1((float)(leftPosition + 33 * multiple), - (float)(m_Height - iTextHeight), - (float)(leftPosition + 33 * multiple + strWidth - 0.5), - (float)m_Height); - matr1.Concat(*matrix); - matr1.TransformRect(rect1); - re = rect1.GetOuterRect(); - device->FillRect(&re, m_backgroundColor); - } - if (!pOutBitmap) - strWidth = (int32_t)(strWidth * m_outputHScale); + + CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); + CFX_FloatRect rect((float)leftPosition, (float)(m_Height - iTextHeight), + (float)(leftPosition + strWidth - 0.5), (float)m_Height); + matr.Concat(*matrix); + matr.TransformRect(rect); + FX_RECT re = rect.GetOuterRect(); + device->FillRect(&re, m_backgroundColor); + CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); + CFX_FloatRect rect1( + (float)(leftPosition + 33 * multiple), (float)(m_Height - iTextHeight), + (float)(leftPosition + 33 * multiple + strWidth - 0.5), (float)m_Height); + matr1.Concat(*matrix); + matr1.TransformRect(rect1); + re = rect1.GetOuterRect(); + device->FillRect(&re, m_backgroundColor); + strWidth = (int32_t)(strWidth * m_outputHScale); CalcTextInfo(tempStr, pCharPos, m_pFont, (float)strWidth, iFontSize, blank); - CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (float)iFontSize); - CFX_FxgeDevice ge; - if (pOutBitmap) { - ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr); - ge.GetBitmap()->Clear(m_backgroundColor); - ge.DrawNormalText(iLen, pCharPos, m_pFont, static_cast(iFontSize), - &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); - geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); - } else { + { CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, (float)leftPosition * m_outputHScale, (float)(m_Height - iTextHeight + iFontSize)); @@ -236,22 +221,13 @@ void CBC_OnedEAN8Writer::ShowChars( iLen = tempStr.GetLength(); CalcTextInfo(tempStr, pCharPos + 4, m_pFont, (float)strWidth, iFontSize, blank); - if (pOutBitmap) { - ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr); - ge.GetBitmap()->Clear(m_backgroundColor); - ge.DrawNormalText(iLen, pCharPos + 4, m_pFont, - static_cast(iFontSize), &affine_matrix, - m_fontColor, FXTEXT_CLEARTYPE); - geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 33 * multiple, - m_Height - iTextHeight); - } else { + { CFX_Matrix affine_matrix1( 1.0, 0.0, 0.0, -1.0, (float)(leftPosition + 33 * multiple) * m_outputHScale, (float)(m_Height - iTextHeight + iFontSize)); - if (matrix) { + if (matrix) affine_matrix1.Concat(*matrix); - } device->DrawNormalText(iLen, pCharPos + 4, m_pFont, static_cast(iFontSize), &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); diff --git a/fxbarcode/oned/BC_OnedEAN8Writer.h b/fxbarcode/oned/BC_OnedEAN8Writer.h index 1d26d16620..57f3b44f7c 100644 --- a/fxbarcode/oned/BC_OnedEAN8Writer.h +++ b/fxbarcode/oned/BC_OnedEAN8Writer.h @@ -50,7 +50,6 @@ class CBC_OnedEAN8Writer : public CBC_OneDimWriter { protected: void ShowChars(const CFX_WideStringC& contents, - const CFX_RetainPtr& pOutBitmap, CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t barWidth, diff --git a/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/fxbarcode/oned/BC_OnedUPCAWriter.cpp index 87c6db12e1..3d31e2d389 100644 --- a/fxbarcode/oned/BC_OnedUPCAWriter.cpp +++ b/fxbarcode/oned/BC_OnedUPCAWriter.cpp @@ -119,13 +119,12 @@ uint8_t* CBC_OnedUPCAWriter::Encode(const CFX_ByteString& contents, void CBC_OnedUPCAWriter::ShowChars( const CFX_WideStringC& contents, - const CFX_RetainPtr& pOutBitmap, CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t barWidth, int32_t multiple, int32_t& e) { - if (!device && !pOutBitmap) { + if (!device) { e = BCExceptionIllegalArgument; return; } @@ -139,68 +138,53 @@ void CBC_OnedUPCAWriter::ShowChars( CFX_ByteString tempStr = str.Mid(1, 5); float strWidth = (float)35 * multiple; float blank = 0.0; - CFX_FxgeDevice geBitmap; - if (pOutBitmap) - geBitmap.Attach(pOutBitmap, false, nullptr, false); iLen = tempStr.GetLength(); int32_t iFontSize = (int32_t)fabs(m_fFontSize); int32_t iTextHeight = iFontSize + 1; - if (!pOutBitmap) { - CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); - CFX_FloatRect rect((float)leftPosition, (float)(m_Height - iTextHeight), - (float)(leftPosition + strWidth - 0.5), (float)m_Height); - matr.Concat(*matrix); - matr.TransformRect(rect); - FX_RECT re = rect.GetOuterRect(); - device->FillRect(&re, m_backgroundColor); - CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); - CFX_FloatRect rect1( - (float)(leftPosition + 40 * multiple), (float)(m_Height - iTextHeight), - (float)((leftPosition + 40 * multiple) + strWidth - 0.5), - (float)m_Height); - matr1.Concat(*matrix); - matr1.TransformRect(rect1); - re = rect1.GetOuterRect(); - device->FillRect(&re, m_backgroundColor); - float strWidth1 = (float)multiple * 7; - CFX_Matrix matr2(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); - CFX_FloatRect rect2(0.0, (float)(m_Height - iTextHeight), - (float)strWidth1 - 1, (float)m_Height); - matr2.Concat(*matrix); - matr2.TransformRect(rect2); - re = rect2.GetOuterRect(); - device->FillRect(&re, m_backgroundColor); - CFX_Matrix matr3(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); - CFX_FloatRect rect3( - (float)(leftPosition + 85 * multiple), (float)(m_Height - iTextHeight), - (float)((leftPosition + 85 * multiple) + strWidth1 - 0.5), - (float)m_Height); - matr3.Concat(*matrix); - matr3.TransformRect(rect3); - re = rect3.GetOuterRect(); - device->FillRect(&re, m_backgroundColor); - } - if (!pOutBitmap) - strWidth = strWidth * m_outputHScale; + + CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); + CFX_FloatRect rect((float)leftPosition, (float)(m_Height - iTextHeight), + (float)(leftPosition + strWidth - 0.5), (float)m_Height); + matr.Concat(*matrix); + matr.TransformRect(rect); + FX_RECT re = rect.GetOuterRect(); + device->FillRect(&re, m_backgroundColor); + CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); + CFX_FloatRect rect1((float)(leftPosition + 40 * multiple), + (float)(m_Height - iTextHeight), + (float)((leftPosition + 40 * multiple) + strWidth - 0.5), + (float)m_Height); + matr1.Concat(*matrix); + matr1.TransformRect(rect1); + re = rect1.GetOuterRect(); + device->FillRect(&re, m_backgroundColor); + float strWidth1 = (float)multiple * 7; + CFX_Matrix matr2(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); + CFX_FloatRect rect2(0.0, (float)(m_Height - iTextHeight), + (float)strWidth1 - 1, (float)m_Height); + matr2.Concat(*matrix); + matr2.TransformRect(rect2); + re = rect2.GetOuterRect(); + device->FillRect(&re, m_backgroundColor); + CFX_Matrix matr3(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); + CFX_FloatRect rect3((float)(leftPosition + 85 * multiple), + (float)(m_Height - iTextHeight), + (float)((leftPosition + 85 * multiple) + strWidth1 - 0.5), + (float)m_Height); + matr3.Concat(*matrix); + matr3.TransformRect(rect3); + re = rect3.GetOuterRect(); + device->FillRect(&re, m_backgroundColor); + strWidth = strWidth * m_outputHScale; CalcTextInfo(tempStr, pCharPos + 1, m_pFont, strWidth, iFontSize, blank); - CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (float)iFontSize); - CFX_FxgeDevice ge; - if (pOutBitmap) { - ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); - ge.GetBitmap()->Clear(m_backgroundColor); - ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, - static_cast(iFontSize), &affine_matrix, - m_fontColor, FXTEXT_CLEARTYPE); - geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); - } else { + { CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, (float)leftPosition * m_outputHScale, (float)(m_Height - iTextHeight + iFontSize)); - if (matrix) { + if (matrix) affine_matrix1.Concat(*matrix); - } device->DrawNormalText(iLen, pCharPos + 1, m_pFont, static_cast(iFontSize), &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); @@ -208,22 +192,13 @@ void CBC_OnedUPCAWriter::ShowChars( tempStr = str.Mid(6, 5); iLen = tempStr.GetLength(); CalcTextInfo(tempStr, pCharPos + 6, m_pFont, strWidth, iFontSize, blank); - if (pOutBitmap) { - FX_RECT rect2(0, 0, (int)strWidth, iTextHeight); - ge.FillRect(&rect2, m_backgroundColor); - ge.DrawNormalText(iLen, pCharPos + 6, m_pFont, - static_cast(iFontSize), &affine_matrix, - m_fontColor, FXTEXT_CLEARTYPE); - geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 40 * multiple, - m_Height - iTextHeight); - } else { + { CFX_Matrix affine_matrix1( 1.0, 0.0, 0.0, -1.0, (float)(leftPosition + 40 * multiple) * m_outputHScale, (float)(m_Height - iTextHeight + iFontSize)); - if (matrix) { + if (matrix) affine_matrix1.Concat(*matrix); - } device->DrawNormalText(iLen, pCharPos + 6, m_pFont, static_cast(iFontSize), &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); @@ -231,22 +206,14 @@ void CBC_OnedUPCAWriter::ShowChars( tempStr = str.Mid(0, 1); iLen = tempStr.GetLength(); strWidth = (float)multiple * 7; - if (!pOutBitmap) - strWidth = strWidth * m_outputHScale; + strWidth = strWidth * m_outputHScale; CalcTextInfo(tempStr, pCharPos, m_pFont, strWidth, iFontSize, blank); - if (pOutBitmap) { - ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); - ge.GetBitmap()->Clear(m_backgroundColor); - ge.DrawNormalText(iLen, pCharPos, m_pFont, static_cast(iFontSize), - &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); - geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight); - } else { + { CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0, (float)(m_Height - iTextHeight + iFontSize)); - if (matrix) { + if (matrix) affine_matrix1.Concat(*matrix); - } device->DrawNormalText(iLen, pCharPos, m_pFont, static_cast(iFontSize), &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); @@ -254,22 +221,13 @@ void CBC_OnedUPCAWriter::ShowChars( tempStr = str.Mid(11, 1); iLen = tempStr.GetLength(); CalcTextInfo(tempStr, pCharPos + 11, m_pFont, strWidth, iFontSize, blank); - if (pOutBitmap) { - ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); - ge.GetBitmap()->Clear(m_backgroundColor); - ge.DrawNormalText(iLen, pCharPos + 11, m_pFont, - static_cast(iFontSize), &affine_matrix, - m_fontColor, FXTEXT_CLEARTYPE); - geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 85 * multiple, - m_Height - iTextHeight); - } else { + { CFX_Matrix affine_matrix1( 1.0, 0.0, 0.0, -1.0, (float)(leftPosition + 85 * multiple) * m_outputHScale, (float)(m_Height - iTextHeight + iFontSize)); - if (matrix) { + if (matrix) affine_matrix1.Concat(*matrix); - } device->DrawNormalText(iLen, pCharPos + 11, m_pFont, static_cast(iFontSize), &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); diff --git a/fxbarcode/oned/BC_OnedUPCAWriter.h b/fxbarcode/oned/BC_OnedUPCAWriter.h index 83e70302f8..c52f4e0ecd 100644 --- a/fxbarcode/oned/BC_OnedUPCAWriter.h +++ b/fxbarcode/oned/BC_OnedUPCAWriter.h @@ -52,7 +52,6 @@ class CBC_OnedUPCAWriter : public CBC_OneDimWriter { protected: void ShowChars(const CFX_WideStringC& contents, - const CFX_RetainPtr& pOutBitmap, CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t barWidth, -- cgit v1.2.3