| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 // Original code is licensed as follows: | 6 // Original code is licensed as follows: |
| 7 /* | 7 /* |
| 8 * Copyright 2009 ZXing authors | 8 * Copyright 2009 ZXing authors |
| 9 * | 9 * |
| 10 * Licensed under the Apache License, Version 2.0 (the "License"); | 10 * Licensed under the Apache License, Version 2.0 (the "License"); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 int32_t leftPosition = 3 * multiple; | 172 int32_t leftPosition = 3 * multiple; |
| 173 CFX_ByteString str = FX_UTF8Encode(contents); | 173 CFX_ByteString str = FX_UTF8Encode(contents); |
| 174 int32_t iLength = str.GetLength(); | 174 int32_t iLength = str.GetLength(); |
| 175 FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLength); | 175 FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLength); |
| 176 FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLength); | 176 FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLength); |
| 177 CFX_ByteString tempStr = str.Mid(0, 4); | 177 CFX_ByteString tempStr = str.Mid(0, 4); |
| 178 int32_t iLen = tempStr.GetLength(); | 178 int32_t iLen = tempStr.GetLength(); |
| 179 int32_t strWidth = 7 * multiple * 4; | 179 int32_t strWidth = 7 * multiple * 4; |
| 180 FX_FLOAT blank = 0.0; | 180 FX_FLOAT blank = 0.0; |
| 181 CFX_FxgeDevice geBitmap; | 181 CFX_FxgeDevice geBitmap; |
| 182 if (pOutBitmap != NULL) { | 182 if (pOutBitmap) { |
| 183 geBitmap.Attach(pOutBitmap); | 183 geBitmap.Attach(pOutBitmap); |
| 184 } | 184 } |
| 185 FX_FLOAT charsWidth = 0; | 185 FX_FLOAT charsWidth = 0; |
| 186 int32_t iFontSize = (int32_t)fabs(m_fFontSize); | 186 int32_t iFontSize = (int32_t)fabs(m_fFontSize); |
| 187 int32_t iTextHeight = iFontSize + 1; | 187 int32_t iTextHeight = iFontSize + 1; |
| 188 if (pOutBitmap == NULL) { | 188 if (pOutBitmap == NULL) { |
| 189 CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); | 189 CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); |
| 190 CFX_FloatRect rect( | 190 CFX_FloatRect rect( |
| 191 (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), | 191 (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), |
| 192 (FX_FLOAT)(leftPosition + strWidth - 0.5), (FX_FLOAT)m_Height); | 192 (FX_FLOAT)(leftPosition + strWidth - 0.5), (FX_FLOAT)m_Height); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 205 re = rect1.GetOutterRect(); | 205 re = rect1.GetOutterRect(); |
| 206 device->FillRect(&re, m_backgroundColor); | 206 device->FillRect(&re, m_backgroundColor); |
| 207 } | 207 } |
| 208 if (pOutBitmap == NULL) { | 208 if (pOutBitmap == NULL) { |
| 209 strWidth = (int32_t)(strWidth * m_outputHScale); | 209 strWidth = (int32_t)(strWidth * m_outputHScale); |
| 210 } | 210 } |
| 211 CalcTextInfo(tempStr, pCharPos, m_pFont, (FX_FLOAT)strWidth, iFontSize, | 211 CalcTextInfo(tempStr, pCharPos, m_pFont, (FX_FLOAT)strWidth, iFontSize, |
| 212 blank); | 212 blank); |
| 213 CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); | 213 CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); |
| 214 CFX_FxgeDevice ge; | 214 CFX_FxgeDevice ge; |
| 215 if (pOutBitmap != NULL) { | 215 if (pOutBitmap) { |
| 216 delete ge.GetBitmap(); | 216 delete ge.GetBitmap(); |
| 217 ge.Create(strWidth, iTextHeight, FXDIB_Argb); | 217 ge.Create(strWidth, iTextHeight, FXDIB_Argb); |
| 218 ge.GetBitmap()->Clear(m_backgroundColor); | 218 ge.GetBitmap()->Clear(m_backgroundColor); |
| 219 ge.DrawNormalText(iLen, pCharPos, m_pFont, | 219 ge.DrawNormalText(iLen, pCharPos, m_pFont, |
| 220 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, | 220 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, |
| 221 (CFX_Matrix*)&affine_matrix, m_fontColor, | 221 (CFX_Matrix*)&affine_matrix, m_fontColor, |
| 222 FXTEXT_CLEARTYPE); | 222 FXTEXT_CLEARTYPE); |
| 223 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); | 223 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); |
| 224 } else { | 224 } else { |
| 225 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, | 225 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, |
| 226 (FX_FLOAT)leftPosition * m_outputHScale, | 226 (FX_FLOAT)leftPosition * m_outputHScale, |
| 227 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); | 227 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); |
| 228 affine_matrix1.Concat(*matrix); | 228 affine_matrix1.Concat(*matrix); |
| 229 device->DrawNormalText(iLen, pCharPos, m_pFont, | 229 device->DrawNormalText(iLen, pCharPos, m_pFont, |
| 230 CFX_GEModule::Get()->GetFontCache(), | 230 CFX_GEModule::Get()->GetFontCache(), |
| 231 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, | 231 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, |
| 232 m_fontColor, FXTEXT_CLEARTYPE); | 232 m_fontColor, FXTEXT_CLEARTYPE); |
| 233 } | 233 } |
| 234 tempStr = str.Mid(4, 4); | 234 tempStr = str.Mid(4, 4); |
| 235 iLen = tempStr.GetLength(); | 235 iLen = tempStr.GetLength(); |
| 236 charsWidth = 0.0f; | 236 charsWidth = 0.0f; |
| 237 CalcTextInfo(tempStr, pCharPos + 4, m_pFont, (FX_FLOAT)strWidth, iFontSize, | 237 CalcTextInfo(tempStr, pCharPos + 4, m_pFont, (FX_FLOAT)strWidth, iFontSize, |
| 238 blank); | 238 blank); |
| 239 if (pOutBitmap != NULL) { | 239 if (pOutBitmap) { |
| 240 delete ge.GetBitmap(); | 240 delete ge.GetBitmap(); |
| 241 ge.Create(strWidth, iTextHeight, FXDIB_Argb); | 241 ge.Create(strWidth, iTextHeight, FXDIB_Argb); |
| 242 ge.GetBitmap()->Clear(m_backgroundColor); | 242 ge.GetBitmap()->Clear(m_backgroundColor); |
| 243 ge.DrawNormalText(iLen, pCharPos + 4, m_pFont, | 243 ge.DrawNormalText(iLen, pCharPos + 4, m_pFont, |
| 244 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, | 244 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, |
| 245 (CFX_Matrix*)&affine_matrix, m_fontColor, | 245 (CFX_Matrix*)&affine_matrix, m_fontColor, |
| 246 FXTEXT_CLEARTYPE); | 246 FXTEXT_CLEARTYPE); |
| 247 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 33 * multiple, | 247 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 33 * multiple, |
| 248 m_Height - iTextHeight); | 248 m_Height - iTextHeight); |
| 249 } else { | 249 } else { |
| 250 CFX_Matrix affine_matrix1( | 250 CFX_Matrix affine_matrix1( |
| 251 1.0, 0.0, 0.0, -1.0, | 251 1.0, 0.0, 0.0, -1.0, |
| 252 (FX_FLOAT)(leftPosition + 33 * multiple) * m_outputHScale, | 252 (FX_FLOAT)(leftPosition + 33 * multiple) * m_outputHScale, |
| 253 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); | 253 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); |
| 254 if (matrix != NULL) { | 254 if (matrix) { |
| 255 affine_matrix1.Concat(*matrix); | 255 affine_matrix1.Concat(*matrix); |
| 256 } | 256 } |
| 257 device->DrawNormalText(iLen, pCharPos + 4, m_pFont, | 257 device->DrawNormalText(iLen, pCharPos + 4, m_pFont, |
| 258 CFX_GEModule::Get()->GetFontCache(), | 258 CFX_GEModule::Get()->GetFontCache(), |
| 259 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, | 259 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, |
| 260 m_fontColor, FXTEXT_CLEARTYPE); | 260 m_fontColor, FXTEXT_CLEARTYPE); |
| 261 } | 261 } |
| 262 FX_Free(pCharPos); | 262 FX_Free(pCharPos); |
| 263 } | 263 } |
| 264 void CBC_OnedEAN8Writer::RenderResult(const CFX_WideStringC& contents, | 264 void CBC_OnedEAN8Writer::RenderResult(const CFX_WideStringC& contents, |
| 265 uint8_t* code, | 265 uint8_t* code, |
| 266 int32_t codeLength, | 266 int32_t codeLength, |
| 267 FX_BOOL isDevice, | 267 FX_BOOL isDevice, |
| 268 int32_t& e) { | 268 int32_t& e) { |
| 269 CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); | 269 CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); |
| 270 } | 270 } |
| OLD | NEW |