[SCM] Multi-format 1D/2D barcode image processing library branch, upstream, updated. 24d4480bc48cf9eabf7b2bd2f528248b0e458809
flyashi
flyashi at 59b500cc-1b3d-0410-9834-0bbf25fbcc57
Wed Aug 4 01:32:29 UTC 2010
The following commit has been merged in the upstream branch:
commit e5776b8d76108d2fb616f19f88bb0ed55d0c2ff6
Author: flyashi <flyashi at 59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Date: Fri Jul 9 15:12:46 2010 +0000
Fixed C++ port's handling of reversed barcodes:
- BitArray.reverse() was inverting, not reversing, bits.
- OneDReader wasn't reversing x coordinates of the result points.
- OneDReader wasn't catching Binarizer exceptions properly.
Issue 470 can be closed by this.
git-svn-id: http://zxing.googlecode.com/svn/trunk@1472 59b500cc-1b3d-0410-9834-0bbf25fbcc57
diff --git a/cpp/core/src/zxing/common/BitArray.cpp b/cpp/core/src/zxing/common/BitArray.cpp
index 9355d01..6ba7fd2 100644
--- a/cpp/core/src/zxing/common/BitArray.cpp
+++ b/cpp/core/src/zxing/common/BitArray.cpp
@@ -107,10 +107,12 @@ vector<unsigned int>& BitArray::getBitArray() {
return bits_;
}
void BitArray::reverse() {
- unsigned int allBits = numeric_limits<unsigned int>::max();
- size_t max = bits_.size();
- for (size_t i = 0; i < max; i++) {
- bits_[i] = bits_[i] ^ allBits;
+ std::vector<unsigned int> newBits(bits_.size(),(const unsigned int) 0);
+ for (size_t i = 0; i < size_; i++) {
+ if (get(size_ - i - 1)) {
+ newBits[i >> logBits_] |= 1<< (i & bitsMask_);
+ }
}
+ bits_ = newBits;
}
}
diff --git a/cpp/core/src/zxing/oned/OneDReader.cpp b/cpp/core/src/zxing/oned/OneDReader.cpp
index 7610b87..d3e4916 100644
--- a/cpp/core/src/zxing/oned/OneDReader.cpp
+++ b/cpp/core/src/zxing/oned/OneDReader.cpp
@@ -20,6 +20,7 @@
#include "OneDReader.h"
#include <zxing/ReaderException.h>
+#include <zxing/oned/OneDResultPoint.h>
#include <math.h>
#include <limits.h>
@@ -93,6 +94,8 @@ namespace zxing {
row = image->getBlackRow(rowNumber, row);
}catch (ReaderException re) {
continue;
+ }catch (IllegalArgumentException re) {
+ continue;
}
// While we have the image data in a BitArray, it's fairly cheap to reverse it in place to
@@ -109,9 +112,17 @@ namespace zxing {
// // But it was upside down, so note that
// result.putMetadata(ResultMetadataType.ORIENTATION, new Integer(180));
// // And remember to flip the result points horizontally.
- // ResultPoint[] points = result.getResultPoints();
- // points[0] = new ResultPoint(width - points[0].getX() - 1, points[0].getY());
- // points[1] = new ResultPoint(width - points[1].getX() - 1, points[1].getY());
+ std::vector<Ref<ResultPoint> > points(result->getResultPoints());
+ if (points.size() == 2) {
+ Ref<ResultPoint> pointZero(new OneDResultPoint(width - points[0]->getX() - 1, points[0]->getY()));
+ points[0] = pointZero;
+
+ Ref<ResultPoint> pointOne(new OneDResultPoint(width - points[1]->getX() - 1, points[1]->getY()));
+ points[1] = pointOne;
+
+ result.reset(new Result(result->getText(),result->getRawBytes(),points,result->getBarcodeFormat()));
+ }
+
}
return result;
} catch (ReaderException re) {
@@ -119,7 +130,7 @@ namespace zxing {
}
}
}
- throw ReaderException("");
+ throw ReaderException("doDecode() failed");
}
unsigned int OneDReader::patternMatchVariance(int counters[], int countersSize, const int pattern[], int maxIndividualVariance) {
--
Multi-format 1D/2D barcode image processing library
More information about the Pkg-google-commits
mailing list