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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #include "BC_PDF417DecodedBitStreamParser.h" | 50 #include "BC_PDF417DecodedBitStreamParser.h" |
51 #include "BC_PDF417ScanningDecoder.h" | 51 #include "BC_PDF417ScanningDecoder.h" |
52 #include "BC_PDF417Reader.h" | 52 #include "BC_PDF417Reader.h" |
53 #define Integer_MAX_VALUE 2147483647 | 53 #define Integer_MAX_VALUE 2147483647 |
54 CBC_PDF417Reader::CBC_PDF417Reader() | 54 CBC_PDF417Reader::CBC_PDF417Reader() |
55 { | 55 { |
56 } | 56 } |
57 CBC_PDF417Reader::~CBC_PDF417Reader() | 57 CBC_PDF417Reader::~CBC_PDF417Reader() |
58 { | 58 { |
59 } | 59 } |
60 CFX_ByteString CBC_PDF417Reader::Decode(CBC_BinaryBitmap *image, FX_INT32 &e) | 60 CFX_ByteString CBC_PDF417Reader::Decode(CBC_BinaryBitmap *image, int32_t &e) |
61 { | 61 { |
62 return Decode(image, 0, e); | 62 return Decode(image, 0, e); |
63 } | 63 } |
64 CFX_ByteString CBC_PDF417Reader::Decode(CBC_BinaryBitmap *image, FX_BOOL multipl
e, FX_INT32 hints, FX_INT32 &e) | 64 CFX_ByteString CBC_PDF417Reader::Decode(CBC_BinaryBitmap *image, FX_BOOL multipl
e, int32_t hints, int32_t &e) |
65 { | 65 { |
66 CFX_ByteString results; | 66 CFX_ByteString results; |
67 CBC_PDF417DetectorResult* detectorResult = CBC_Detector::detect(image, hints
, multiple, e); | 67 CBC_PDF417DetectorResult* detectorResult = CBC_Detector::detect(image, hints
, multiple, e); |
68 BC_EXCEPTION_CHECK_ReturnValue(e, ""); | 68 BC_EXCEPTION_CHECK_ReturnValue(e, ""); |
69 for (FX_INT32 i = 0; i < detectorResult->getPoints()->GetSize(); i++) { | 69 for (int32_t i = 0; i < detectorResult->getPoints()->GetSize(); i++) { |
70 CFX_PtrArray* points = (CFX_PtrArray*)detectorResult->getPoints()->GetAt
(i); | 70 CFX_PtrArray* points = (CFX_PtrArray*)detectorResult->getPoints()->GetAt
(i); |
71 CBC_CommonDecoderResult* ResultTemp = CBC_PDF417ScanningDecoder::decode(
detectorResult->getBits(), (CBC_ResultPoint*)points->GetAt(4), (CBC_ResultPoint*
)points->GetAt(5), | 71 CBC_CommonDecoderResult* ResultTemp = CBC_PDF417ScanningDecoder::decode(
detectorResult->getBits(), (CBC_ResultPoint*)points->GetAt(4), (CBC_ResultPoint*
)points->GetAt(5), |
72 (CBC_ResultPoint*)points->GetAt(6)
, (CBC_ResultPoint*)points->GetAt(7), getMinCodewordWidth(*points), getMaxCodewo
rdWidth(*points), e); | 72 (CBC_ResultPoint*)points->GetAt(6)
, (CBC_ResultPoint*)points->GetAt(7), getMinCodewordWidth(*points), getMaxCodewo
rdWidth(*points), e); |
73 if (ResultTemp == NULL) { | 73 if (ResultTemp == NULL) { |
74 delete detectorResult; | 74 delete detectorResult; |
75 e = BCExceptiontNotFoundInstance; | 75 e = BCExceptiontNotFoundInstance; |
76 return ""; | 76 return ""; |
77 } | 77 } |
78 results += ResultTemp->GetText(); | 78 results += ResultTemp->GetText(); |
79 delete ResultTemp; | 79 delete ResultTemp; |
80 } | 80 } |
81 delete detectorResult; | 81 delete detectorResult; |
82 return results; | 82 return results; |
83 } | 83 } |
84 CFX_ByteString CBC_PDF417Reader::Decode(CBC_BinaryBitmap *image, FX_INT32 hints,
FX_INT32 &e) | 84 CFX_ByteString CBC_PDF417Reader::Decode(CBC_BinaryBitmap *image, int32_t hints,
int32_t &e) |
85 { | 85 { |
86 CFX_ByteString bs = Decode(image, FALSE, 0, e); | 86 CFX_ByteString bs = Decode(image, FALSE, 0, e); |
87 BC_EXCEPTION_CHECK_ReturnValue(e, ""); | 87 BC_EXCEPTION_CHECK_ReturnValue(e, ""); |
88 return bs; | 88 return bs; |
89 } | 89 } |
90 FX_INT32 CBC_PDF417Reader::getMaxWidth(CBC_ResultPoint* p1, CBC_ResultPoint* p2) | 90 int32_t CBC_PDF417Reader::getMaxWidth(CBC_ResultPoint* p1, CBC_ResultPoint* p2) |
91 { | 91 { |
92 if (p1 == NULL || p2 == NULL) { | 92 if (p1 == NULL || p2 == NULL) { |
93 return 0; | 93 return 0; |
94 } | 94 } |
95 return (FX_INT32) FXSYS_fabs(p1->GetX() - p2->GetX()); | 95 return (int32_t) FXSYS_fabs(p1->GetX() - p2->GetX()); |
96 } | 96 } |
97 FX_INT32 CBC_PDF417Reader::getMinWidth(CBC_ResultPoint* p1, CBC_ResultPoint* p2) | 97 int32_t CBC_PDF417Reader::getMinWidth(CBC_ResultPoint* p1, CBC_ResultPoint* p2) |
98 { | 98 { |
99 if (p1 == NULL || p2 == NULL) { | 99 if (p1 == NULL || p2 == NULL) { |
100 return Integer_MAX_VALUE; | 100 return Integer_MAX_VALUE; |
101 } | 101 } |
102 return (FX_INT32) FXSYS_fabs(p1->GetX() - p2->GetX()); | 102 return (int32_t) FXSYS_fabs(p1->GetX() - p2->GetX()); |
103 } | 103 } |
104 FX_INT32 CBC_PDF417Reader::getMaxCodewordWidth(CFX_PtrArray& p) | 104 int32_t CBC_PDF417Reader::getMaxCodewordWidth(CFX_PtrArray& p) |
105 { | 105 { |
106 FX_INT32 a = getMaxWidth((CBC_ResultPoint*)p.GetAt(6), (CBC_ResultPoint*)p.G
etAt(2)) * CBC_PDF417Common::MODULES_IN_CODEWORD / CBC_PDF417Common::MODULES_IN_
STOP_PATTERN; | 106 int32_t a = getMaxWidth((CBC_ResultPoint*)p.GetAt(6), (CBC_ResultPoint*)p.Ge
tAt(2)) * CBC_PDF417Common::MODULES_IN_CODEWORD / CBC_PDF417Common::MODULES_IN_S
TOP_PATTERN; |
107 FX_INT32 b = getMaxWidth((CBC_ResultPoint*)p.GetAt(7), (CBC_ResultPoint*)p.G
etAt(3)) * CBC_PDF417Common::MODULES_IN_CODEWORD / CBC_PDF417Common::MODULES_IN_
STOP_PATTERN; | 107 int32_t b = getMaxWidth((CBC_ResultPoint*)p.GetAt(7), (CBC_ResultPoint*)p.Ge
tAt(3)) * CBC_PDF417Common::MODULES_IN_CODEWORD / CBC_PDF417Common::MODULES_IN_S
TOP_PATTERN; |
108 FX_INT32 c = getMaxWidth((CBC_ResultPoint*)p.GetAt(0), (CBC_ResultPoint*)p.G
etAt(4)) < a ? getMaxWidth((CBC_ResultPoint*)p.GetAt(0), (CBC_ResultPoint*)p.Get
At(4)) : a; | 108 int32_t c = getMaxWidth((CBC_ResultPoint*)p.GetAt(0), (CBC_ResultPoint*)p.Ge
tAt(4)) < a ? getMaxWidth((CBC_ResultPoint*)p.GetAt(0), (CBC_ResultPoint*)p.GetA
t(4)) : a; |
109 FX_INT32 d = getMaxWidth((CBC_ResultPoint*)p.GetAt(1), (CBC_ResultPoint*)p.G
etAt(5)) < b ? getMaxWidth((CBC_ResultPoint*)p.GetAt(1), (CBC_ResultPoint*)p.Get
At(5)) : b; | 109 int32_t d = getMaxWidth((CBC_ResultPoint*)p.GetAt(1), (CBC_ResultPoint*)p.Ge
tAt(5)) < b ? getMaxWidth((CBC_ResultPoint*)p.GetAt(1), (CBC_ResultPoint*)p.GetA
t(5)) : b; |
110 return c < d ? c : d; | 110 return c < d ? c : d; |
111 } | 111 } |
112 FX_INT32 CBC_PDF417Reader::getMinCodewordWidth(CFX_PtrArray& p) | 112 int32_t CBC_PDF417Reader::getMinCodewordWidth(CFX_PtrArray& p) |
113 { | 113 { |
114 FX_INT32 a = getMinWidth((CBC_ResultPoint*)p.GetAt(6), (CBC_ResultPoint*)p.G
etAt(2)) * CBC_PDF417Common::MODULES_IN_CODEWORD / CBC_PDF417Common::MODULES_IN_
STOP_PATTERN; | 114 int32_t a = getMinWidth((CBC_ResultPoint*)p.GetAt(6), (CBC_ResultPoint*)p.Ge
tAt(2)) * CBC_PDF417Common::MODULES_IN_CODEWORD / CBC_PDF417Common::MODULES_IN_S
TOP_PATTERN; |
115 FX_INT32 b = getMinWidth((CBC_ResultPoint*)p.GetAt(7), (CBC_ResultPoint*)p.G
etAt(3)) * CBC_PDF417Common::MODULES_IN_CODEWORD / CBC_PDF417Common::MODULES_IN_
STOP_PATTERN; | 115 int32_t b = getMinWidth((CBC_ResultPoint*)p.GetAt(7), (CBC_ResultPoint*)p.Ge
tAt(3)) * CBC_PDF417Common::MODULES_IN_CODEWORD / CBC_PDF417Common::MODULES_IN_S
TOP_PATTERN; |
116 FX_INT32 c = getMinWidth((CBC_ResultPoint*)p.GetAt(0), (CBC_ResultPoint*)p.G
etAt(4)) < a ? getMinWidth((CBC_ResultPoint*)p.GetAt(0), (CBC_ResultPoint*)p.Get
At(4)) : a; | 116 int32_t c = getMinWidth((CBC_ResultPoint*)p.GetAt(0), (CBC_ResultPoint*)p.Ge
tAt(4)) < a ? getMinWidth((CBC_ResultPoint*)p.GetAt(0), (CBC_ResultPoint*)p.GetA
t(4)) : a; |
117 FX_INT32 d = getMinWidth((CBC_ResultPoint*)p.GetAt(1), (CBC_ResultPoint*)p.G
etAt(5)) < b ? getMinWidth((CBC_ResultPoint*)p.GetAt(1), (CBC_ResultPoint*)p.Get
At(5)) : b; | 117 int32_t d = getMinWidth((CBC_ResultPoint*)p.GetAt(1), (CBC_ResultPoint*)p.Ge
tAt(5)) < b ? getMinWidth((CBC_ResultPoint*)p.GetAt(1), (CBC_ResultPoint*)p.GetA
t(5)) : b; |
118 return c < d ? c : d; | 118 return c < d ? c : d; |
119 } | 119 } |
OLD | NEW |