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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 151 } |
152 } | 152 } |
153 pos += | 153 pos += |
154 AppendPattern(result, pos, CBC_OneDimReader::START_END_PATTERN, 3, 1, e); | 154 AppendPattern(result, pos, CBC_OneDimReader::START_END_PATTERN, 3, 1, e); |
155 if (e != BCExceptionNO) { | 155 if (e != BCExceptionNO) { |
156 FX_Free(result); | 156 FX_Free(result); |
157 return NULL; | 157 return NULL; |
158 } | 158 } |
159 return result; | 159 return result; |
160 } | 160 } |
| 161 |
161 void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, | 162 void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, |
162 CFX_DIBitmap* pOutBitmap, | 163 CFX_DIBitmap* pOutBitmap, |
163 CFX_RenderDevice* device, | 164 CFX_RenderDevice* device, |
164 const CFX_Matrix* matrix, | 165 const CFX_Matrix* matrix, |
165 int32_t barWidth, | 166 int32_t barWidth, |
166 int32_t multiple, | 167 int32_t multiple, |
167 int32_t& e) { | 168 int32_t& e) { |
168 if (device == NULL && pOutBitmap == NULL) { | 169 if (!device && !pOutBitmap) { |
169 e = BCExceptionIllegalArgument; | 170 e = BCExceptionIllegalArgument; |
170 return; | 171 return; |
171 } | 172 } |
| 173 |
172 int32_t leftPosition = 3 * multiple; | 174 int32_t leftPosition = 3 * multiple; |
173 CFX_ByteString str = FX_UTF8Encode(contents); | 175 CFX_ByteString str = FX_UTF8Encode(contents); |
174 int32_t iLength = str.GetLength(); | 176 int32_t iLength = str.GetLength(); |
175 FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLength); | 177 FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLength); |
176 FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLength); | 178 FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLength); |
177 CFX_ByteString tempStr = str.Mid(0, 4); | 179 CFX_ByteString tempStr = str.Mid(0, 4); |
178 int32_t iLen = tempStr.GetLength(); | 180 int32_t iLen = tempStr.GetLength(); |
179 int32_t strWidth = 7 * multiple * 4; | 181 int32_t strWidth = 7 * multiple * 4; |
180 FX_FLOAT blank = 0.0; | 182 FX_FLOAT blank = 0.0; |
181 CFX_FxgeDevice geBitmap; | 183 CFX_FxgeDevice geBitmap; |
182 if (pOutBitmap) { | 184 if (pOutBitmap) |
183 geBitmap.Attach(pOutBitmap); | 185 geBitmap.Attach(pOutBitmap, false, nullptr, false); |
184 } | 186 |
185 int32_t iFontSize = (int32_t)fabs(m_fFontSize); | 187 int32_t iFontSize = (int32_t)fabs(m_fFontSize); |
186 int32_t iTextHeight = iFontSize + 1; | 188 int32_t iTextHeight = iFontSize + 1; |
187 if (pOutBitmap == NULL) { | 189 if (!pOutBitmap) { |
188 CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); | 190 CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); |
189 CFX_FloatRect rect( | 191 CFX_FloatRect rect( |
190 (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), | 192 (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), |
191 (FX_FLOAT)(leftPosition + strWidth - 0.5), (FX_FLOAT)m_Height); | 193 (FX_FLOAT)(leftPosition + strWidth - 0.5), (FX_FLOAT)m_Height); |
192 matr.Concat(*matrix); | 194 matr.Concat(*matrix); |
193 matr.TransformRect(rect); | 195 matr.TransformRect(rect); |
194 FX_RECT re = rect.GetOutterRect(); | 196 FX_RECT re = rect.GetOutterRect(); |
195 device->FillRect(&re, m_backgroundColor); | 197 device->FillRect(&re, m_backgroundColor); |
196 CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); | 198 CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); |
197 CFX_FloatRect rect1( | 199 CFX_FloatRect rect1( |
198 (FX_FLOAT)(leftPosition + 33 * multiple), | 200 (FX_FLOAT)(leftPosition + 33 * multiple), |
199 (FX_FLOAT)(m_Height - iTextHeight), | 201 (FX_FLOAT)(m_Height - iTextHeight), |
200 (FX_FLOAT)(leftPosition + 33 * multiple + strWidth - 0.5), | 202 (FX_FLOAT)(leftPosition + 33 * multiple + strWidth - 0.5), |
201 (FX_FLOAT)m_Height); | 203 (FX_FLOAT)m_Height); |
202 matr1.Concat(*matrix); | 204 matr1.Concat(*matrix); |
203 matr1.TransformRect(rect1); | 205 matr1.TransformRect(rect1); |
204 re = rect1.GetOutterRect(); | 206 re = rect1.GetOutterRect(); |
205 device->FillRect(&re, m_backgroundColor); | 207 device->FillRect(&re, m_backgroundColor); |
206 } | 208 } |
207 if (pOutBitmap == NULL) { | 209 if (!pOutBitmap) |
208 strWidth = (int32_t)(strWidth * m_outputHScale); | 210 strWidth = (int32_t)(strWidth * m_outputHScale); |
209 } | 211 |
210 CalcTextInfo(tempStr, pCharPos, m_pFont, (FX_FLOAT)strWidth, iFontSize, | 212 CalcTextInfo(tempStr, pCharPos, m_pFont, (FX_FLOAT)strWidth, iFontSize, |
211 blank); | 213 blank); |
212 CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); | 214 CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); |
213 CFX_FxgeDevice ge; | 215 CFX_FxgeDevice ge; |
214 if (pOutBitmap) { | 216 if (pOutBitmap) { |
215 delete ge.GetBitmap(); | 217 delete ge.GetBitmap(); |
216 ge.Create(strWidth, iTextHeight, FXDIB_Argb); | 218 ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr); |
217 ge.GetBitmap()->Clear(m_backgroundColor); | 219 ge.GetBitmap()->Clear(m_backgroundColor); |
218 ge.DrawNormalText(iLen, pCharPos, m_pFont, | 220 ge.DrawNormalText(iLen, pCharPos, m_pFont, |
219 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, | 221 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, |
220 (CFX_Matrix*)&affine_matrix, m_fontColor, | 222 (CFX_Matrix*)&affine_matrix, m_fontColor, |
221 FXTEXT_CLEARTYPE); | 223 FXTEXT_CLEARTYPE); |
222 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); | 224 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); |
223 } else { | 225 } else { |
224 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, | 226 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, |
225 (FX_FLOAT)leftPosition * m_outputHScale, | 227 (FX_FLOAT)leftPosition * m_outputHScale, |
226 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); | 228 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); |
227 affine_matrix1.Concat(*matrix); | 229 affine_matrix1.Concat(*matrix); |
228 device->DrawNormalText(iLen, pCharPos, m_pFont, | 230 device->DrawNormalText(iLen, pCharPos, m_pFont, |
229 CFX_GEModule::Get()->GetFontCache(), | 231 CFX_GEModule::Get()->GetFontCache(), |
230 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, | 232 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, |
231 m_fontColor, FXTEXT_CLEARTYPE); | 233 m_fontColor, FXTEXT_CLEARTYPE); |
232 } | 234 } |
233 tempStr = str.Mid(4, 4); | 235 tempStr = str.Mid(4, 4); |
234 iLen = tempStr.GetLength(); | 236 iLen = tempStr.GetLength(); |
235 CalcTextInfo(tempStr, pCharPos + 4, m_pFont, (FX_FLOAT)strWidth, iFontSize, | 237 CalcTextInfo(tempStr, pCharPos + 4, m_pFont, (FX_FLOAT)strWidth, iFontSize, |
236 blank); | 238 blank); |
237 if (pOutBitmap) { | 239 if (pOutBitmap) { |
238 delete ge.GetBitmap(); | 240 delete ge.GetBitmap(); |
239 ge.Create(strWidth, iTextHeight, FXDIB_Argb); | 241 ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr); |
240 ge.GetBitmap()->Clear(m_backgroundColor); | 242 ge.GetBitmap()->Clear(m_backgroundColor); |
241 ge.DrawNormalText(iLen, pCharPos + 4, m_pFont, | 243 ge.DrawNormalText(iLen, pCharPos + 4, m_pFont, |
242 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, | 244 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, |
243 (CFX_Matrix*)&affine_matrix, m_fontColor, | 245 (CFX_Matrix*)&affine_matrix, m_fontColor, |
244 FXTEXT_CLEARTYPE); | 246 FXTEXT_CLEARTYPE); |
245 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 33 * multiple, | 247 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 33 * multiple, |
246 m_Height - iTextHeight); | 248 m_Height - iTextHeight); |
247 } else { | 249 } else { |
248 CFX_Matrix affine_matrix1( | 250 CFX_Matrix affine_matrix1( |
249 1.0, 0.0, 0.0, -1.0, | 251 1.0, 0.0, 0.0, -1.0, |
250 (FX_FLOAT)(leftPosition + 33 * multiple) * m_outputHScale, | 252 (FX_FLOAT)(leftPosition + 33 * multiple) * m_outputHScale, |
251 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); | 253 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); |
252 if (matrix) { | 254 if (matrix) { |
253 affine_matrix1.Concat(*matrix); | 255 affine_matrix1.Concat(*matrix); |
254 } | 256 } |
255 device->DrawNormalText(iLen, pCharPos + 4, m_pFont, | 257 device->DrawNormalText(iLen, pCharPos + 4, m_pFont, |
256 CFX_GEModule::Get()->GetFontCache(), | 258 CFX_GEModule::Get()->GetFontCache(), |
257 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, | 259 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, |
258 m_fontColor, FXTEXT_CLEARTYPE); | 260 m_fontColor, FXTEXT_CLEARTYPE); |
259 } | 261 } |
260 FX_Free(pCharPos); | 262 FX_Free(pCharPos); |
261 } | 263 } |
| 264 |
262 void CBC_OnedEAN8Writer::RenderResult(const CFX_WideStringC& contents, | 265 void CBC_OnedEAN8Writer::RenderResult(const CFX_WideStringC& contents, |
263 uint8_t* code, | 266 uint8_t* code, |
264 int32_t codeLength, | 267 int32_t codeLength, |
265 FX_BOOL isDevice, | 268 FX_BOOL isDevice, |
266 int32_t& e) { | 269 int32_t& e) { |
267 CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); | 270 CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); |
268 } | 271 } |
OLD | NEW |