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 16 matching lines...) Expand all Loading... |
27 | 27 |
28 CBC_OnedUPCAWriter::CBC_OnedUPCAWriter() { | 28 CBC_OnedUPCAWriter::CBC_OnedUPCAWriter() { |
29 m_subWriter = NULL; | 29 m_subWriter = NULL; |
30 m_bLeftPadding = TRUE; | 30 m_bLeftPadding = TRUE; |
31 m_bRightPadding = TRUE; | 31 m_bRightPadding = TRUE; |
32 } | 32 } |
33 void CBC_OnedUPCAWriter::Init() { | 33 void CBC_OnedUPCAWriter::Init() { |
34 m_subWriter = new CBC_OnedEAN13Writer; | 34 m_subWriter = new CBC_OnedEAN13Writer; |
35 } | 35 } |
36 CBC_OnedUPCAWriter::~CBC_OnedUPCAWriter() { | 36 CBC_OnedUPCAWriter::~CBC_OnedUPCAWriter() { |
37 if (m_subWriter != NULL) { | 37 delete m_subWriter; |
38 delete m_subWriter; | |
39 } | |
40 m_subWriter = NULL; | |
41 } | 38 } |
42 FX_BOOL CBC_OnedUPCAWriter::CheckContentValidity( | 39 FX_BOOL CBC_OnedUPCAWriter::CheckContentValidity( |
43 const CFX_WideStringC& contents) { | 40 const CFX_WideStringC& contents) { |
44 int32_t i = 0; | 41 int32_t i = 0; |
45 for (i = 0; i < contents.GetLength(); i++) { | 42 for (i = 0; i < contents.GetLength(); i++) { |
46 if (contents.GetAt(i) >= '0' && contents.GetAt(i) <= '9') { | 43 if (contents.GetAt(i) >= '0' && contents.GetAt(i) <= '9') { |
47 continue; | 44 continue; |
48 } else { | 45 } else { |
49 return FALSE; | 46 return FALSE; |
50 } | 47 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 int32_t leftPadding = 7 * multiple; | 120 int32_t leftPadding = 7 * multiple; |
124 int32_t leftPosition = 10 * multiple + leftPadding; | 121 int32_t leftPosition = 10 * multiple + leftPadding; |
125 CFX_ByteString str = FX_UTF8Encode(contents); | 122 CFX_ByteString str = FX_UTF8Encode(contents); |
126 int32_t iLen = str.GetLength(); | 123 int32_t iLen = str.GetLength(); |
127 FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen); | 124 FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen); |
128 FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen); | 125 FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen); |
129 CFX_ByteString tempStr = str.Mid(1, 5); | 126 CFX_ByteString tempStr = str.Mid(1, 5); |
130 FX_FLOAT strWidth = (FX_FLOAT)35 * multiple; | 127 FX_FLOAT strWidth = (FX_FLOAT)35 * multiple; |
131 FX_FLOAT blank = 0.0; | 128 FX_FLOAT blank = 0.0; |
132 CFX_FxgeDevice geBitmap; | 129 CFX_FxgeDevice geBitmap; |
133 if (pOutBitmap != NULL) { | 130 if (pOutBitmap) { |
134 geBitmap.Attach(pOutBitmap); | 131 geBitmap.Attach(pOutBitmap); |
135 } | 132 } |
136 FX_FLOAT charsWidth = 0; | 133 FX_FLOAT charsWidth = 0; |
137 iLen = tempStr.GetLength(); | 134 iLen = tempStr.GetLength(); |
138 int32_t iFontSize = (int32_t)fabs(m_fFontSize); | 135 int32_t iFontSize = (int32_t)fabs(m_fFontSize); |
139 int32_t iTextHeight = iFontSize + 1; | 136 int32_t iTextHeight = iFontSize + 1; |
140 if (pOutBitmap == NULL) { | 137 if (pOutBitmap == NULL) { |
141 CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); | 138 CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); |
142 CFX_FloatRect rect( | 139 CFX_FloatRect rect( |
143 (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), | 140 (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), |
(...skipping 30 matching lines...) Expand all Loading... |
174 matr3.TransformRect(rect3); | 171 matr3.TransformRect(rect3); |
175 re = rect3.GetOutterRect(); | 172 re = rect3.GetOutterRect(); |
176 device->FillRect(&re, m_backgroundColor); | 173 device->FillRect(&re, m_backgroundColor); |
177 } | 174 } |
178 if (pOutBitmap == NULL) { | 175 if (pOutBitmap == NULL) { |
179 strWidth = strWidth * m_outputHScale; | 176 strWidth = strWidth * m_outputHScale; |
180 } | 177 } |
181 CalcTextInfo(tempStr, pCharPos + 1, m_pFont, strWidth, iFontSize, blank); | 178 CalcTextInfo(tempStr, pCharPos + 1, m_pFont, strWidth, iFontSize, blank); |
182 CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); | 179 CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); |
183 CFX_FxgeDevice ge; | 180 CFX_FxgeDevice ge; |
184 if (pOutBitmap != NULL) { | 181 if (pOutBitmap) { |
185 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); | 182 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); |
186 ge.GetBitmap()->Clear(m_backgroundColor); | 183 ge.GetBitmap()->Clear(m_backgroundColor); |
187 ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, | 184 ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, |
188 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, | 185 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, |
189 (CFX_Matrix*)&affine_matrix, m_fontColor, | 186 (CFX_Matrix*)&affine_matrix, m_fontColor, |
190 FXTEXT_CLEARTYPE); | 187 FXTEXT_CLEARTYPE); |
191 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); | 188 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); |
192 } else { | 189 } else { |
193 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, | 190 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, |
194 (FX_FLOAT)leftPosition * m_outputHScale, | 191 (FX_FLOAT)leftPosition * m_outputHScale, |
195 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); | 192 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); |
196 if (matrix != NULL) { | 193 if (matrix) { |
197 affine_matrix1.Concat(*matrix); | 194 affine_matrix1.Concat(*matrix); |
198 } | 195 } |
199 device->DrawNormalText(iLen, pCharPos + 1, m_pFont, | 196 device->DrawNormalText(iLen, pCharPos + 1, m_pFont, |
200 CFX_GEModule::Get()->GetFontCache(), | 197 CFX_GEModule::Get()->GetFontCache(), |
201 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, | 198 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, |
202 m_fontColor, FXTEXT_CLEARTYPE); | 199 m_fontColor, FXTEXT_CLEARTYPE); |
203 } | 200 } |
204 tempStr = str.Mid(6, 5); | 201 tempStr = str.Mid(6, 5); |
205 iLen = tempStr.GetLength(); | 202 iLen = tempStr.GetLength(); |
206 charsWidth = 0.0f; | 203 charsWidth = 0.0f; |
207 CalcTextInfo(tempStr, pCharPos + 6, m_pFont, strWidth, iFontSize, blank); | 204 CalcTextInfo(tempStr, pCharPos + 6, m_pFont, strWidth, iFontSize, blank); |
208 if (pOutBitmap != NULL) { | 205 if (pOutBitmap) { |
209 FX_RECT rect2(0, 0, (int)strWidth, iTextHeight); | 206 FX_RECT rect2(0, 0, (int)strWidth, iTextHeight); |
210 ge.FillRect(&rect2, m_backgroundColor); | 207 ge.FillRect(&rect2, m_backgroundColor); |
211 ge.DrawNormalText(iLen, pCharPos + 6, m_pFont, | 208 ge.DrawNormalText(iLen, pCharPos + 6, m_pFont, |
212 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, | 209 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, |
213 (CFX_Matrix*)&affine_matrix, m_fontColor, | 210 (CFX_Matrix*)&affine_matrix, m_fontColor, |
214 FXTEXT_CLEARTYPE); | 211 FXTEXT_CLEARTYPE); |
215 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 40 * multiple, | 212 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 40 * multiple, |
216 m_Height - iTextHeight); | 213 m_Height - iTextHeight); |
217 } else { | 214 } else { |
218 CFX_Matrix affine_matrix1( | 215 CFX_Matrix affine_matrix1( |
219 1.0, 0.0, 0.0, -1.0, | 216 1.0, 0.0, 0.0, -1.0, |
220 (FX_FLOAT)(leftPosition + 40 * multiple) * m_outputHScale, | 217 (FX_FLOAT)(leftPosition + 40 * multiple) * m_outputHScale, |
221 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); | 218 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); |
222 if (matrix != NULL) { | 219 if (matrix) { |
223 affine_matrix1.Concat(*matrix); | 220 affine_matrix1.Concat(*matrix); |
224 } | 221 } |
225 device->DrawNormalText(iLen, pCharPos + 6, m_pFont, | 222 device->DrawNormalText(iLen, pCharPos + 6, m_pFont, |
226 CFX_GEModule::Get()->GetFontCache(), | 223 CFX_GEModule::Get()->GetFontCache(), |
227 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, | 224 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, |
228 m_fontColor, FXTEXT_CLEARTYPE); | 225 m_fontColor, FXTEXT_CLEARTYPE); |
229 } | 226 } |
230 tempStr = str.Mid(0, 1); | 227 tempStr = str.Mid(0, 1); |
231 iLen = tempStr.GetLength(); | 228 iLen = tempStr.GetLength(); |
232 strWidth = (FX_FLOAT)multiple * 7; | 229 strWidth = (FX_FLOAT)multiple * 7; |
233 if (pOutBitmap == NULL) { | 230 if (pOutBitmap == NULL) { |
234 strWidth = strWidth * m_outputHScale; | 231 strWidth = strWidth * m_outputHScale; |
235 } | 232 } |
236 CalcTextInfo(tempStr, pCharPos, m_pFont, strWidth, iFontSize, blank); | 233 CalcTextInfo(tempStr, pCharPos, m_pFont, strWidth, iFontSize, blank); |
237 if (pOutBitmap != NULL) { | 234 if (pOutBitmap) { |
238 delete ge.GetBitmap(); | 235 delete ge.GetBitmap(); |
239 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); | 236 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); |
240 ge.GetBitmap()->Clear(m_backgroundColor); | 237 ge.GetBitmap()->Clear(m_backgroundColor); |
241 ge.DrawNormalText(iLen, pCharPos, m_pFont, | 238 ge.DrawNormalText(iLen, pCharPos, m_pFont, |
242 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, | 239 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, |
243 (CFX_Matrix*)&affine_matrix, m_fontColor, | 240 (CFX_Matrix*)&affine_matrix, m_fontColor, |
244 FXTEXT_CLEARTYPE); | 241 FXTEXT_CLEARTYPE); |
245 geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight); | 242 geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight); |
246 } else { | 243 } else { |
247 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0, | 244 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0, |
248 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); | 245 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); |
249 if (matrix != NULL) { | 246 if (matrix) { |
250 affine_matrix1.Concat(*matrix); | 247 affine_matrix1.Concat(*matrix); |
251 } | 248 } |
252 device->DrawNormalText(iLen, pCharPos, m_pFont, | 249 device->DrawNormalText(iLen, pCharPos, m_pFont, |
253 CFX_GEModule::Get()->GetFontCache(), | 250 CFX_GEModule::Get()->GetFontCache(), |
254 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, | 251 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, |
255 m_fontColor, FXTEXT_CLEARTYPE); | 252 m_fontColor, FXTEXT_CLEARTYPE); |
256 } | 253 } |
257 tempStr = str.Mid(11, 1); | 254 tempStr = str.Mid(11, 1); |
258 iLen = tempStr.GetLength(); | 255 iLen = tempStr.GetLength(); |
259 CalcTextInfo(tempStr, pCharPos + 11, m_pFont, strWidth, iFontSize, blank); | 256 CalcTextInfo(tempStr, pCharPos + 11, m_pFont, strWidth, iFontSize, blank); |
260 if (pOutBitmap != NULL) { | 257 if (pOutBitmap) { |
261 delete ge.GetBitmap(); | 258 delete ge.GetBitmap(); |
262 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); | 259 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); |
263 ge.GetBitmap()->Clear(m_backgroundColor); | 260 ge.GetBitmap()->Clear(m_backgroundColor); |
264 ge.DrawNormalText(iLen, pCharPos + 11, m_pFont, | 261 ge.DrawNormalText(iLen, pCharPos + 11, m_pFont, |
265 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, | 262 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, |
266 (CFX_Matrix*)&affine_matrix, m_fontColor, | 263 (CFX_Matrix*)&affine_matrix, m_fontColor, |
267 FXTEXT_CLEARTYPE); | 264 FXTEXT_CLEARTYPE); |
268 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 85 * multiple, | 265 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 85 * multiple, |
269 m_Height - iTextHeight); | 266 m_Height - iTextHeight); |
270 } else { | 267 } else { |
271 CFX_Matrix affine_matrix1( | 268 CFX_Matrix affine_matrix1( |
272 1.0, 0.0, 0.0, -1.0, | 269 1.0, 0.0, 0.0, -1.0, |
273 (FX_FLOAT)(leftPosition + 85 * multiple) * m_outputHScale, | 270 (FX_FLOAT)(leftPosition + 85 * multiple) * m_outputHScale, |
274 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); | 271 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); |
275 if (matrix != NULL) { | 272 if (matrix) { |
276 affine_matrix1.Concat(*matrix); | 273 affine_matrix1.Concat(*matrix); |
277 } | 274 } |
278 device->DrawNormalText(iLen, pCharPos + 11, m_pFont, | 275 device->DrawNormalText(iLen, pCharPos + 11, m_pFont, |
279 CFX_GEModule::Get()->GetFontCache(), | 276 CFX_GEModule::Get()->GetFontCache(), |
280 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, | 277 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, |
281 m_fontColor, FXTEXT_CLEARTYPE); | 278 m_fontColor, FXTEXT_CLEARTYPE); |
282 } | 279 } |
283 FX_Free(pCharPos); | 280 FX_Free(pCharPos); |
284 } | 281 } |
285 void CBC_OnedUPCAWriter::RenderResult(const CFX_WideStringC& contents, | 282 void CBC_OnedUPCAWriter::RenderResult(const CFX_WideStringC& contents, |
286 uint8_t* code, | 283 uint8_t* code, |
287 int32_t codeLength, | 284 int32_t codeLength, |
288 FX_BOOL isDevice, | 285 FX_BOOL isDevice, |
289 int32_t& e) { | 286 int32_t& e) { |
290 CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); | 287 CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); |
291 } | 288 } |
OLD | NEW |