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 2010 ZXing authors | 8 * Copyright 2010 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 strWidth = strWidth * m_outputHScale; | 175 strWidth = strWidth * m_outputHScale; |
176 } | 176 } |
177 CalcTextInfo(tempStr, pCharPos + 1, m_pFont, strWidth, iFontSize, blank); | 177 CalcTextInfo(tempStr, pCharPos + 1, m_pFont, strWidth, iFontSize, blank); |
178 CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); | 178 CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); |
179 CFX_FxgeDevice ge; | 179 CFX_FxgeDevice ge; |
180 if (pOutBitmap) { | 180 if (pOutBitmap) { |
181 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); | 181 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); |
182 ge.GetBitmap()->Clear(m_backgroundColor); | 182 ge.GetBitmap()->Clear(m_backgroundColor); |
183 ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, | 183 ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, |
184 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, | 184 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, |
185 (CFX_Matrix*)&affine_matrix, m_fontColor, | 185 &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); |
186 FXTEXT_CLEARTYPE); | |
187 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); | 186 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); |
188 } else { | 187 } else { |
189 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, | 188 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, |
190 (FX_FLOAT)leftPosition * m_outputHScale, | 189 (FX_FLOAT)leftPosition * m_outputHScale, |
191 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); | 190 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); |
192 if (matrix) { | 191 if (matrix) { |
193 affine_matrix1.Concat(*matrix); | 192 affine_matrix1.Concat(*matrix); |
194 } | 193 } |
195 device->DrawNormalText(iLen, pCharPos + 1, m_pFont, | 194 device->DrawNormalText( |
196 CFX_GEModule::Get()->GetFontCache(), | 195 iLen, pCharPos + 1, m_pFont, CFX_GEModule::Get()->GetFontCache(), |
197 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, | 196 (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); |
198 m_fontColor, FXTEXT_CLEARTYPE); | |
199 } | 197 } |
200 tempStr = str.Mid(6, 5); | 198 tempStr = str.Mid(6, 5); |
201 iLen = tempStr.GetLength(); | 199 iLen = tempStr.GetLength(); |
202 CalcTextInfo(tempStr, pCharPos + 6, m_pFont, strWidth, iFontSize, blank); | 200 CalcTextInfo(tempStr, pCharPos + 6, m_pFont, strWidth, iFontSize, blank); |
203 if (pOutBitmap) { | 201 if (pOutBitmap) { |
204 FX_RECT rect2(0, 0, (int)strWidth, iTextHeight); | 202 FX_RECT rect2(0, 0, (int)strWidth, iTextHeight); |
205 ge.FillRect(&rect2, m_backgroundColor); | 203 ge.FillRect(&rect2, m_backgroundColor); |
206 ge.DrawNormalText(iLen, pCharPos + 6, m_pFont, | 204 ge.DrawNormalText(iLen, pCharPos + 6, m_pFont, |
207 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, | 205 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, |
208 (CFX_Matrix*)&affine_matrix, m_fontColor, | 206 &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); |
209 FXTEXT_CLEARTYPE); | |
210 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 40 * multiple, | 207 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 40 * multiple, |
211 m_Height - iTextHeight); | 208 m_Height - iTextHeight); |
212 } else { | 209 } else { |
213 CFX_Matrix affine_matrix1( | 210 CFX_Matrix affine_matrix1( |
214 1.0, 0.0, 0.0, -1.0, | 211 1.0, 0.0, 0.0, -1.0, |
215 (FX_FLOAT)(leftPosition + 40 * multiple) * m_outputHScale, | 212 (FX_FLOAT)(leftPosition + 40 * multiple) * m_outputHScale, |
216 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); | 213 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); |
217 if (matrix) { | 214 if (matrix) { |
218 affine_matrix1.Concat(*matrix); | 215 affine_matrix1.Concat(*matrix); |
219 } | 216 } |
220 device->DrawNormalText(iLen, pCharPos + 6, m_pFont, | 217 device->DrawNormalText( |
221 CFX_GEModule::Get()->GetFontCache(), | 218 iLen, pCharPos + 6, m_pFont, CFX_GEModule::Get()->GetFontCache(), |
222 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, | 219 (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); |
223 m_fontColor, FXTEXT_CLEARTYPE); | |
224 } | 220 } |
225 tempStr = str.Mid(0, 1); | 221 tempStr = str.Mid(0, 1); |
226 iLen = tempStr.GetLength(); | 222 iLen = tempStr.GetLength(); |
227 strWidth = (FX_FLOAT)multiple * 7; | 223 strWidth = (FX_FLOAT)multiple * 7; |
228 if (pOutBitmap == NULL) { | 224 if (pOutBitmap == NULL) { |
229 strWidth = strWidth * m_outputHScale; | 225 strWidth = strWidth * m_outputHScale; |
230 } | 226 } |
231 CalcTextInfo(tempStr, pCharPos, m_pFont, strWidth, iFontSize, blank); | 227 CalcTextInfo(tempStr, pCharPos, m_pFont, strWidth, iFontSize, blank); |
232 if (pOutBitmap) { | 228 if (pOutBitmap) { |
233 delete ge.GetBitmap(); | 229 delete ge.GetBitmap(); |
234 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); | 230 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); |
235 ge.GetBitmap()->Clear(m_backgroundColor); | 231 ge.GetBitmap()->Clear(m_backgroundColor); |
236 ge.DrawNormalText(iLen, pCharPos, m_pFont, | 232 ge.DrawNormalText(iLen, pCharPos, m_pFont, |
237 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, | 233 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, |
238 (CFX_Matrix*)&affine_matrix, m_fontColor, | 234 &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); |
239 FXTEXT_CLEARTYPE); | |
240 geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight); | 235 geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight); |
241 } else { | 236 } else { |
242 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0, | 237 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0, |
243 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); | 238 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); |
244 if (matrix) { | 239 if (matrix) { |
245 affine_matrix1.Concat(*matrix); | 240 affine_matrix1.Concat(*matrix); |
246 } | 241 } |
247 device->DrawNormalText(iLen, pCharPos, m_pFont, | 242 device->DrawNormalText( |
248 CFX_GEModule::Get()->GetFontCache(), | 243 iLen, pCharPos, m_pFont, CFX_GEModule::Get()->GetFontCache(), |
249 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, | 244 (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); |
250 m_fontColor, FXTEXT_CLEARTYPE); | |
251 } | 245 } |
252 tempStr = str.Mid(11, 1); | 246 tempStr = str.Mid(11, 1); |
253 iLen = tempStr.GetLength(); | 247 iLen = tempStr.GetLength(); |
254 CalcTextInfo(tempStr, pCharPos + 11, m_pFont, strWidth, iFontSize, blank); | 248 CalcTextInfo(tempStr, pCharPos + 11, m_pFont, strWidth, iFontSize, blank); |
255 if (pOutBitmap) { | 249 if (pOutBitmap) { |
256 delete ge.GetBitmap(); | 250 delete ge.GetBitmap(); |
257 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); | 251 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); |
258 ge.GetBitmap()->Clear(m_backgroundColor); | 252 ge.GetBitmap()->Clear(m_backgroundColor); |
259 ge.DrawNormalText(iLen, pCharPos + 11, m_pFont, | 253 ge.DrawNormalText(iLen, pCharPos + 11, m_pFont, |
260 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, | 254 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, |
261 (CFX_Matrix*)&affine_matrix, m_fontColor, | 255 &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); |
262 FXTEXT_CLEARTYPE); | |
263 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 85 * multiple, | 256 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 85 * multiple, |
264 m_Height - iTextHeight); | 257 m_Height - iTextHeight); |
265 } else { | 258 } else { |
266 CFX_Matrix affine_matrix1( | 259 CFX_Matrix affine_matrix1( |
267 1.0, 0.0, 0.0, -1.0, | 260 1.0, 0.0, 0.0, -1.0, |
268 (FX_FLOAT)(leftPosition + 85 * multiple) * m_outputHScale, | 261 (FX_FLOAT)(leftPosition + 85 * multiple) * m_outputHScale, |
269 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); | 262 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); |
270 if (matrix) { | 263 if (matrix) { |
271 affine_matrix1.Concat(*matrix); | 264 affine_matrix1.Concat(*matrix); |
272 } | 265 } |
273 device->DrawNormalText(iLen, pCharPos + 11, m_pFont, | 266 device->DrawNormalText( |
274 CFX_GEModule::Get()->GetFontCache(), | 267 iLen, pCharPos + 11, m_pFont, CFX_GEModule::Get()->GetFontCache(), |
275 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, | 268 (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); |
276 m_fontColor, FXTEXT_CLEARTYPE); | |
277 } | 269 } |
278 FX_Free(pCharPos); | 270 FX_Free(pCharPos); |
279 } | 271 } |
280 | 272 |
281 void CBC_OnedUPCAWriter::RenderResult(const CFX_WideStringC& contents, | 273 void CBC_OnedUPCAWriter::RenderResult(const CFX_WideStringC& contents, |
282 uint8_t* code, | 274 uint8_t* code, |
283 int32_t codeLength, | 275 int32_t codeLength, |
284 FX_BOOL isDevice, | 276 FX_BOOL isDevice, |
285 int32_t& e) { | 277 int32_t& e) { |
286 CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); | 278 CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); |
287 } | 279 } |
OLD | NEW |