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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 e = BCExceptionIllegalArgument; | 164 e = BCExceptionIllegalArgument; |
165 return; | 165 return; |
166 } | 166 } |
167 int32_t leftPadding = 7 * multiple; | 167 int32_t leftPadding = 7 * multiple; |
168 int32_t leftPosition = 3 * multiple + leftPadding; | 168 int32_t leftPosition = 3 * multiple + leftPadding; |
169 CFX_ByteString str = FX_UTF8Encode(contents); | 169 CFX_ByteString str = FX_UTF8Encode(contents); |
170 int32_t iLen = str.GetLength(); | 170 int32_t iLen = str.GetLength(); |
171 FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen); | 171 FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen); |
172 FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen); | 172 FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen); |
173 CFX_FxgeDevice geBitmap; | 173 CFX_FxgeDevice geBitmap; |
174 if (pOutBitmap != NULL) { | 174 if (pOutBitmap) { |
175 geBitmap.Attach(pOutBitmap); | 175 geBitmap.Attach(pOutBitmap); |
176 } | 176 } |
177 int32_t iFontSize = (int32_t)fabs(m_fFontSize); | 177 int32_t iFontSize = (int32_t)fabs(m_fFontSize); |
178 int32_t iTextHeight = iFontSize + 1; | 178 int32_t iTextHeight = iFontSize + 1; |
179 CFX_ByteString tempStr = str.Mid(1, 6); | 179 CFX_ByteString tempStr = str.Mid(1, 6); |
180 int32_t strWidth = multiple * 42; | 180 int32_t strWidth = multiple * 42; |
181 if (pOutBitmap == NULL) { | 181 if (pOutBitmap == NULL) { |
182 CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); | 182 CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); |
183 CFX_FloatRect rect( | 183 CFX_FloatRect rect( |
184 (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), | 184 (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), |
(...skipping 24 matching lines...) Expand all Loading... |
209 FX_FLOAT blank = 0.0; | 209 FX_FLOAT blank = 0.0; |
210 FX_FLOAT charsWidth = 0; | 210 FX_FLOAT charsWidth = 0; |
211 iLen = tempStr.GetLength(); | 211 iLen = tempStr.GetLength(); |
212 if (pOutBitmap == NULL) { | 212 if (pOutBitmap == NULL) { |
213 strWidth = (int32_t)(strWidth * m_outputHScale); | 213 strWidth = (int32_t)(strWidth * m_outputHScale); |
214 } | 214 } |
215 CalcTextInfo(tempStr, pCharPos + 1, m_pFont, (FX_FLOAT)strWidth, iFontSize, | 215 CalcTextInfo(tempStr, pCharPos + 1, m_pFont, (FX_FLOAT)strWidth, iFontSize, |
216 blank); | 216 blank); |
217 CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); | 217 CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); |
218 CFX_FxgeDevice ge; | 218 CFX_FxgeDevice ge; |
219 if (pOutBitmap != NULL) { | 219 if (pOutBitmap) { |
220 ge.Create(strWidth, iTextHeight, FXDIB_Argb); | 220 ge.Create(strWidth, iTextHeight, FXDIB_Argb); |
221 FX_RECT rect(0, 0, strWidth, iTextHeight); | 221 FX_RECT rect(0, 0, strWidth, iTextHeight); |
222 ge.FillRect(&rect, m_backgroundColor); | 222 ge.FillRect(&rect, m_backgroundColor); |
223 ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, | 223 ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, |
224 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, | 224 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, |
225 (CFX_Matrix*)&affine_matrix, m_fontColor, | 225 (CFX_Matrix*)&affine_matrix, m_fontColor, |
226 FXTEXT_CLEARTYPE); | 226 FXTEXT_CLEARTYPE); |
227 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); | 227 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); |
228 } else { | 228 } else { |
229 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, | 229 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, |
230 (FX_FLOAT)leftPosition * m_outputHScale, | 230 (FX_FLOAT)leftPosition * m_outputHScale, |
231 (FX_FLOAT)(m_Height - iTextHeight) + iFontSize); | 231 (FX_FLOAT)(m_Height - iTextHeight) + iFontSize); |
232 if (matrix != NULL) { | 232 if (matrix) { |
233 affine_matrix1.Concat(*matrix); | 233 affine_matrix1.Concat(*matrix); |
234 } | 234 } |
235 device->DrawNormalText(iLen, pCharPos + 1, m_pFont, | 235 device->DrawNormalText(iLen, pCharPos + 1, m_pFont, |
236 CFX_GEModule::Get()->GetFontCache(), | 236 CFX_GEModule::Get()->GetFontCache(), |
237 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, | 237 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, |
238 m_fontColor, FXTEXT_CLEARTYPE); | 238 m_fontColor, FXTEXT_CLEARTYPE); |
239 } | 239 } |
240 tempStr = str.Mid(7, 6); | 240 tempStr = str.Mid(7, 6); |
241 iLen = tempStr.GetLength(); | 241 iLen = tempStr.GetLength(); |
242 charsWidth = 0.0f; | 242 charsWidth = 0.0f; |
243 CalcTextInfo(tempStr, pCharPos + 7, m_pFont, (FX_FLOAT)strWidth, iFontSize, | 243 CalcTextInfo(tempStr, pCharPos + 7, m_pFont, (FX_FLOAT)strWidth, iFontSize, |
244 blank); | 244 blank); |
245 if (pOutBitmap != NULL) { | 245 if (pOutBitmap) { |
246 FX_RECT rect1(0, 0, strWidth, iTextHeight); | 246 FX_RECT rect1(0, 0, strWidth, iTextHeight); |
247 ge.FillRect(&rect1, m_backgroundColor); | 247 ge.FillRect(&rect1, m_backgroundColor); |
248 ge.DrawNormalText(iLen, pCharPos + 7, m_pFont, | 248 ge.DrawNormalText(iLen, pCharPos + 7, m_pFont, |
249 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, | 249 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, |
250 (CFX_Matrix*)&affine_matrix, m_fontColor, | 250 (CFX_Matrix*)&affine_matrix, m_fontColor, |
251 FXTEXT_CLEARTYPE); | 251 FXTEXT_CLEARTYPE); |
252 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 47 * multiple, | 252 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 47 * multiple, |
253 m_Height - iTextHeight); | 253 m_Height - iTextHeight); |
254 } else { | 254 } else { |
255 CFX_Matrix affine_matrix1( | 255 CFX_Matrix affine_matrix1( |
256 1.0, 0.0, 0.0, -1.0, | 256 1.0, 0.0, 0.0, -1.0, |
257 (FX_FLOAT)(leftPosition + 47 * multiple) * m_outputHScale, | 257 (FX_FLOAT)(leftPosition + 47 * multiple) * m_outputHScale, |
258 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); | 258 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); |
259 if (matrix != NULL) { | 259 if (matrix) { |
260 affine_matrix1.Concat(*matrix); | 260 affine_matrix1.Concat(*matrix); |
261 } | 261 } |
262 device->DrawNormalText(iLen, pCharPos + 7, m_pFont, | 262 device->DrawNormalText(iLen, pCharPos + 7, m_pFont, |
263 CFX_GEModule::Get()->GetFontCache(), | 263 CFX_GEModule::Get()->GetFontCache(), |
264 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, | 264 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, |
265 m_fontColor, FXTEXT_CLEARTYPE); | 265 m_fontColor, FXTEXT_CLEARTYPE); |
266 } | 266 } |
267 tempStr = str.Mid(0, 1); | 267 tempStr = str.Mid(0, 1); |
268 iLen = tempStr.GetLength(); | 268 iLen = tempStr.GetLength(); |
269 strWidth = multiple * 7; | 269 strWidth = multiple * 7; |
270 if (pOutBitmap == NULL) { | 270 if (pOutBitmap == NULL) { |
271 strWidth = (int32_t)(strWidth * m_outputHScale); | 271 strWidth = (int32_t)(strWidth * m_outputHScale); |
272 } | 272 } |
273 CalcTextInfo(tempStr, pCharPos, m_pFont, (FX_FLOAT)strWidth, iFontSize, | 273 CalcTextInfo(tempStr, pCharPos, m_pFont, (FX_FLOAT)strWidth, iFontSize, |
274 blank); | 274 blank); |
275 if (pOutBitmap != NULL) { | 275 if (pOutBitmap) { |
276 delete ge.GetBitmap(); | 276 delete ge.GetBitmap(); |
277 ge.Create(strWidth, iTextHeight, FXDIB_Argb); | 277 ge.Create(strWidth, iTextHeight, FXDIB_Argb); |
278 ge.GetBitmap()->Clear(m_backgroundColor); | 278 ge.GetBitmap()->Clear(m_backgroundColor); |
279 ge.DrawNormalText(iLen, pCharPos, m_pFont, | 279 ge.DrawNormalText(iLen, pCharPos, m_pFont, |
280 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, | 280 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, |
281 (CFX_Matrix*)&affine_matrix, m_fontColor, | 281 (CFX_Matrix*)&affine_matrix, m_fontColor, |
282 FXTEXT_CLEARTYPE); | 282 FXTEXT_CLEARTYPE); |
283 geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight); | 283 geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight); |
284 } else { | 284 } else { |
285 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0.0, | 285 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0.0, |
286 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); | 286 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); |
287 if (matrix != NULL) { | 287 if (matrix) { |
288 affine_matrix1.Concat(*matrix); | 288 affine_matrix1.Concat(*matrix); |
289 } | 289 } |
290 device->DrawNormalText(iLen, pCharPos, m_pFont, | 290 device->DrawNormalText(iLen, pCharPos, m_pFont, |
291 CFX_GEModule::Get()->GetFontCache(), | 291 CFX_GEModule::Get()->GetFontCache(), |
292 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, | 292 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, |
293 m_fontColor, FXTEXT_CLEARTYPE); | 293 m_fontColor, FXTEXT_CLEARTYPE); |
294 } | 294 } |
295 FX_Free(pCharPos); | 295 FX_Free(pCharPos); |
296 } | 296 } |
297 void CBC_OnedEAN13Writer::RenderResult(const CFX_WideStringC& contents, | 297 void CBC_OnedEAN13Writer::RenderResult(const CFX_WideStringC& contents, |
298 uint8_t* code, | 298 uint8_t* code, |
299 int32_t codeLength, | 299 int32_t codeLength, |
300 FX_BOOL isDevice, | 300 FX_BOOL isDevice, |
301 int32_t& e) { | 301 int32_t& e) { |
302 CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); | 302 CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); |
303 } | 303 } |
OLD | NEW |