| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
| 6 // Original code is licensed as follows: | |
| 7 /* | |
| 8 * Copyright 2011 ZXing authors | |
| 9 * | |
| 10 * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 11 * you may not use this file except in compliance with the License. | |
| 12 * You may obtain a copy of the License at | |
| 13 * | |
| 14 * http://www.apache.org/licenses/LICENSE-2.0 | |
| 15 * | |
| 16 * Unless required by applicable law or agreed to in writing, software | |
| 17 * distributed under the License is distributed on an "AS IS" BASIS, | |
| 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 19 * See the License for the specific language governing permissions and | |
| 20 * limitations under the License. | |
| 21 */ | |
| 22 | |
| 23 #include "barcode.h" | |
| 24 #include "include/BC_Reader.h" | |
| 25 #include "include/BC_OneDReader.h" | |
| 26 #include "include/BC_OneDimReader.h" | |
| 27 #include "include/BC_Writer.h" | |
| 28 #include "include/BC_OneDimWriter.h" | |
| 29 #include "include/BC_OnedCode39Reader.h" | |
| 30 #include "include/BC_OnedCode39Writer.h" | |
| 31 #include "include/BC_OnedCodaBarReader.h" | |
| 32 #include "include/BC_OnedCodaBarWriter.h" | |
| 33 #include "include/BC_OnedCode128Reader.h" | |
| 34 #include "include/BC_OnedCode128Writer.h" | |
| 35 #include "include/BC_OnedEAN8Reader.h" | |
| 36 #include "include/BC_OnedEAN8Writer.h" | |
| 37 #include "include/BC_OnedEAN13Reader.h" | |
| 38 #include "include/BC_OnedEAN13Writer.h" | |
| 39 #include "include/BC_OnedUPCAReader.h" | |
| 40 #include "include/BC_OnedUPCAWriter.h" | |
| 41 #include "include/BC_QRCodeReader.h" | |
| 42 #include "include/BC_QRCodeWriter.h" | |
| 43 #include "include/BC_PDF417Compaction.h" | |
| 44 #include "include/BC_PDF417.h" | |
| 45 #include "include/BC_PDF417Writer.h" | |
| 46 #include "include/BC_DataMatrixReader.h" | |
| 47 #include "include/BC_DataMatrixWriter.h" | |
| 48 #include "include/BC_LuminanceSource.h" | |
| 49 #include "include/BC_BufferedImageLuminanceSource.h" | |
| 50 #include "include/BC_Binarizer.h" | |
| 51 #include "include/BC_GlobalHistogramBinarizer.h" | |
| 52 #include "include/BC_BinaryBitmap.h" | |
| 53 #include "include/BC_UtilCodingConvert.h" | |
| 54 #include "include/BC_PDF417HighLevelEncoder.h" | |
| 55 #include "include/BC_ResultPoint.h" | |
| 56 #include "include/BC_PDF417DetectorResult.h" | |
| 57 #include "include/BC_BinaryBitmap.h" | |
| 58 #include "include/BC_CommonBitMatrix.h" | |
| 59 #include "include/BC_CommonBitArray.h" | |
| 60 #include "include/BC_PDF417Detector.h" | |
| 61 #include "include/BC_PDF417DetectorResult.h" | |
| 62 #include "include/BC_DecoderResult.h" | |
| 63 #include "include/BC_PDF417Codeword.h" | |
| 64 #include "include/BC_CommonBitMatrix.h" | |
| 65 #include "include/BC_PDF417Common.h" | |
| 66 #include "include/BC_PDF417BarcodeValue.h" | |
| 67 #include "include/BC_PDF417BarcodeMetadata.h" | |
| 68 #include "include/BC_PDF417BoundingBox.h" | |
| 69 #include "include/BC_PDF417DetectionResultColumn.h" | |
| 70 #include "include/BC_PDF417DetectionResultRowIndicatorColumn.h" | |
| 71 #include "include/BC_PDF417DetectionResult.h" | |
| 72 #include "include/BC_PDF417DecodedBitStreamParser.h" | |
| 73 #include "include/BC_PDF417CodewordDecoder.h" | |
| 74 #include "include/BC_PDF417DecodedBitStreamParser.h" | |
| 75 #include "include/BC_PDF417ECModulusPoly.h" | |
| 76 #include "include/BC_PDF417ECModulusGF.h" | |
| 77 #include "include/BC_PDF417ECErrorCorrection.h" | |
| 78 #include "include/BC_PDF417DecodedBitStreamParser.h" | |
| 79 #include "include/BC_CommonDecoderResult.h" | |
| 80 #include "include/BC_PDF417ScanningDecoder.h" | |
| 81 #include "include/BC_PDF417Reader.h" | |
| 82 CBC_CodeBase :: CBC_CodeBase() | |
| 83 { | |
| 84 } | |
| 85 CBC_CodeBase :: ~CBC_CodeBase() | |
| 86 { | |
| 87 } | |
| 88 FX_BOOL CBC_CodeBase::SetCharEncoding(FX_INT32 encoding) | |
| 89 { | |
| 90 if (m_pBCWriter) { | |
| 91 return m_pBCWriter->SetCharEncoding(encoding); | |
| 92 } | |
| 93 return FALSE; | |
| 94 } | |
| 95 FX_BOOL CBC_CodeBase::SetModuleHeight(FX_INT32 moduleHeight) | |
| 96 { | |
| 97 if (m_pBCWriter) { | |
| 98 return m_pBCWriter->SetModuleHeight(moduleHeight); | |
| 99 } | |
| 100 return FALSE; | |
| 101 } | |
| 102 FX_BOOL CBC_CodeBase::SetModuleWidth(FX_INT32 moduleWidth) | |
| 103 { | |
| 104 if (m_pBCWriter) { | |
| 105 return m_pBCWriter->SetModuleWidth(moduleWidth); | |
| 106 } | |
| 107 return FALSE; | |
| 108 } | |
| 109 FX_BOOL CBC_CodeBase::SetHeight(FX_INT32 height) | |
| 110 { | |
| 111 if (m_pBCWriter) { | |
| 112 return m_pBCWriter->SetHeight(height); | |
| 113 } | |
| 114 return FALSE; | |
| 115 } | |
| 116 FX_BOOL CBC_CodeBase::SetWidth(FX_INT32 width) | |
| 117 { | |
| 118 if (m_pBCWriter) { | |
| 119 return m_pBCWriter->SetWidth(width); | |
| 120 } | |
| 121 return FALSE; | |
| 122 } | |
| 123 void CBC_CodeBase::SetBackgroundColor(FX_ARGB backgroundColor) | |
| 124 { | |
| 125 if (m_pBCWriter) { | |
| 126 m_pBCWriter->SetBackgroundColor(backgroundColor); | |
| 127 } | |
| 128 } | |
| 129 void CBC_CodeBase::SetBarcodeColor(FX_ARGB foregroundColor) | |
| 130 { | |
| 131 if (m_pBCWriter) { | |
| 132 m_pBCWriter->SetBarcodeColor(foregroundColor); | |
| 133 } | |
| 134 } | |
| 135 CBC_OneCode::CBC_OneCode() | |
| 136 { | |
| 137 }; | |
| 138 CBC_OneCode::~CBC_OneCode() | |
| 139 { | |
| 140 } | |
| 141 FX_BOOL CBC_OneCode::CheckContentValidity(FX_WSTR contents) | |
| 142 { | |
| 143 if (m_pBCWriter) { | |
| 144 return ((CBC_OneDimWriter*)m_pBCWriter)->CheckContentValidity(contents); | |
| 145 } | |
| 146 return FALSE; | |
| 147 } | |
| 148 CFX_WideString CBC_OneCode::FilterContents(FX_WSTR contents) | |
| 149 { | |
| 150 CFX_WideString tmp; | |
| 151 if (m_pBCWriter == NULL) { | |
| 152 return tmp; | |
| 153 } | |
| 154 return ((CBC_OneDimWriter*)m_pBCWriter)->FilterContents(contents); | |
| 155 } | |
| 156 void CBC_OneCode::SetPrintChecksum(FX_BOOL checksum) | |
| 157 { | |
| 158 if (m_pBCWriter) { | |
| 159 ((CBC_OneDimWriter*)m_pBCWriter)->SetPrintChecksum(checksum); | |
| 160 } | |
| 161 } | |
| 162 void CBC_OneCode::SetDataLength(FX_INT32 length) | |
| 163 { | |
| 164 if (m_pBCWriter) { | |
| 165 ((CBC_OneDimWriter*)m_pBCWriter)->SetDataLength(length); | |
| 166 } | |
| 167 } | |
| 168 void CBC_OneCode::SetCalChecksum(FX_BOOL calc) | |
| 169 { | |
| 170 if (m_pBCWriter) { | |
| 171 ((CBC_OneDimWriter*)m_pBCWriter)->SetCalcChecksum(calc); | |
| 172 } | |
| 173 } | |
| 174 FX_BOOL CBC_OneCode::SetFont(CFX_Font* cFont) | |
| 175 { | |
| 176 if (m_pBCWriter) { | |
| 177 return ((CBC_OneDimWriter*)m_pBCWriter)->SetFont(cFont); | |
| 178 } | |
| 179 return FALSE; | |
| 180 } | |
| 181 void CBC_OneCode::SetFontSize(FX_FLOAT size) | |
| 182 { | |
| 183 if (m_pBCWriter) { | |
| 184 ((CBC_OneDimWriter*)m_pBCWriter)->SetFontSize(size); | |
| 185 } | |
| 186 } | |
| 187 void CBC_OneCode::SetFontStyle(FX_INT32 style) | |
| 188 { | |
| 189 if (m_pBCWriter) { | |
| 190 ((CBC_OneDimWriter*)m_pBCWriter)->SetFontStyle(style); | |
| 191 } | |
| 192 } | |
| 193 void CBC_OneCode::SetFontColor(FX_ARGB color) | |
| 194 { | |
| 195 if (m_pBCWriter) { | |
| 196 ((CBC_OneDimWriter*)m_pBCWriter)->SetFontColor(color); | |
| 197 } | |
| 198 } | |
| 199 CBC_Code39::CBC_Code39() | |
| 200 { | |
| 201 m_pBCReader = (CBC_Reader*) FX_NEW (CBC_OnedCode39Reader); | |
| 202 m_pBCWriter = (CBC_Writer*) FX_NEW (CBC_OnedCode39Writer); | |
| 203 } | |
| 204 CBC_Code39::CBC_Code39(FX_BOOL usingCheckDigit) | |
| 205 { | |
| 206 m_pBCReader = (CBC_Reader*) FX_NEW CBC_OnedCode39Reader(usingCheckDigit); | |
| 207 m_pBCWriter = (CBC_Writer*) FX_NEW CBC_OnedCode39Writer; | |
| 208 } | |
| 209 CBC_Code39::CBC_Code39(FX_BOOL usingCheckDigit, FX_BOOL extendedMode) | |
| 210 { | |
| 211 m_pBCReader = (CBC_Reader*) FX_NEW CBC_OnedCode39Reader(usingCheckDigit, ext
endedMode); | |
| 212 m_pBCWriter = (CBC_Writer*) FX_NEW CBC_OnedCode39Writer(extendedMode); | |
| 213 } | |
| 214 CBC_Code39::~CBC_Code39() | |
| 215 { | |
| 216 if(m_pBCReader) { | |
| 217 delete(m_pBCReader); | |
| 218 m_pBCReader = NULL; | |
| 219 } | |
| 220 if(m_pBCWriter) { | |
| 221 delete(m_pBCWriter); | |
| 222 m_pBCWriter = NULL; | |
| 223 } | |
| 224 } | |
| 225 FX_BOOL CBC_Code39::Encode(FX_WSTR contents, FX_BOOL isDevice, FX_INT32 &e) | |
| 226 { | |
| 227 if(contents.IsEmpty()) { | |
| 228 e = BCExceptionNoContents; | |
| 229 return FALSE; | |
| 230 } | |
| 231 BCFORMAT format = BCFORMAT_CODE_39; | |
| 232 FX_INT32 outWidth = 0; | |
| 233 FX_INT32 outHeight = 0; | |
| 234 CFX_WideString filtercontents = ((CBC_OnedCode39Writer*)m_pBCWriter)->Filter
Contents(contents); | |
| 235 CFX_WideString renderContents = ((CBC_OnedCode39Writer*)m_pBCWriter)->Render
TextContents(contents); | |
| 236 m_renderContents = renderContents; | |
| 237 CFX_ByteString byteString = filtercontents.UTF8Encode(); | |
| 238 FX_BYTE *data = m_pBCWriter->Encode(byteString, format, outWidth, outHeight,
e); | |
| 239 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 240 ((CBC_OneDimWriter*)m_pBCWriter)->RenderResult(renderContents, data, outWidt
h, isDevice, e); | |
| 241 FX_Free(data); | |
| 242 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 243 return TRUE; | |
| 244 } | |
| 245 FX_BOOL CBC_Code39::RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* mat
irx, FX_INT32 &e) | |
| 246 { | |
| 247 CFX_WideString renderCon = ((CBC_OnedCode39Writer*)m_pBCWriter)->encodedCont
ents(m_renderContents, e); | |
| 248 ((CBC_OneDimWriter*)m_pBCWriter)->RenderDeviceResult(device, matirx, renderC
on, e); | |
| 249 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 250 return TRUE; | |
| 251 } | |
| 252 FX_BOOL CBC_Code39::RenderBitmap(CFX_DIBitmap *&pOutBitmap, FX_INT32 &e) | |
| 253 { | |
| 254 CFX_WideString renderCon = ((CBC_OnedCode39Writer*)m_pBCWriter)->encodedCont
ents(m_renderContents, e); | |
| 255 ((CBC_OneDimWriter*)m_pBCWriter)->RenderBitmapResult(pOutBitmap, renderCon,
e); | |
| 256 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 257 return TRUE; | |
| 258 } | |
| 259 CFX_WideString CBC_Code39::Decode(FX_BYTE* buf, FX_INT32 width, FX_INT32 hight,
FX_INT32 &e) | |
| 260 { | |
| 261 CFX_WideString str; | |
| 262 return str; | |
| 263 } | |
| 264 CFX_WideString CBC_Code39::Decode(CFX_DIBitmap *pBitmap, FX_INT32 &e) | |
| 265 { | |
| 266 CBC_BufferedImageLuminanceSource source(pBitmap); | |
| 267 CBC_GlobalHistogramBinarizer binarizer(&source); | |
| 268 CBC_BinaryBitmap bitmap(&binarizer); | |
| 269 CFX_ByteString str = m_pBCReader->Decode(&bitmap, 0, e); | |
| 270 BC_EXCEPTION_CHECK_ReturnValue(e, FX_WSTRC(L"")); | |
| 271 return CFX_WideString::FromUTF8(str, str.GetLength()); | |
| 272 } | |
| 273 FX_BOOL CBC_Code39::SetTextLocation(BC_TEXT_LOC location) | |
| 274 { | |
| 275 if (m_pBCWriter) { | |
| 276 return ((CBC_OnedCode39Writer*)m_pBCWriter)->SetTextLocation(location); | |
| 277 } | |
| 278 return FALSE; | |
| 279 } | |
| 280 FX_BOOL CBC_Code39::SetWideNarrowRatio(FX_INT32 ratio) | |
| 281 { | |
| 282 if (m_pBCWriter) { | |
| 283 return ((CBC_OnedCode39Writer*)m_pBCWriter)->SetWideNarrowRatio(ratio); | |
| 284 } | |
| 285 return FALSE; | |
| 286 } | |
| 287 CBC_Codabar::CBC_Codabar() | |
| 288 { | |
| 289 m_pBCReader = (CBC_Reader*) FX_NEW (CBC_OnedCodaBarReader); | |
| 290 m_pBCWriter = (CBC_Writer*) FX_NEW (CBC_OnedCodaBarWriter); | |
| 291 } | |
| 292 CBC_Codabar::~CBC_Codabar() | |
| 293 { | |
| 294 if(m_pBCReader) { | |
| 295 delete(m_pBCReader); | |
| 296 m_pBCReader = NULL; | |
| 297 } | |
| 298 if(m_pBCWriter) { | |
| 299 delete(m_pBCWriter); | |
| 300 m_pBCWriter = NULL; | |
| 301 } | |
| 302 } | |
| 303 FX_BOOL CBC_Codabar::SetStartChar(FX_CHAR start) | |
| 304 { | |
| 305 if (m_pBCWriter) { | |
| 306 return ((CBC_OnedCodaBarWriter*)m_pBCWriter)->SetStartChar(start); | |
| 307 } | |
| 308 return FALSE; | |
| 309 } | |
| 310 FX_BOOL CBC_Codabar::SetEndChar(FX_CHAR end) | |
| 311 { | |
| 312 if (m_pBCWriter) { | |
| 313 return ((CBC_OnedCodaBarWriter*)m_pBCWriter)->SetEndChar(end); | |
| 314 } | |
| 315 return FALSE; | |
| 316 } | |
| 317 FX_BOOL CBC_Codabar::SetTextLocation(BC_TEXT_LOC location) | |
| 318 { | |
| 319 return ((CBC_OnedCodaBarWriter*) m_pBCWriter)->SetTextLocation(location); | |
| 320 } | |
| 321 FX_BOOL CBC_Codabar::SetWideNarrowRatio(FX_INT32 ratio) | |
| 322 { | |
| 323 if (m_pBCWriter) { | |
| 324 return ((CBC_OnedCodaBarWriter*) m_pBCWriter)->SetWideNarrowRatio(ratio)
; | |
| 325 } | |
| 326 return FALSE; | |
| 327 } | |
| 328 FX_BOOL CBC_Codabar::Encode(FX_WSTR contents, FX_BOOL isDevice, FX_INT32 &e) | |
| 329 { | |
| 330 if(contents.IsEmpty()) { | |
| 331 e = BCExceptionNoContents; | |
| 332 return FALSE; | |
| 333 } | |
| 334 BCFORMAT format = BCFORMAT_CODABAR; | |
| 335 FX_INT32 outWidth = 0; | |
| 336 FX_INT32 outHeight = 0; | |
| 337 CFX_WideString filtercontents = ((CBC_OneDimWriter*)m_pBCWriter)->FilterCont
ents(contents); | |
| 338 CFX_ByteString byteString = filtercontents.UTF8Encode(); | |
| 339 m_renderContents = filtercontents; | |
| 340 FX_BYTE *data = m_pBCWriter->Encode(byteString, format, outWidth, outHeight,
e); | |
| 341 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 342 ((CBC_OneDimWriter*)m_pBCWriter)->RenderResult(filtercontents, data, outWidt
h, isDevice, e); | |
| 343 FX_Free(data); | |
| 344 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 345 return TRUE; | |
| 346 } | |
| 347 FX_BOOL CBC_Codabar::RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* ma
tirx, FX_INT32 &e) | |
| 348 { | |
| 349 CFX_WideString renderCon = ((CBC_OnedCodaBarWriter*)m_pBCWriter)->encodedCon
tents(m_renderContents); | |
| 350 ((CBC_OneDimWriter*)m_pBCWriter)->RenderDeviceResult(device, matirx, renderC
on, e); | |
| 351 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 352 return TRUE; | |
| 353 } | |
| 354 FX_BOOL CBC_Codabar::RenderBitmap(CFX_DIBitmap *&pOutBitmap, FX_INT32 &e) | |
| 355 { | |
| 356 CFX_WideString renderCon = ((CBC_OnedCodaBarWriter*)m_pBCWriter)->encodedCon
tents(m_renderContents); | |
| 357 ((CBC_OneDimWriter*)m_pBCWriter)->RenderBitmapResult(pOutBitmap, renderCon,
e); | |
| 358 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 359 return TRUE; | |
| 360 } | |
| 361 CFX_WideString CBC_Codabar::Decode(FX_BYTE* buf, FX_INT32 width, FX_INT32 hight,
FX_INT32 &e) | |
| 362 { | |
| 363 CFX_WideString str; | |
| 364 return str; | |
| 365 } | |
| 366 CFX_WideString CBC_Codabar::Decode(CFX_DIBitmap *pBitmap, FX_INT32 &e) | |
| 367 { | |
| 368 CBC_BufferedImageLuminanceSource source(pBitmap); | |
| 369 CBC_GlobalHistogramBinarizer binarizer(&source); | |
| 370 CBC_BinaryBitmap bitmap(&binarizer); | |
| 371 CFX_ByteString str = m_pBCReader->Decode(&bitmap, 0, e); | |
| 372 BC_EXCEPTION_CHECK_ReturnValue(e, FX_WSTRC(L"")); | |
| 373 return CFX_WideString::FromUTF8(str, str.GetLength()); | |
| 374 } | |
| 375 CBC_Code128::CBC_Code128(BC_TYPE type) | |
| 376 { | |
| 377 m_pBCReader = (CBC_Reader *) FX_NEW (CBC_OnedCode128Reader); | |
| 378 m_pBCWriter = (CBC_Writer *) FX_NEW CBC_OnedCode128Writer(type); | |
| 379 } | |
| 380 CBC_Code128::~CBC_Code128() | |
| 381 { | |
| 382 if(m_pBCReader) { | |
| 383 delete(m_pBCReader); | |
| 384 m_pBCReader = NULL; | |
| 385 } | |
| 386 if(m_pBCWriter) { | |
| 387 delete(m_pBCWriter); | |
| 388 m_pBCWriter = NULL; | |
| 389 } | |
| 390 } | |
| 391 FX_BOOL CBC_Code128::SetTextLocation(BC_TEXT_LOC location) | |
| 392 { | |
| 393 if (m_pBCWriter) { | |
| 394 return (( CBC_OnedCode128Writer*)m_pBCWriter)->SetTextLocation(location)
; | |
| 395 } | |
| 396 return FALSE; | |
| 397 } | |
| 398 FX_BOOL CBC_Code128::Encode(FX_WSTR contents, FX_BOOL isDevice, FX_INT32 &e) | |
| 399 { | |
| 400 if(contents.IsEmpty()) { | |
| 401 e = BCExceptionNoContents; | |
| 402 return FALSE; | |
| 403 } | |
| 404 BCFORMAT format = BCFORMAT_CODE_128; | |
| 405 FX_INT32 outWidth = 0; | |
| 406 FX_INT32 outHeight = 0; | |
| 407 CFX_WideString content = contents; | |
| 408 if (contents.GetLength() % 2 && ((CBC_OnedCode128Writer *)m_pBCWriter)->GetT
ype() == BC_CODE128_C) { | |
| 409 content += '0'; | |
| 410 } | |
| 411 CFX_WideString encodeContents = ((CBC_OnedCode128Writer*)m_pBCWriter)->Filte
rContents(content); | |
| 412 m_renderContents = encodeContents; | |
| 413 CFX_ByteString byteString = encodeContents.UTF8Encode(); | |
| 414 FX_BYTE *data = m_pBCWriter->Encode(byteString, format, outWidth, outHeight,
e); | |
| 415 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 416 ((CBC_OneDimWriter*)m_pBCWriter)->RenderResult(encodeContents, data, outWidt
h, isDevice, e); | |
| 417 FX_Free(data); | |
| 418 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 419 return TRUE; | |
| 420 } | |
| 421 FX_BOOL CBC_Code128::RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* ma
tirx, FX_INT32 &e) | |
| 422 { | |
| 423 ((CBC_OneDimWriter*)m_pBCWriter)->RenderDeviceResult(device, matirx, m_rende
rContents, e); | |
| 424 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 425 return TRUE; | |
| 426 } | |
| 427 FX_BOOL CBC_Code128::RenderBitmap(CFX_DIBitmap *&pOutBitmap, FX_INT32 &e) | |
| 428 { | |
| 429 ((CBC_OneDimWriter*)m_pBCWriter)->RenderBitmapResult(pOutBitmap, m_renderCon
tents, e); | |
| 430 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 431 return TRUE; | |
| 432 } | |
| 433 CFX_WideString CBC_Code128::Decode(FX_BYTE* buf, FX_INT32 width, FX_INT32 hight,
FX_INT32 &e) | |
| 434 { | |
| 435 CFX_WideString str; | |
| 436 return str; | |
| 437 } | |
| 438 CFX_WideString CBC_Code128::Decode(CFX_DIBitmap *pBitmap, FX_INT32 &e) | |
| 439 { | |
| 440 CBC_BufferedImageLuminanceSource source(pBitmap); | |
| 441 CBC_GlobalHistogramBinarizer binarizer(&source); | |
| 442 CBC_BinaryBitmap bitmap(&binarizer); | |
| 443 CFX_ByteString str = m_pBCReader->Decode(&bitmap, 0, e); | |
| 444 BC_EXCEPTION_CHECK_ReturnValue(e, FX_WSTRC(L"")); | |
| 445 return CFX_WideString::FromUTF8(str, str.GetLength()); | |
| 446 } | |
| 447 CBC_EAN8::CBC_EAN8() | |
| 448 { | |
| 449 m_pBCReader = (CBC_Reader*) FX_NEW (CBC_OnedEAN8Reader); | |
| 450 m_pBCWriter = (CBC_Writer*) FX_NEW (CBC_OnedEAN8Writer); | |
| 451 } | |
| 452 CBC_EAN8::~CBC_EAN8() | |
| 453 { | |
| 454 if(m_pBCReader) { | |
| 455 delete(m_pBCReader); | |
| 456 m_pBCReader = NULL; | |
| 457 } | |
| 458 if(m_pBCWriter) { | |
| 459 delete(m_pBCWriter); | |
| 460 m_pBCWriter = NULL; | |
| 461 } | |
| 462 } | |
| 463 CFX_WideString CBC_EAN8::Preprocess(FX_WSTR contents) | |
| 464 { | |
| 465 CFX_WideString encodeContents = ((CBC_OnedEAN8Writer*)m_pBCWriter)->FilterCo
ntents(contents); | |
| 466 FX_INT32 length = encodeContents.GetLength(); | |
| 467 if (length <= 7) { | |
| 468 for (FX_INT32 i = 0; i < 7 - length; i++) { | |
| 469 encodeContents = FX_WCHAR('0') + encodeContents; | |
| 470 } | |
| 471 CFX_ByteString byteString = encodeContents.UTF8Encode(); | |
| 472 FX_INT32 checksum = ((CBC_OnedEAN8Writer *)m_pBCWriter)->CalcChecksum(by
teString); | |
| 473 encodeContents += FX_WCHAR(checksum - 0 + '0'); | |
| 474 } | |
| 475 if (length > 8) { | |
| 476 encodeContents = encodeContents.Mid(0, 8); | |
| 477 } | |
| 478 return encodeContents; | |
| 479 } | |
| 480 FX_BOOL CBC_EAN8::Encode(FX_WSTR contents, FX_BOOL isDevice, FX_INT32 &e) | |
| 481 { | |
| 482 if(contents.IsEmpty()) { | |
| 483 e = BCExceptionNoContents; | |
| 484 return FALSE; | |
| 485 } | |
| 486 BCFORMAT format = BCFORMAT_EAN_8; | |
| 487 FX_INT32 outWidth = 0; | |
| 488 FX_INT32 outHeight = 0; | |
| 489 CFX_WideString encodeContents = Preprocess(contents); | |
| 490 CFX_ByteString byteString = encodeContents.UTF8Encode(); | |
| 491 m_renderContents = encodeContents; | |
| 492 FX_BYTE *data = m_pBCWriter->Encode(byteString, format, outWidth, outHeight,
e); | |
| 493 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 494 ((CBC_OneDimWriter*)m_pBCWriter)->RenderResult(encodeContents, data, outWidt
h, isDevice, e); | |
| 495 FX_Free(data); | |
| 496 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 497 return TRUE; | |
| 498 } | |
| 499 FX_BOOL CBC_EAN8::RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matir
x, FX_INT32 &e) | |
| 500 { | |
| 501 ((CBC_OneDimWriter*)m_pBCWriter)->RenderDeviceResult(device, matirx, m_rende
rContents, e); | |
| 502 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 503 return TRUE; | |
| 504 } | |
| 505 FX_BOOL CBC_EAN8::RenderBitmap(CFX_DIBitmap *&pOutBitmap, FX_INT32 &e) | |
| 506 { | |
| 507 ((CBC_OneDimWriter*)m_pBCWriter)->RenderBitmapResult(pOutBitmap, m_renderCon
tents, e); | |
| 508 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 509 return TRUE; | |
| 510 } | |
| 511 CFX_WideString CBC_EAN8::Decode(FX_BYTE* buf, FX_INT32 width, FX_INT32 hight, FX
_INT32 &e) | |
| 512 { | |
| 513 CFX_WideString str; | |
| 514 return str; | |
| 515 } | |
| 516 CFX_WideString CBC_EAN8::Decode(CFX_DIBitmap *pBitmap, FX_INT32 &e) | |
| 517 { | |
| 518 CBC_BufferedImageLuminanceSource source(pBitmap); | |
| 519 CBC_GlobalHistogramBinarizer binarizer(&source); | |
| 520 CBC_BinaryBitmap bitmap(&binarizer); | |
| 521 CFX_ByteString str = m_pBCReader->Decode(&bitmap, 0, e); | |
| 522 BC_EXCEPTION_CHECK_ReturnValue(e, FX_WSTRC(L"")); | |
| 523 return CFX_WideString::FromUTF8(str, str.GetLength()); | |
| 524 } | |
| 525 CBC_EAN13::CBC_EAN13() | |
| 526 { | |
| 527 m_pBCReader = (CBC_Reader*) FX_NEW (CBC_OnedEAN13Reader); | |
| 528 m_pBCWriter = (CBC_Writer*) FX_NEW (CBC_OnedEAN13Writer); | |
| 529 } | |
| 530 CBC_EAN13::~CBC_EAN13() | |
| 531 { | |
| 532 if(m_pBCReader) { | |
| 533 delete(m_pBCReader); | |
| 534 m_pBCReader = NULL; | |
| 535 } | |
| 536 if(m_pBCWriter) { | |
| 537 delete(m_pBCWriter); | |
| 538 m_pBCWriter = NULL; | |
| 539 } | |
| 540 } | |
| 541 CFX_WideString CBC_EAN13::Preprocess(FX_WSTR contents) | |
| 542 { | |
| 543 CFX_WideString encodeContents = ((CBC_OnedEAN8Writer*)m_pBCWriter)->FilterCo
ntents(contents); | |
| 544 FX_INT32 length = encodeContents.GetLength(); | |
| 545 if (length <= 12) { | |
| 546 for (FX_INT32 i = 0; i < 12 - length; i++) { | |
| 547 encodeContents = FX_WCHAR('0') + encodeContents; | |
| 548 } | |
| 549 CFX_ByteString byteString = encodeContents.UTF8Encode(); | |
| 550 FX_INT32 checksum = ((CBC_OnedEAN13Writer *)m_pBCWriter)->CalcChecksum(b
yteString); | |
| 551 byteString += checksum - 0 + '0'; | |
| 552 encodeContents = byteString.UTF8Decode(); | |
| 553 } | |
| 554 if (length > 13) { | |
| 555 encodeContents = encodeContents.Mid(0, 13); | |
| 556 } | |
| 557 return encodeContents; | |
| 558 } | |
| 559 FX_BOOL CBC_EAN13::Encode(FX_WSTR contents, FX_BOOL isDevice, FX_INT32 &e) | |
| 560 { | |
| 561 if(contents.IsEmpty()) { | |
| 562 e = BCExceptionNoContents; | |
| 563 return FALSE; | |
| 564 } | |
| 565 BCFORMAT format = BCFORMAT_EAN_13; | |
| 566 FX_INT32 outWidth = 0; | |
| 567 FX_INT32 outHeight = 0; | |
| 568 CFX_WideString encodeContents = Preprocess(contents); | |
| 569 CFX_ByteString byteString = encodeContents.UTF8Encode(); | |
| 570 m_renderContents = encodeContents; | |
| 571 FX_BYTE *data = m_pBCWriter->Encode(byteString, format, outWidth, outHeight,
e); | |
| 572 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 573 ((CBC_OneDimWriter*)m_pBCWriter)->RenderResult(encodeContents, data, outWidt
h, isDevice, e); | |
| 574 FX_Free(data); | |
| 575 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 576 return TRUE; | |
| 577 } | |
| 578 FX_BOOL CBC_EAN13::RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* mati
rx, FX_INT32 &e) | |
| 579 { | |
| 580 ((CBC_OneDimWriter*)m_pBCWriter)->RenderDeviceResult(device, matirx, m_rende
rContents, e); | |
| 581 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 582 return TRUE; | |
| 583 } | |
| 584 FX_BOOL CBC_EAN13::RenderBitmap(CFX_DIBitmap *&pOutBitmap, FX_INT32 &e) | |
| 585 { | |
| 586 ((CBC_OneDimWriter*)m_pBCWriter)->RenderBitmapResult(pOutBitmap, m_renderCon
tents, e); | |
| 587 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 588 return TRUE; | |
| 589 } | |
| 590 CFX_WideString CBC_EAN13::Decode(FX_BYTE* buf, FX_INT32 width, FX_INT32 hight, F
X_INT32 &e) | |
| 591 { | |
| 592 CFX_WideString str; | |
| 593 return str; | |
| 594 } | |
| 595 CFX_WideString CBC_EAN13::Decode(CFX_DIBitmap *pBitmap, FX_INT32 &e) | |
| 596 { | |
| 597 CBC_BufferedImageLuminanceSource source(pBitmap); | |
| 598 CBC_GlobalHistogramBinarizer binarizer(&source); | |
| 599 CBC_BinaryBitmap bitmap(&binarizer); | |
| 600 CFX_ByteString str = m_pBCReader->Decode(&bitmap, 0, e); | |
| 601 BC_EXCEPTION_CHECK_ReturnValue(e, FX_WSTRC(L"")); | |
| 602 return CFX_WideString::FromUTF8(str, str.GetLength()); | |
| 603 } | |
| 604 CBC_UPCA::CBC_UPCA() | |
| 605 { | |
| 606 m_pBCReader = (CBC_Reader*) FX_NEW (CBC_OnedUPCAReader); | |
| 607 ((CBC_OnedUPCAReader *)m_pBCReader)->Init(); | |
| 608 m_pBCWriter = (CBC_Writer*) FX_NEW (CBC_OnedUPCAWriter); | |
| 609 } | |
| 610 CBC_UPCA::~CBC_UPCA() | |
| 611 { | |
| 612 if(m_pBCReader) { | |
| 613 delete(m_pBCReader); | |
| 614 m_pBCReader = NULL; | |
| 615 } | |
| 616 if(m_pBCWriter) { | |
| 617 delete(m_pBCWriter); | |
| 618 m_pBCWriter = NULL; | |
| 619 } | |
| 620 } | |
| 621 CFX_WideString CBC_UPCA::Preprocess(FX_WSTR contents) | |
| 622 { | |
| 623 CFX_WideString encodeContents = ((CBC_OnedEAN8Writer*)m_pBCWriter)->FilterCo
ntents(contents); | |
| 624 FX_INT32 length = encodeContents.GetLength(); | |
| 625 if (length <= 11) { | |
| 626 for (FX_INT32 i = 0; i < 11 - length; i++) { | |
| 627 encodeContents = FX_WCHAR('0') + encodeContents; | |
| 628 } | |
| 629 CFX_ByteString byteString = encodeContents.UTF8Encode(); | |
| 630 FX_INT32 checksum = ((CBC_OnedUPCAWriter *)m_pBCWriter)->CalcChecksum(by
teString); | |
| 631 byteString += checksum - 0 + '0'; | |
| 632 encodeContents = byteString.UTF8Decode(); | |
| 633 } | |
| 634 if (length > 12) { | |
| 635 encodeContents = encodeContents.Mid(0, 12); | |
| 636 } | |
| 637 return encodeContents; | |
| 638 } | |
| 639 FX_BOOL CBC_UPCA::Encode(FX_WSTR contents, FX_BOOL isDevice, FX_INT32 &e) | |
| 640 { | |
| 641 if(contents.IsEmpty()) { | |
| 642 e = BCExceptionNoContents; | |
| 643 return FALSE; | |
| 644 } | |
| 645 BCFORMAT format = BCFORMAT_UPC_A; | |
| 646 FX_INT32 outWidth = 0; | |
| 647 FX_INT32 outHeight = 0; | |
| 648 CFX_WideString encodeContents = Preprocess(contents); | |
| 649 CFX_ByteString byteString = encodeContents.UTF8Encode(); | |
| 650 m_renderContents = encodeContents; | |
| 651 ((CBC_OnedUPCAWriter*)m_pBCWriter)->Init(); | |
| 652 FX_BYTE *data = m_pBCWriter->Encode(byteString, format, outWidth, outHeight,
e); | |
| 653 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 654 ((CBC_OneDimWriter*)m_pBCWriter)->RenderResult(encodeContents, data, outWidt
h, isDevice, e); | |
| 655 FX_Free(data); | |
| 656 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 657 return TRUE; | |
| 658 } | |
| 659 FX_BOOL CBC_UPCA::RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matir
x, FX_INT32 &e) | |
| 660 { | |
| 661 ((CBC_OneDimWriter*)m_pBCWriter)->RenderDeviceResult(device, matirx, m_rende
rContents, e); | |
| 662 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 663 return TRUE; | |
| 664 } | |
| 665 FX_BOOL CBC_UPCA::RenderBitmap(CFX_DIBitmap *&pOutBitmap, FX_INT32 &e) | |
| 666 { | |
| 667 ((CBC_OneDimWriter*)m_pBCWriter)->RenderBitmapResult(pOutBitmap, m_renderCon
tents, e); | |
| 668 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 669 return TRUE; | |
| 670 } | |
| 671 CFX_WideString CBC_UPCA::Decode(FX_BYTE* buf, FX_INT32 width, FX_INT32 hight, FX
_INT32 &e) | |
| 672 { | |
| 673 CFX_WideString str; | |
| 674 return str; | |
| 675 } | |
| 676 CFX_WideString CBC_UPCA::Decode(CFX_DIBitmap *pBitmap, FX_INT32 &e) | |
| 677 { | |
| 678 CBC_BufferedImageLuminanceSource source(pBitmap); | |
| 679 CBC_GlobalHistogramBinarizer binarizer(&source); | |
| 680 CBC_BinaryBitmap bitmap(&binarizer); | |
| 681 CFX_ByteString str = m_pBCReader->Decode(&bitmap, 0, e); | |
| 682 BC_EXCEPTION_CHECK_ReturnValue(e, FX_WSTRC(L"")); | |
| 683 return CFX_WideString::FromUTF8(str, str.GetLength()); | |
| 684 } | |
| 685 CBC_QRCode::CBC_QRCode() | |
| 686 { | |
| 687 m_pBCReader = (CBC_Reader *) FX_NEW (CBC_QRCodeReader); | |
| 688 ((CBC_QRCodeReader*)m_pBCReader)->Init(); | |
| 689 m_pBCWriter = (CBC_Writer *) FX_NEW (CBC_QRCodeWriter); | |
| 690 } | |
| 691 CBC_QRCode ::~CBC_QRCode() | |
| 692 { | |
| 693 if(m_pBCReader) { | |
| 694 delete(m_pBCReader); | |
| 695 m_pBCReader = NULL; | |
| 696 } | |
| 697 if(m_pBCWriter) { | |
| 698 delete(m_pBCWriter); | |
| 699 m_pBCWriter = NULL; | |
| 700 } | |
| 701 } | |
| 702 FX_BOOL CBC_QRCode::SetVersion(FX_INT32 version) | |
| 703 { | |
| 704 if (version < 0 || version > 40) { | |
| 705 return FALSE; | |
| 706 } | |
| 707 if (m_pBCWriter == NULL) { | |
| 708 return FALSE; | |
| 709 } | |
| 710 return((CBC_QRCodeWriter*)m_pBCWriter)->SetVersion(version); | |
| 711 } | |
| 712 FX_BOOL CBC_QRCode::SetErrorCorrectionLevel (FX_INT32 level) | |
| 713 { | |
| 714 if (level < 0 || level > 3) { | |
| 715 return FALSE; | |
| 716 } | |
| 717 if (m_pBCWriter == NULL) { | |
| 718 return FALSE; | |
| 719 } | |
| 720 return ((CBC_TwoDimWriter*)m_pBCWriter)->SetErrorCorrectionLevel(level); | |
| 721 } | |
| 722 FX_BOOL CBC_QRCode::Encode(FX_WSTR contents, FX_BOOL isDevice, FX_INT32 &e) | |
| 723 { | |
| 724 FX_INT32 outWidth = 0; | |
| 725 FX_INT32 outHeight = 0; | |
| 726 FX_BYTE *data = ((CBC_QRCodeWriter*)m_pBCWriter)->Encode(contents, ((CBC_QRC
odeWriter*)m_pBCWriter)->GetErrorCorrectionLevel(), outWidth, outHeight, e); | |
| 727 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 728 ((CBC_TwoDimWriter*)m_pBCWriter)->RenderResult(data, outWidth, outHeight, e)
; | |
| 729 FX_Free(data); | |
| 730 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 731 return TRUE; | |
| 732 } | |
| 733 FX_BOOL CBC_QRCode::RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* mat
irx, FX_INT32 &e) | |
| 734 { | |
| 735 ((CBC_TwoDimWriter*)m_pBCWriter)->RenderDeviceResult(device, matirx); | |
| 736 return TRUE; | |
| 737 } | |
| 738 FX_BOOL CBC_QRCode::RenderBitmap(CFX_DIBitmap *&pOutBitmap, FX_INT32 &e) | |
| 739 { | |
| 740 ((CBC_TwoDimWriter*)m_pBCWriter)->RenderBitmapResult(pOutBitmap, e); | |
| 741 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 742 return TRUE; | |
| 743 } | |
| 744 CFX_WideString CBC_QRCode::Decode(FX_BYTE* buf, FX_INT32 width, FX_INT32 hight,
FX_INT32 &e) | |
| 745 { | |
| 746 CFX_WideString str; | |
| 747 return str; | |
| 748 } | |
| 749 CFX_WideString CBC_QRCode::Decode(CFX_DIBitmap *pBitmap, FX_INT32 &e) | |
| 750 { | |
| 751 CBC_BufferedImageLuminanceSource source(pBitmap); | |
| 752 CBC_GlobalHistogramBinarizer binarizer(&source); | |
| 753 CBC_BinaryBitmap bitmap(&binarizer); | |
| 754 CFX_ByteString retStr = m_pBCReader->Decode(&bitmap, 0, e); | |
| 755 BC_EXCEPTION_CHECK_ReturnValue(e, FX_WSTRC(L"")); | |
| 756 return CFX_WideString::FromUTF8(retStr, retStr.GetLength()); | |
| 757 } | |
| 758 CBC_PDF417I::CBC_PDF417I() | |
| 759 { | |
| 760 m_pBCReader = (CBC_Reader*) FX_NEW (CBC_PDF417Reader); | |
| 761 m_pBCWriter = (CBC_Writer*) FX_NEW (CBC_PDF417Writer); | |
| 762 } | |
| 763 CBC_PDF417I::~CBC_PDF417I() | |
| 764 { | |
| 765 if(m_pBCReader) { | |
| 766 delete(m_pBCReader); | |
| 767 m_pBCReader = NULL; | |
| 768 } | |
| 769 if(m_pBCWriter) { | |
| 770 delete(m_pBCWriter); | |
| 771 m_pBCWriter = NULL; | |
| 772 } | |
| 773 } | |
| 774 FX_BOOL CBC_PDF417I::SetErrorCorrectionLevel (FX_INT32 level) | |
| 775 { | |
| 776 ((CBC_PDF417Writer*)m_pBCWriter)->SetErrorCorrectionLevel(level); | |
| 777 return TRUE; | |
| 778 } | |
| 779 void CBC_PDF417I::SetTruncated(FX_BOOL truncated) | |
| 780 { | |
| 781 ((CBC_PDF417Writer*)m_pBCWriter)->SetTruncated(truncated); | |
| 782 } | |
| 783 FX_BOOL CBC_PDF417I::Encode(FX_WSTR contents, FX_BOOL isDevice, FX_INT32 &e) | |
| 784 { | |
| 785 BCFORMAT format = BCFORMAT_PDF_417; | |
| 786 FX_INT32 outWidth = 0; | |
| 787 FX_INT32 outHeight = 0; | |
| 788 FX_BYTE *data = ((CBC_PDF417Writer*)m_pBCWriter)->Encode(contents, outWidth,
outHeight, e); | |
| 789 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 790 ((CBC_TwoDimWriter*)m_pBCWriter)->RenderResult(data, outWidth, outHeight, e)
; | |
| 791 FX_Free(data); | |
| 792 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 793 return TRUE; | |
| 794 } | |
| 795 FX_BOOL CBC_PDF417I::RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* ma
tirx, FX_INT32 &e) | |
| 796 { | |
| 797 ((CBC_TwoDimWriter*)m_pBCWriter)->RenderDeviceResult(device, matirx); | |
| 798 return TRUE; | |
| 799 } | |
| 800 FX_BOOL CBC_PDF417I::RenderBitmap(CFX_DIBitmap *&pOutBitmap, FX_INT32 &e) | |
| 801 { | |
| 802 ((CBC_TwoDimWriter*)m_pBCWriter)->RenderBitmapResult(pOutBitmap, e); | |
| 803 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 804 return TRUE; | |
| 805 } | |
| 806 CFX_WideString CBC_PDF417I::Decode(FX_BYTE* buf, FX_INT32 width, FX_INT32 hight,
FX_INT32 &e) | |
| 807 { | |
| 808 CFX_WideString str; | |
| 809 return str; | |
| 810 } | |
| 811 CFX_WideString CBC_PDF417I::Decode(CFX_DIBitmap *pBitmap, FX_INT32 &e) | |
| 812 { | |
| 813 CBC_BufferedImageLuminanceSource source(pBitmap); | |
| 814 CBC_GlobalHistogramBinarizer binarizer(&source); | |
| 815 CBC_BinaryBitmap bitmap(&binarizer); | |
| 816 CFX_ByteString bytestring = m_pBCReader->Decode(&bitmap, 0, e); | |
| 817 BC_EXCEPTION_CHECK_ReturnValue(e, FX_WSTRC(L"")); | |
| 818 return CFX_WideString::FromUTF8(bytestring, bytestring.GetLength()); | |
| 819 } | |
| 820 CBC_DataMatrix::CBC_DataMatrix() | |
| 821 { | |
| 822 m_pBCReader = (CBC_Reader*) FX_NEW (CBC_DataMatrixReader); | |
| 823 ((CBC_DataMatrixReader*)m_pBCReader)->Init(); | |
| 824 m_pBCWriter = (CBC_Writer*) FX_NEW (CBC_DataMatrixWriter); | |
| 825 } | |
| 826 CBC_DataMatrix::~CBC_DataMatrix() | |
| 827 { | |
| 828 if(m_pBCReader) { | |
| 829 delete(m_pBCReader); | |
| 830 m_pBCReader = NULL; | |
| 831 } | |
| 832 if(m_pBCWriter) { | |
| 833 delete(m_pBCWriter); | |
| 834 m_pBCWriter = NULL; | |
| 835 } | |
| 836 } | |
| 837 FX_BOOL CBC_DataMatrix::Encode(FX_WSTR contents, FX_BOOL isDevice, FX_INT32 &e) | |
| 838 { | |
| 839 FX_INT32 outWidth = 0; | |
| 840 FX_INT32 outHeight = 0; | |
| 841 FX_BYTE *data = ((CBC_DataMatrixWriter *)m_pBCWriter)->Encode(contents, outW
idth, outHeight, e); | |
| 842 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 843 ((CBC_TwoDimWriter*)m_pBCWriter)->RenderResult(data, outWidth, outHeight, e)
; | |
| 844 FX_Free(data); | |
| 845 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 846 return TRUE; | |
| 847 } | |
| 848 FX_BOOL CBC_DataMatrix::RenderDevice(CFX_RenderDevice* device, const CFX_Matrix*
matirx, FX_INT32 &e) | |
| 849 { | |
| 850 ((CBC_TwoDimWriter*)m_pBCWriter)->RenderDeviceResult(device, matirx); | |
| 851 return TRUE; | |
| 852 } | |
| 853 FX_BOOL CBC_DataMatrix::RenderBitmap(CFX_DIBitmap *&pOutBitmap, FX_INT32 &e) | |
| 854 { | |
| 855 ((CBC_TwoDimWriter*)m_pBCWriter)->RenderBitmapResult(pOutBitmap, e); | |
| 856 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | |
| 857 return TRUE; | |
| 858 } | |
| 859 CFX_WideString CBC_DataMatrix::Decode(FX_BYTE* buf, FX_INT32 width, FX_INT32 hig
ht, FX_INT32 &e) | |
| 860 { | |
| 861 CFX_WideString str; | |
| 862 return str; | |
| 863 } | |
| 864 CFX_WideString CBC_DataMatrix::Decode(CFX_DIBitmap *pBitmap, FX_INT32 &e) | |
| 865 { | |
| 866 CBC_BufferedImageLuminanceSource source(pBitmap); | |
| 867 CBC_GlobalHistogramBinarizer binarizer(&source); | |
| 868 CBC_BinaryBitmap bitmap(&binarizer); | |
| 869 CFX_ByteString retStr = m_pBCReader->Decode(&bitmap, 0, e); | |
| 870 BC_EXCEPTION_CHECK_ReturnValue(e, FX_WSTRC(L"")); | |
| 871 return CFX_WideString::FromUTF8(retStr, retStr.GetLength()); | |
| 872 } | |
| OLD | NEW |