zxing_cpp 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +9 -10
  3. data/ext/zxing/zxing-cpp/CMakeLists.txt +5 -0
  4. data/ext/zxing/zxing-cpp/README.md +2 -7
  5. data/ext/zxing/zxing-cpp/cli/src/ImageReaderSource.cpp +1 -0
  6. data/ext/zxing/zxing-cpp/core/src/zxing/common/CharacterSetECI.cpp +5 -4
  7. data/ext/zxing/zxing-cpp/core/src/zxing/common/CharacterSetECI.h +3 -3
  8. data/ext/zxing/zxing-cpp/core/src/zxing/common/detector/MonochromeRectangleDetector.cpp +1 -0
  9. data/ext/zxing/zxing-cpp/core/src/zxing/common/reedsolomon/GenericGF.cpp +3 -3
  10. data/ext/zxing/zxing-cpp/core/src/zxing/common/reedsolomon/GenericGFPoly.cpp +19 -19
  11. data/ext/zxing/zxing-cpp/core/src/zxing/common/reedsolomon/GenericGFPoly.h +2 -2
  12. data/ext/zxing/zxing-cpp/core/src/zxing/common/reedsolomon/ReedSolomonDecoder.cpp +2 -2
  13. data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/decoder/DecodedBitStreamParser.cpp +3 -4
  14. data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/detector/Detector.cpp +1 -0
  15. data/ext/zxing/zxing-cpp/core/src/zxing/multi/GenericMultipleBarcodeReader.cpp +1 -1
  16. data/ext/zxing/zxing-cpp/core/src/zxing/oned/Code128Reader.cpp +1 -0
  17. data/ext/zxing/zxing-cpp/core/src/zxing/oned/Code39Reader.cpp +2 -1
  18. data/ext/zxing/zxing-cpp/core/src/zxing/oned/Code93Reader.cpp +20 -10
  19. data/ext/zxing/zxing-cpp/core/src/zxing/oned/OneDReader.cpp +1 -0
  20. data/ext/zxing/zxing-cpp/core/src/zxing/oned/UPCAReader.cpp +4 -5
  21. data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/detector/Detector.cpp +1 -0
  22. data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/detector/LinesSampler.cpp +4 -3
  23. data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/DecodedBitStreamParser.cpp +3 -0
  24. data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/Detector.cpp +1 -0
  25. data/lib/zxing/rmagick/image.rb +7 -2
  26. data/lib/zxing/version.rb +1 -1
  27. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b419584e04c824a4e3075c1a38e558753aaca225
4
- data.tar.gz: d5775f7156f64249e2f3097c5df41872fdbacf96
3
+ metadata.gz: 27d404f02e304a2cc3855d6ba0bb4548d5f28c2d
4
+ data.tar.gz: d9b4fb14bd03951572190e9ddb86bfda39204e73
5
5
  SHA512:
6
- metadata.gz: f96bf92589a3e14a42dfe36dacc0d2c439945cdf049ff97a69bbbddd5983c33a7f0ffae8a17c4026e3fddd687eb349f469b44ea19f9863c93c7e66a0e57c57bf
7
- data.tar.gz: 09b88b47d439346d20a4a36666bf6b4d95839040d6a910a6bde11646f1fcfb7d8697f6614918ba5c9b3951abe8fd9dddf0760485df36689fa8b675fba100bdbc
6
+ metadata.gz: 7eee23288c0e7ee238911ce047d518f158bb9e765996681c4dba5c6784ec791f5723f04d307e4dc85d088c26d3052d0417c0e28fb2846189bb6557edfb3a9fc9
7
+ data.tar.gz: 51dd2a2318a7380920fd45e649b3ac82ee574c76d22335e6a1587ecbc36411eb8540c007cfae344ff2f18b92fac856a73bcbde1bb88210fdb9ac77311f824d9c
@@ -23,14 +23,14 @@ The {bug tracker}[https://github.com/glassechidna/zxing_cpp.rb/issues] is availa
23
23
  require 'zxing'
24
24
  result = ZXing.decode "myimage.png"
25
25
 
26
- zxing.rb also comes with a command that decodes images: zxd:
26
+ zxing_cpp also comes with a command that decodes images: zxd:
27
27
 
28
28
  $ zxd filename.png
29
29
  <decoded contents>
30
30
 
31
31
  +zxd+ can take multiple arguments and the arguments can be URLs.
32
32
 
33
- zxing.rb provides access to many of the classes of ZXing classes like
33
+ zxing_cpp provides access to many of the classes of ZXing classes like
34
34
  readers, luminance sources, binarizers, so you can mix and match your
35
35
  own applications much as you would with a native Java or C++ app. See
36
36
  +zxd+ and +test/vendor.rb+ for examples.
@@ -90,25 +90,24 @@ is yet to be written.
90
90
  * Ruby (>= 1.9)
91
91
  * CMake (>= 2.8.0)
92
92
 
93
- zxing.rb bundles a version of the ZXing C++ library (zxing-cpp).
93
+ zxing_cpp bundles a version of the ZXing C++ library (zxing-cpp).
94
94
 
95
95
  == INSTALL:
96
96
 
97
- The gem has yet to be submitted to RubyGems. For now you must clone
98
- the repo and execute:
97
+ If you're using RubyGems (probably), then simply add the following to your <tt>Gemfile</tt>:
99
98
 
100
- rake gem
101
- gem install pkg/zxing_cpp-0.1.0.gem
99
+ gem 'zxing_cpp'
102
100
 
103
- or add it zxing_cpp to your Gemfile:
101
+ Alternatively, you could clone the {zxing_cpp repo}[https://github.com/glassechidna/zxing_cpp.rb] and execute:
104
102
 
105
- gem 'zxing_cpp', git: 'https://github.com/glassechidna/zxing_cpp.rb.git', submodules: true
103
+ rake gem
104
+ gem install pkg/zxing_cpp-0.1.0.gem
106
105
 
107
106
  == DEVELOPMENT:
108
107
 
109
108
  rake test
110
109
 
111
- <tt>rake test</tt> runs the zxing.rb unit tests.
110
+ <tt>rake test</tt> runs the zxing_cpp unit tests.
112
111
 
113
112
  == LICENSE:
114
113
 
@@ -68,6 +68,11 @@ file(GLOB_RECURSE ZXING_FILES
68
68
  )
69
69
  add_executable(zxing ${ZXING_FILES})
70
70
  target_link_libraries(zxing libzxing)
71
+ install(TARGETS zxing libzxing
72
+ LIBRARY DESTINATION lib
73
+ RUNTIME DESTINATION bin
74
+ ARCHIVE DESTINATION lib)
75
+ install(DIRECTORY core/src/zxing/ DESTINATION include/zxing FILES_MATCHING PATTERN "*.h")
71
76
 
72
77
  # Add testrunner executable.
73
78
  find_package(CPPUNIT)
@@ -26,7 +26,8 @@ Usage with CLion or Qt Creator:
26
26
 
27
27
  Usage with Makefiles, Visual Studio, etc. (see `cmake --help` for a complete list of generators):
28
28
 
29
- 1. `cd` to `cpp/build`
29
+ 1. `mkdir build`
30
+ 2. `cd` to `build`
30
31
  3. Unix: run `cmake -G "Unix Makefiles" ..`
31
32
  3. Windows: run `cmake -G "Visual Studio 10" ..`
32
33
 
@@ -42,9 +43,3 @@ To profile the code (very useful to optimize the code):
42
43
  1. Install Valgrind
43
44
  2. Run `valgrind --tool=callgrind build/zxing - path/to/test/data/*.jpg > report.html`
44
45
  3. Analyze output using KCachegrind
45
-
46
- To run the black box tests and check for changes:
47
-
48
- 1. Build `zxing-img`, e.g., scons zxing
49
- 2. Run the tests: `bash blackboxtest.sh 2>&1 | tee bb.results`
50
- 3. Diff them with the known results: `diff bb.results blackboxtest.results`
@@ -75,6 +75,7 @@ Ref<LuminanceSource> ImageReaderSource::create(string const& filename) {
75
75
  char *buffer = reinterpret_cast<char*>(jpgd::decompress_jpeg_image_from_file(
76
76
  filename.c_str(), &width, &height, &comps, 4));
77
77
  image = zxing::ArrayRef<char>(buffer, 4 * width * height);
78
+ free(buffer);
78
79
  }
79
80
  if (!image) {
80
81
  ostringstream msg;
@@ -24,8 +24,8 @@ using std::string;
24
24
  using zxing::common::CharacterSetECI;
25
25
  using zxing::IllegalArgumentException;
26
26
 
27
- std::map<int, CharacterSetECI*> CharacterSetECI::VALUE_TO_ECI;
28
- std::map<std::string, CharacterSetECI*> CharacterSetECI::NAME_TO_ECI;
27
+ std::map<int, zxing::Ref<CharacterSetECI> > CharacterSetECI::VALUE_TO_ECI;
28
+ std::map<std::string, zxing::Ref<CharacterSetECI> > CharacterSetECI::NAME_TO_ECI;
29
29
 
30
30
  const bool CharacterSetECI::inited = CharacterSetECI::init_tables();
31
31
 
@@ -72,11 +72,12 @@ bool CharacterSetECI::init_tables() {
72
72
  CharacterSetECI::CharacterSetECI(int const* values,
73
73
  char const* const* names)
74
74
  : values_(values), names_(names) {
75
+ zxing::Ref<CharacterSetECI> this_ref(this);
75
76
  for(int const* values = values_; *values != -1; values++) {
76
- VALUE_TO_ECI[*values] = this;
77
+ VALUE_TO_ECI[*values] = this_ref;
77
78
  }
78
79
  for(char const* const* names = names_; *names; names++) {
79
- NAME_TO_ECI[string(*names)] = this;
80
+ NAME_TO_ECI[string(*names)] = this_ref;
80
81
  }
81
82
  }
82
83
 
@@ -25,10 +25,10 @@
25
25
  namespace zxing {
26
26
  namespace common {
27
27
 
28
- class CharacterSetECI {
28
+ class CharacterSetECI : public Counted {
29
29
  private:
30
- static std::map<int, CharacterSetECI*> VALUE_TO_ECI;
31
- static std::map<std::string, CharacterSetECI*> NAME_TO_ECI;
30
+ static std::map<int, zxing::Ref<CharacterSetECI> > VALUE_TO_ECI;
31
+ static std::map<std::string, zxing::Ref<CharacterSetECI> > NAME_TO_ECI;
32
32
  static const bool inited;
33
33
  static bool init_tables();
34
34
 
@@ -22,6 +22,7 @@
22
22
  #include <zxing/NotFoundException.h>
23
23
  #include <zxing/common/detector/MonochromeRectangleDetector.h>
24
24
  #include <sstream>
25
+ #include <algorithm> // vs12, std::min und std:max
25
26
 
26
27
  using std::vector;
27
28
  using zxing::Ref;
@@ -67,10 +67,10 @@ void GenericGF::initialize() {
67
67
  }
68
68
  //logTable[0] == 0 but this should never be used
69
69
  zero =
70
- Ref<GenericGFPoly>(new GenericGFPoly(Ref<GenericGF>(this), ArrayRef<int>(new Array<int>(1))));
70
+ Ref<GenericGFPoly>(new GenericGFPoly(*this, ArrayRef<int>(new Array<int>(1))));
71
71
  zero->getCoefficients()[0] = 0;
72
72
  one =
73
- Ref<GenericGFPoly>(new GenericGFPoly(Ref<GenericGF>(this), ArrayRef<int>(new Array<int>(1))));
73
+ Ref<GenericGFPoly>(new GenericGFPoly(*this, ArrayRef<int>(new Array<int>(1))));
74
74
  one->getCoefficients()[0] = 1;
75
75
  initialized = true;
76
76
  }
@@ -103,7 +103,7 @@ Ref<GenericGFPoly> GenericGF::buildMonomial(int degree, int coefficient) {
103
103
  ArrayRef<int> coefficients(new Array<int>(degree + 1));
104
104
  coefficients[0] = coefficient;
105
105
 
106
- return Ref<GenericGFPoly>(new GenericGFPoly(Ref<GenericGF>(this), coefficients));
106
+ return Ref<GenericGFPoly>(new GenericGFPoly(*this, coefficients));
107
107
  }
108
108
 
109
109
  int GenericGF::addOrSubtract(int a, int b) {
@@ -31,7 +31,7 @@ using zxing::Ref;
31
31
  // VC++
32
32
  using zxing::GenericGF;
33
33
 
34
- GenericGFPoly::GenericGFPoly(Ref<GenericGF> field,
34
+ GenericGFPoly::GenericGFPoly(GenericGF &field,
35
35
  ArrayRef<int> coefficients)
36
36
  : field_(field) {
37
37
  if (coefficients->size() == 0) {
@@ -45,7 +45,7 @@ GenericGFPoly::GenericGFPoly(Ref<GenericGF> field,
45
45
  firstNonZero++;
46
46
  }
47
47
  if (firstNonZero == coefficientsLength) {
48
- coefficients_ = field->getZero()->getCoefficients();
48
+ coefficients_ = field.getZero()->getCoefficients();
49
49
  } else {
50
50
  coefficients_ = ArrayRef<int>(new Array<int>(coefficientsLength-firstNonZero));
51
51
  for (int i = 0; i < (int)coefficients_->size(); i++) {
@@ -90,13 +90,13 @@ int GenericGFPoly::evaluateAt(int a) {
90
90
  }
91
91
  int result = coefficients_[0];
92
92
  for (int i = 1; i < size; i++) {
93
- result = GenericGF::addOrSubtract(field_->multiply(a, result), coefficients_[i]);
93
+ result = GenericGF::addOrSubtract(field_.multiply(a, result), coefficients_[i]);
94
94
  }
95
95
  return result;
96
96
  }
97
97
 
98
98
  Ref<GenericGFPoly> GenericGFPoly::addOrSubtract(Ref<zxing::GenericGFPoly> other) {
99
- if (!(field_.object_ == other->field_.object_)) {
99
+ if (!(&field_ == &other->field_)) {
100
100
  throw IllegalArgumentException("GenericGFPolys do not have same GenericGF field");
101
101
  }
102
102
  if (isZero()) {
@@ -130,12 +130,12 @@ Ref<GenericGFPoly> GenericGFPoly::addOrSubtract(Ref<zxing::GenericGFPoly> other)
130
130
  }
131
131
 
132
132
  Ref<GenericGFPoly> GenericGFPoly::multiply(Ref<zxing::GenericGFPoly> other) {
133
- if (!(field_.object_ == other->field_.object_)) {
133
+ if (!(&field_ == &other->field_)) {
134
134
  throw IllegalArgumentException("GenericGFPolys do not have same GenericGF field");
135
135
  }
136
136
 
137
137
  if (isZero() || other->isZero()) {
138
- return field_->getZero();
138
+ return field_.getZero();
139
139
  }
140
140
 
141
141
  ArrayRef<int> aCoefficients = coefficients_;
@@ -149,7 +149,7 @@ Ref<GenericGFPoly> GenericGFPoly::multiply(Ref<zxing::GenericGFPoly> other) {
149
149
  int aCoeff = aCoefficients[i];
150
150
  for (int j = 0; j < bLength; j++) {
151
151
  product[i+j] = GenericGF::addOrSubtract(product[i+j],
152
- field_->multiply(aCoeff, bCoefficients[j]));
152
+ field_.multiply(aCoeff, bCoefficients[j]));
153
153
  }
154
154
  }
155
155
 
@@ -158,7 +158,7 @@ Ref<GenericGFPoly> GenericGFPoly::multiply(Ref<zxing::GenericGFPoly> other) {
158
158
 
159
159
  Ref<GenericGFPoly> GenericGFPoly::multiply(int scalar) {
160
160
  if (scalar == 0) {
161
- return field_->getZero();
161
+ return field_.getZero();
162
162
  }
163
163
  if (scalar == 1) {
164
164
  return Ref<GenericGFPoly>(this);
@@ -166,7 +166,7 @@ Ref<GenericGFPoly> GenericGFPoly::multiply(int scalar) {
166
166
  int size = coefficients_->size();
167
167
  ArrayRef<int> product(new Array<int>(size));
168
168
  for (int i = 0; i < size; i++) {
169
- product[i] = field_->multiply(coefficients_[i], scalar);
169
+ product[i] = field_.multiply(coefficients_[i], scalar);
170
170
  }
171
171
  return Ref<GenericGFPoly>(new GenericGFPoly(field_, product));
172
172
  }
@@ -176,42 +176,42 @@ Ref<GenericGFPoly> GenericGFPoly::multiplyByMonomial(int degree, int coefficient
176
176
  throw IllegalArgumentException("degree must not be less then 0");
177
177
  }
178
178
  if (coefficient == 0) {
179
- return field_->getZero();
179
+ return field_.getZero();
180
180
  }
181
181
  int size = coefficients_->size();
182
182
  ArrayRef<int> product(new Array<int>(size+degree));
183
183
  for (int i = 0; i < size; i++) {
184
- product[i] = field_->multiply(coefficients_[i], coefficient);
184
+ product[i] = field_.multiply(coefficients_[i], coefficient);
185
185
  }
186
186
  return Ref<GenericGFPoly>(new GenericGFPoly(field_, product));
187
187
  }
188
188
 
189
189
  std::vector<Ref<GenericGFPoly> > GenericGFPoly::divide(Ref<GenericGFPoly> other) {
190
- if (!(field_.object_ == other->field_.object_)) {
190
+ if (!(&field_ == &other->field_)) {
191
191
  throw IllegalArgumentException("GenericGFPolys do not have same GenericGF field");
192
192
  }
193
193
  if (other->isZero()) {
194
194
  throw IllegalArgumentException("divide by 0");
195
195
  }
196
196
 
197
- Ref<GenericGFPoly> quotient = field_->getZero();
197
+ Ref<GenericGFPoly> quotient = field_.getZero();
198
198
  Ref<GenericGFPoly> remainder = Ref<GenericGFPoly>(this);
199
199
 
200
200
  int denominatorLeadingTerm = other->getCoefficient(other->getDegree());
201
- int inverseDenominatorLeadingTerm = field_->inverse(denominatorLeadingTerm);
201
+ int inverseDenominatorLeadingTerm = field_.inverse(denominatorLeadingTerm);
202
202
 
203
203
  while (remainder->getDegree() >= other->getDegree() && !remainder->isZero()) {
204
204
  int degreeDifference = remainder->getDegree() - other->getDegree();
205
- int scale = field_->multiply(remainder->getCoefficient(remainder->getDegree()),
206
- inverseDenominatorLeadingTerm);
205
+ int scale = field_.multiply(remainder->getCoefficient(remainder->getDegree()),
206
+ inverseDenominatorLeadingTerm);
207
207
  Ref<GenericGFPoly> term = other->multiplyByMonomial(degreeDifference, scale);
208
- Ref<GenericGFPoly> iterationQuotiont = field_->buildMonomial(degreeDifference,
209
- scale);
208
+ Ref<GenericGFPoly> iterationQuotiont = field_.buildMonomial(degreeDifference,
209
+ scale);
210
210
  quotient = quotient->addOrSubtract(iterationQuotiont);
211
211
  remainder = remainder->addOrSubtract(term);
212
212
  }
213
213
 
214
- std::vector<Ref<GenericGFPoly> > returnValue;
214
+ std::vector<Ref<GenericGFPoly> > returnValue(2);
215
215
  returnValue[0] = quotient;
216
216
  returnValue[1] = remainder;
217
217
  return returnValue;
@@ -32,11 +32,11 @@ class GenericGF;
32
32
 
33
33
  class GenericGFPoly : public Counted {
34
34
  private:
35
- Ref<GenericGF> field_;
35
+ GenericGF &field_;
36
36
  ArrayRef<int> coefficients_;
37
37
 
38
38
  public:
39
- GenericGFPoly(Ref<GenericGF> field, ArrayRef<int> coefficients);
39
+ GenericGFPoly(GenericGF &field, ArrayRef<int> coefficients);
40
40
  ArrayRef<int> getCoefficients();
41
41
  int getDegree();
42
42
  bool isZero();
@@ -40,7 +40,7 @@ ReedSolomonDecoder::~ReedSolomonDecoder() {
40
40
  }
41
41
 
42
42
  void ReedSolomonDecoder::decode(ArrayRef<int> received, int twoS) {
43
- Ref<GenericGFPoly> poly(new GenericGFPoly(field, received));
43
+ Ref<GenericGFPoly> poly(new GenericGFPoly(*field, received));
44
44
  ArrayRef<int> syndromeCoefficients(twoS);
45
45
  bool noError = true;
46
46
  for (int i = 0; i < twoS; i++) {
@@ -53,7 +53,7 @@ void ReedSolomonDecoder::decode(ArrayRef<int> received, int twoS) {
53
53
  if (noError) {
54
54
  return;
55
55
  }
56
- Ref<GenericGFPoly> syndrome(new GenericGFPoly(field, syndromeCoefficients));
56
+ Ref<GenericGFPoly> syndrome(new GenericGFPoly(*field, syndromeCoefficients));
57
57
  vector<Ref<GenericGFPoly> > sigmaOmega =
58
58
  runEuclideanAlgorithm(field->buildMonomial(twoS, 1), syndrome, twoS);
59
59
  Ref<GenericGFPoly> sigma = sigmaOmega[0];
@@ -399,16 +399,15 @@ void DecodedBitStreamParser::decodeBase256Segment(Ref<BitSource> bits, ostringst
399
399
  throw FormatException("NegativeArraySizeException");
400
400
  }
401
401
 
402
- char* bytes = new char[count];
403
402
  for (int i = 0; i < count; i++) {
404
403
  // Have seen this particular error in the wild, such as at
405
404
  // http://www.bcgen.com/demo/IDAutomationStreamingDataMatrix.aspx?MODE=3&D=Fred&PFMT=3&PT=F&X=0.3&O=0&LM=0.2
406
405
  if (bits->available() < 8) {
407
406
  throw FormatException("byteSegments");
408
407
  }
409
- bytes[i] = unrandomize255State(bits->readBits(8), codewordPosition++);
410
- byteSegments.push_back(bytes[i]);
411
- result << (char)bytes[i];
408
+ char byte = unrandomize255State(bits->readBits(8), codewordPosition++);
409
+ byteSegments.push_back(byte);
410
+ result << byte;
412
411
  }
413
412
  }
414
413
  }
@@ -27,6 +27,7 @@
27
27
  #include <zxing/NotFoundException.h>
28
28
  #include <sstream>
29
29
  #include <cstdlib>
30
+ #include <algorithm> // vs12, std::min und std:max
30
31
 
31
32
  using std::abs;
32
33
  using zxing::Ref;
@@ -128,7 +128,7 @@ Ref<Result> GenericMultipleBarcodeReader::translateResultPoints(Ref<Result> resu
128
128
  if (oldResultPoints->empty()) {
129
129
  return result;
130
130
  }
131
- ArrayRef< Ref<ResultPoint> > newResultPoints;
131
+ ArrayRef< Ref<ResultPoint> > newResultPoints(new zxing::Array< Ref<ResultPoint> >());
132
132
  for (int i = 0; i < oldResultPoints->size(); i++) {
133
133
  Ref<ResultPoint> oldPoint = oldResultPoints[i];
134
134
  newResultPoints->values().push_back(Ref<ResultPoint>(new ResultPoint(oldPoint->getX() + xOffset, oldPoint->getY() + yOffset)));
@@ -26,6 +26,7 @@
26
26
  #include <math.h>
27
27
  #include <string.h>
28
28
  #include <sstream>
29
+ #include <algorithm> // vs12, std::min und std:max
29
30
 
30
31
  using std::vector;
31
32
  using std::string;
@@ -23,6 +23,7 @@
23
23
  #include <zxing/ChecksumException.h>
24
24
  #include <math.h>
25
25
  #include <limits.h>
26
+ #include <algorithm> // vs12, std::min und std:max
26
27
 
27
28
  using std::vector;
28
29
  using zxing::Ref;
@@ -132,7 +133,7 @@ Ref<Result> Code39Reader::decodeRow(int rowNumber, Ref<BitArray> row) {
132
133
  int whiteSpaceAfterEnd = nextStart - lastStart - lastPatternSize;
133
134
  // If 50% of last pattern size, following last pattern, is not whitespace,
134
135
  // fail (but if it's whitespace to the very end of the image, that's OK)
135
- if (nextStart != end && (whiteSpaceAfterEnd >> 1) < lastPatternSize) {
136
+ if (nextStart != end && (whiteSpaceAfterEnd << 1) < lastPatternSize) {
136
137
  throw NotFoundException();
137
138
  }
138
139
 
@@ -239,16 +239,26 @@ Ref<String> Code93Reader::decodeExtended(string const& encoded) {
239
239
  throw FormatException::getFormatInstance();
240
240
  }
241
241
  break;
242
- case 'b':
243
- // %A to %E map to control codes ESC to US
244
- if (next >= 'A' && next <= 'E') {
245
- decodedChar = (char) (next - 38);
246
- } else if (next >= 'F' && next <= 'W') {
247
- decodedChar = (char) (next - 11);
248
- } else {
249
- throw FormatException::getFormatInstance();
250
- }
251
- break;
242
+ case 'b':
243
+ if (next >= 'A' && next <= 'E') {
244
+ // %A to %E map to control codes ESC to USep
245
+ decodedChar = (char) (next - 38);
246
+ } else if (next >= 'F' && next <= 'J') {
247
+ // %F to %J map to ; < = > ?
248
+ decodedChar = (char) (next - 11);
249
+ } else if (next >= 'K' && next <= 'O') {
250
+ // %K to %O map to [ \ ] ^ _
251
+ decodedChar = (char) (next + 16);
252
+ } else if (next >= 'P' && next <= 'S') {
253
+ // %P to %S map to { | } ~
254
+ decodedChar = (char) (next + 43);
255
+ } else if (next >= 'T' && next <= 'Z') {
256
+ // %T to %Z all map to DEL (127)
257
+ decodedChar = 127;
258
+ } else {
259
+ throw FormatException::getFormatInstance();
260
+ }
261
+ break;
252
262
  case 'c':
253
263
  // /A to /O map to ! to , and /Z maps to :
254
264
  if (next >= 'A' && next <= 'O') {
@@ -22,6 +22,7 @@
22
22
  #include <zxing/NotFoundException.h>
23
23
  #include <math.h>
24
24
  #include <limits.h>
25
+ #include <algorithm> // vs12, std::min und std:max
25
26
 
26
27
  using std::vector;
27
28
  using zxing::Ref;
@@ -19,7 +19,7 @@
19
19
  */
20
20
 
21
21
  #include "UPCAReader.h"
22
- #include <zxing/ReaderException.h>
22
+ #include <zxing/FormatException.h>
23
23
 
24
24
  using zxing::oned::UPCAReader;
25
25
  using zxing::Ref;
@@ -29,6 +29,7 @@ using zxing::Result;
29
29
  using zxing::BitArray;
30
30
  using zxing::BinaryBitmap;
31
31
  using zxing::DecodeHints;
32
+ using zxing::FormatException;
32
33
 
33
34
  UPCAReader::UPCAReader() : ean13Reader() {}
34
35
 
@@ -53,17 +54,15 @@ int UPCAReader::decodeMiddle(Ref<BitArray> row,
53
54
  }
54
55
 
55
56
  Ref<Result> UPCAReader::maybeReturnResult(Ref<Result> result) {
56
- if (result.empty()) {
57
- return result;
58
- }
59
57
  const std::string& text = (result->getText())->getText();
60
58
  if (text[0] == '0') {
61
59
  Ref<String> resultString(new String(text.substr(1)));
62
60
  Ref<Result> res(new Result(resultString, result->getRawBytes(), result->getResultPoints(),
63
61
  BarcodeFormat::UPC_A));
64
62
  return res;
63
+ } else {
64
+ throw FormatException();
65
65
  }
66
- return Ref<Result>();
67
66
  }
68
67
 
69
68
  zxing::BarcodeFormat UPCAReader::getBarcodeFormat(){
@@ -21,6 +21,7 @@
21
21
  #include <zxing/common/GridSampler.h>
22
22
  #include <zxing/common/detector/JavaMath.h>
23
23
  #include <zxing/common/detector/MathUtils.h>
24
+ #include <algorithm> // vs12, std::min und std:max
24
25
 
25
26
  using std::max;
26
27
  using std::abs;
@@ -20,11 +20,12 @@
20
20
  #include <zxing/pdf417/decoder/BitMatrixParser.h>
21
21
  #include <zxing/NotFoundException.h>
22
22
  #include <zxing/common/Point.h>
23
+ #include <algorithm> // vs12, std::min und std:max
24
+ #include <cmath>
23
25
 
24
26
  using std::map;
25
27
  using std::vector;
26
28
  using std::min;
27
- using std::abs;
28
29
  using zxing::pdf417::detector::LinesSampler;
29
30
  using zxing::pdf417::decoder::BitMatrixParser;
30
31
  using zxing::Ref;
@@ -61,7 +62,7 @@ class VoteResult {
61
62
  this->vote = vote;
62
63
  }
63
64
  };
64
-
65
+
65
66
  VoteResult getValueWithMaxVotes(map<int, int>& votes) {
66
67
  VoteResult result;
67
68
  int maxVotes = 0;
@@ -703,7 +704,7 @@ Point LinesSampler::intersection(Line a, Line b) {
703
704
  float p = a.start.x * a.end.y - a.start.y * a.end.x;
704
705
  float q = b.start.x * b.end.y - b.start.y * b.end.x;
705
706
  float denom = dxa * dyb - dya * dxb;
706
- if(abs(denom) < 1e-12) // Lines don't intersect (replaces "denom == 0")
707
+ if(std::abs(denom) < 1e-12) // Lines don't intersect (replaces "denom == 0")
707
708
  return Point(std::numeric_limits<float>::infinity(),
708
709
  std::numeric_limits<float>::infinity());
709
710
 
@@ -221,6 +221,7 @@ void DecodedBitStreamParser::decodeNumericSegment(Ref<BitSource> bits, std::stri
221
221
  while (count >= 3) {
222
222
  // Each 10 bits encodes three digits
223
223
  if (bits->available() < 10) {
224
+ delete[] bytes;
224
225
  throw ReaderException("format exception");
225
226
  }
226
227
  int threeDigitsBits = bits->readBits(10);
@@ -237,6 +238,7 @@ void DecodedBitStreamParser::decodeNumericSegment(Ref<BitSource> bits, std::stri
237
238
  }
238
239
  if (count == 2) {
239
240
  if (bits->available() < 7) {
241
+ delete[] bytes;
240
242
  throw ReaderException("format exception");
241
243
  }
242
244
  // Two digits left over to read, encoded in 7 bits
@@ -251,6 +253,7 @@ void DecodedBitStreamParser::decodeNumericSegment(Ref<BitSource> bits, std::stri
251
253
  bytes[i++] = ALPHANUMERIC_CHARS[twoDigitsBits % 10];
252
254
  } else if (count == 1) {
253
255
  if (bits->available() < 4) {
256
+ delete[] bytes;
254
257
  throw ReaderException("format exception");
255
258
  }
256
259
  // One digit left over to read
@@ -30,6 +30,7 @@
30
30
  #include <zxing/common/detector/MathUtils.h>
31
31
  #include <sstream>
32
32
  #include <cstdlib>
33
+ #include <algorithm> // vs12, std::min und std:max
33
34
 
34
35
  using std::ostringstream;
35
36
  using std::abs;
@@ -1,9 +1,14 @@
1
- require 'RMagick'
1
+ begin
2
+ # Support both newer 'rmagick' require and deprecated 'RMagick' require:
3
+ require 'rmagick'
4
+ rescue LoadError => e
5
+ require 'RMagick'
6
+ end
2
7
 
3
8
  module ZXing; end
4
9
  module ZXing::RMagick; end
5
10
 
6
- class ZXing::RMagick::Image
11
+ class ZXing::RMagick::Image
7
12
  include ZXing::Image
8
13
  LuminanceSource = ZXing::FFI::Common::GreyscaleLuminanceSource
9
14
 
@@ -1,5 +1,5 @@
1
1
  module ZXing
2
- VERSION = "0.1.0" unless defined?(::ZXing::VERSION)
2
+ VERSION = "0.1.1" unless defined?(::ZXing::VERSION)
3
3
 
4
4
  VERSION_INFO = {}
5
5
  VERSION_INFO['warnings'] = []
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zxing_cpp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Dobell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-19 00:00:00.000000000 Z
11
+ date: 2016-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -461,7 +461,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
461
461
  version: '0'
462
462
  requirements: []
463
463
  rubyforge_project:
464
- rubygems_version: 2.2.2
464
+ rubygems_version: 2.5.1
465
465
  signing_key:
466
466
  specification_version: 4
467
467
  summary: A barcode and QR code library.