From f6bf265df7c2ee2e7f7653ac9cef4ddbcdb00326 Mon Sep 17 00:00:00 2001 From: favoritas37 Date: Tue, 14 Jun 2016 23:27:05 +0300 Subject: [PATCH] completed the transition from char to byte. --- src/CameraImageWrapper.cpp | 16 +++---- src/CameraImageWrapper.h | 8 ++-- src/zxing/zxing/InvertedLuminanceSource.cpp | 12 ++--- src/zxing/zxing/InvertedLuminanceSource.h | 4 +- src/zxing/zxing/LuminanceSource.cpp | 2 +- src/zxing/zxing/LuminanceSource.h | 4 +- .../zxing/common/GlobalHistogramBinarizer.cpp | 17 +++---- .../zxing/common/GlobalHistogramBinarizer.h | 2 +- .../zxing/common/GreyscaleLuminanceSource.cpp | 15 ++++--- .../zxing/common/GreyscaleLuminanceSource.h | 8 ++-- .../GreyscaleRotatedLuminanceSource.cpp | 19 ++++---- .../common/GreyscaleRotatedLuminanceSource.h | 8 ++-- src/zxing/zxing/common/HybridBinarizer.cpp | 8 ++-- src/zxing/zxing/common/HybridBinarizer.h | 6 +-- .../datamatrix/decoder/BitMatrixParser.h | 2 +- .../zxing/datamatrix/decoder/DataBlock.h | 8 ++-- .../decoder/DataMatrixBitMatrixParser.cpp | 16 +++---- .../decoder/DataMatrixDataBlock.cpp | 8 ++-- .../DataMatrixDecodedBitStreamParser.cpp | 44 +++++++++---------- .../datamatrix/decoder/DataMatrixDecoder.cpp | 8 ++-- .../decoder/DecodedBitStreamParser.h | 4 +- src/zxing/zxing/datamatrix/decoder/Decoder.h | 2 +- src/zxing/zxing/oned/CodaBarReader.cpp | 2 +- src/zxing/zxing/oned/Code128Reader.cpp | 10 ++--- src/zxing/zxing/oned/Code39Reader.cpp | 10 ++--- src/zxing/zxing/oned/Code93Reader.cpp | 10 ++--- src/zxing/zxing/oned/EAN13Reader.cpp | 6 +-- src/zxing/zxing/oned/EAN8Reader.cpp | 4 +- src/zxing/zxing/oned/ITFReader.cpp | 4 +- src/zxing/zxing/oned/UPCEReader.cpp | 6 +-- .../decoder/PDF417DecodedBitStreamParser.cpp | 36 ++++++++------- src/zxing/zxing/qrcode/QRCodeReader.cpp | 38 ++++++++-------- .../zxing/qrcode/QRFormatInformation.cpp | 3 +- .../zxing/qrcode/decoder/BitMatrixParser.h | 2 +- src/zxing/zxing/qrcode/decoder/DataBlock.h | 8 ++-- src/zxing/zxing/qrcode/decoder/Decoder.h | 2 +- .../qrcode/decoder/QRBitMatrixParser.cpp | 6 +-- .../zxing/qrcode/decoder/QRDataBlock.cpp | 8 ++-- .../decoder/QRDecodedBitStreamParser.cpp | 10 ++--- src/zxing/zxing/qrcode/decoder/QRDecoder.cpp | 8 ++-- src/zxing/zxing/qrcode/encoder/BlockPair.h | 6 +-- src/zxing/zxing/qrcode/encoder/Encoder.h | 2 +- src/zxing/zxing/qrcode/encoder/QREncoder.cpp | 12 ++--- 43 files changed, 215 insertions(+), 199 deletions(-) diff --git a/src/CameraImageWrapper.cpp b/src/CameraImageWrapper.cpp index 359bf4e..7b7e4d3 100644 --- a/src/CameraImageWrapper.cpp +++ b/src/CameraImageWrapper.cpp @@ -69,7 +69,7 @@ QImage CameraImageWrapper::getOriginalImage() return *image; } -ArrayRef CameraImageWrapper::getRow(int y, ArrayRef row) const +ArrayRef CameraImageWrapper::getRow(int y, ArrayRef row) const { if(delegate) return delegate->getRow(y, row); @@ -77,7 +77,7 @@ ArrayRef CameraImageWrapper::getRow(int y, ArrayRef row) const return getRowP(y, row); } -ArrayRef CameraImageWrapper::getMatrix() const +ArrayRef CameraImageWrapper::getMatrix() const { if(delegate) return delegate->getMatrix(); @@ -125,12 +125,12 @@ Ref CameraImageWrapper::rotateCounterClockwise() const return LuminanceSource::rotateCounterClockwise(); } -ArrayRef CameraImageWrapper::getRowP(int y, ArrayRef row) const +ArrayRef CameraImageWrapper::getRowP(int y, ArrayRef row) const { int width = getWidth(); if (row->size() != width) - row.reset(ArrayRef(width)); + row.reset(ArrayRef(width)); for (int x = 0; x < width; x++) { @@ -144,15 +144,15 @@ ArrayRef CameraImageWrapper::getRowP(int y, ArrayRef row) const return row; } -ArrayRef CameraImageWrapper::getMatrixP() const +ArrayRef CameraImageWrapper::getMatrixP() const { int width = getWidth(); int height = getHeight(); - ArrayRef tmpRow(0); - ArrayRef arr(width*height); + ArrayRef tmpRow(0); + ArrayRef arr(width*height); - char* m = &arr[0]; + byte* m = &arr[0]; for(int y=0; y getDelegate() { return delegate; } - ArrayRef getRow(int y, ArrayRef row) const; - ArrayRef getMatrix() const; + ArrayRef getRow(int y, ArrayRef row) const; + ArrayRef getMatrix() const; bool isCropSupported() const; Ref crop(int left, int top, int width, int height) const; @@ -30,8 +30,8 @@ public: Ref rotateCounterClockwise() const; private: - ArrayRef getRowP(int y, ArrayRef row) const; - ArrayRef getMatrixP() const; + ArrayRef getRowP(int y, ArrayRef row) const; + ArrayRef getMatrixP() const; #if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) QImage* grayScaleImage(const QImage *origin); #endif diff --git a/src/zxing/zxing/InvertedLuminanceSource.cpp b/src/zxing/zxing/InvertedLuminanceSource.cpp index 1039ce8..70428d8 100644 --- a/src/zxing/zxing/InvertedLuminanceSource.cpp +++ b/src/zxing/zxing/InvertedLuminanceSource.cpp @@ -22,12 +22,13 @@ using zxing::boolean; using zxing::Ref; using zxing::ArrayRef; using zxing::LuminanceSource; -using zxing::InvertedLuminanceSource; + +namespace zxing { InvertedLuminanceSource::InvertedLuminanceSource(Ref const& delegate_) : Super(delegate_->getWidth(), delegate_->getHeight()), delegate(delegate_) {} -ArrayRef InvertedLuminanceSource::getRow(int y, ArrayRef row) const { +ArrayRef InvertedLuminanceSource::getRow(int y, ArrayRef row) const { row = delegate->getRow(y, row); int width = getWidth(); for (int i = 0; i < width; i++) { @@ -36,10 +37,10 @@ ArrayRef InvertedLuminanceSource::getRow(int y, ArrayRef row) const return row; } -ArrayRef InvertedLuminanceSource::getMatrix() const { - ArrayRef matrix = delegate->getMatrix(); +ArrayRef InvertedLuminanceSource::getMatrix() const { + ArrayRef matrix = delegate->getMatrix(); int length = getWidth() * getHeight(); - ArrayRef invertedMatrix(length); + ArrayRef invertedMatrix(length); for (int i = 0; i < length; i++) { invertedMatrix[i] = (byte) (255 - (matrix[i] & 0xFF)); } @@ -66,3 +67,4 @@ Ref InvertedLuminanceSource::rotateCounterClockwise() const { return Ref(new InvertedLuminanceSource(delegate->rotateCounterClockwise())); } +} diff --git a/src/zxing/zxing/InvertedLuminanceSource.h b/src/zxing/zxing/InvertedLuminanceSource.h index 9f5a7cc..a3f7fbe 100644 --- a/src/zxing/zxing/InvertedLuminanceSource.h +++ b/src/zxing/zxing/InvertedLuminanceSource.h @@ -30,8 +30,8 @@ private: public: InvertedLuminanceSource(Ref const&); - ArrayRef getRow(int y, ArrayRef row) const; - ArrayRef getMatrix() const; + ArrayRef getRow(int y, ArrayRef row) const; + ArrayRef getMatrix() const; boolean isCropSupported() const; Ref crop(int left, int top, int width, int height) const; diff --git a/src/zxing/zxing/LuminanceSource.cpp b/src/zxing/zxing/LuminanceSource.cpp index 4323614..04dc420 100644 --- a/src/zxing/zxing/LuminanceSource.cpp +++ b/src/zxing/zxing/LuminanceSource.cpp @@ -52,7 +52,7 @@ Ref LuminanceSource::rotateCounterClockwise45() const } LuminanceSource::operator std::string() const { - ArrayRef row; + ArrayRef row; std::ostringstream oss; for (int y = 0; y < getHeight(); y++) { row = getRow(y, row); diff --git a/src/zxing/zxing/LuminanceSource.h b/src/zxing/zxing/LuminanceSource.h index 4287a86..dfe4051 100644 --- a/src/zxing/zxing/LuminanceSource.h +++ b/src/zxing/zxing/LuminanceSource.h @@ -40,8 +40,8 @@ class LuminanceSource : public Counted { int getHeight() const { return height; } // Callers take ownership of the returned memory and must call delete [] on it themselves. - virtual ArrayRef getRow(int y, ArrayRef row) const = 0; - virtual ArrayRef getMatrix() const = 0; + virtual ArrayRef getRow(int y, ArrayRef row) const = 0; + virtual ArrayRef getMatrix() const = 0; virtual bool isCropSupported() const; virtual Ref crop(int left, int top, int width, int height) const; diff --git a/src/zxing/zxing/common/GlobalHistogramBinarizer.cpp b/src/zxing/zxing/common/GlobalHistogramBinarizer.cpp index ecbccd6..4073731 100644 --- a/src/zxing/zxing/common/GlobalHistogramBinarizer.cpp +++ b/src/zxing/zxing/common/GlobalHistogramBinarizer.cpp @@ -22,7 +22,6 @@ #include #include -using zxing::GlobalHistogramBinarizer; using zxing::Binarizer; using zxing::ArrayRef; using zxing::Ref; @@ -32,12 +31,12 @@ using zxing::BitMatrix; // VC++ using zxing::LuminanceSource; -namespace { +namespace zxing { + const int LUMINANCE_BITS = 5; const int LUMINANCE_SHIFT = 8 - LUMINANCE_BITS; const int LUMINANCE_BUCKETS = 1 << LUMINANCE_BITS; -const ArrayRef EMPTY (0); -} +const ArrayRef EMPTY (0); GlobalHistogramBinarizer::GlobalHistogramBinarizer(Ref source) : Binarizer(source), luminances(EMPTY), buckets(LUMINANCE_BUCKETS) {} @@ -46,7 +45,7 @@ GlobalHistogramBinarizer::~GlobalHistogramBinarizer() {} void GlobalHistogramBinarizer::initArrays(int luminanceSize) { if (luminances->size() < luminanceSize) { - luminances = ArrayRef(luminanceSize); + luminances = ArrayRef(luminanceSize); } // for (int x = 0; x < LUMINANCE_BUCKETS; x++) { // buckets[x] = 0; @@ -65,7 +64,7 @@ Ref GlobalHistogramBinarizer::getBlackRow(int y, Ref row) { } initArrays(width); - ArrayRef localLuminances = source.getRow(y, luminances); + ArrayRef localLuminances = source.getRow(y, luminances); if (false) { std::cerr << "gbr " << y << " r "; for(int i=0, e=localLuminances->size(); i < e; ++i) { @@ -109,7 +108,7 @@ Ref GlobalHistogramBinarizer::getBlackMatrix() { ArrayRef localBuckets = buckets; for (int y = 1; y < 5; y++) { int row = height * y / 5; - ArrayRef localLuminances = source.getRow(row, luminances); + ArrayRef localLuminances = source.getRow(row, luminances); int right = (width << 2) / 5; for (int x = width / 5; x < right; x++) { int pixel = localLuminances[x] & 0xff; @@ -119,7 +118,7 @@ Ref GlobalHistogramBinarizer::getBlackMatrix() { int blackPoint = estimateBlackPoint(localBuckets); - ArrayRef localLuminances = source.getMatrix(); + ArrayRef localLuminances = source.getMatrix(); for (int y = 0; y < height; y++) { int offset = y * width; for (int x = 0; x < width; x++) { @@ -211,3 +210,5 @@ int GlobalHistogramBinarizer::estimateBlackPoint(ArrayRef const& buckets) { Ref GlobalHistogramBinarizer::createBinarizer(Ref source) { return Ref (new GlobalHistogramBinarizer(source)); } + +} diff --git a/src/zxing/zxing/common/GlobalHistogramBinarizer.h b/src/zxing/zxing/common/GlobalHistogramBinarizer.h index b0d1bd4..e60e7fc 100644 --- a/src/zxing/zxing/common/GlobalHistogramBinarizer.h +++ b/src/zxing/zxing/common/GlobalHistogramBinarizer.h @@ -29,7 +29,7 @@ namespace zxing { class GlobalHistogramBinarizer : public Binarizer { private: - ArrayRef luminances; + ArrayRef luminances; ArrayRef buckets; public: GlobalHistogramBinarizer(Ref source); diff --git a/src/zxing/zxing/common/GreyscaleLuminanceSource.cpp b/src/zxing/zxing/common/GreyscaleLuminanceSource.cpp index ee78bc7..2b5df4f 100644 --- a/src/zxing/zxing/common/GreyscaleLuminanceSource.cpp +++ b/src/zxing/zxing/common/GreyscaleLuminanceSource.cpp @@ -25,10 +25,11 @@ using zxing::Ref; using zxing::ArrayRef; using zxing::LuminanceSource; -using zxing::GreyscaleLuminanceSource; + +namespace zxing { GreyscaleLuminanceSource:: -GreyscaleLuminanceSource(ArrayRef greyData, +GreyscaleLuminanceSource(ArrayRef greyData, int dataWidth, int dataHeight, int left, int top, int width, int height) @@ -42,13 +43,13 @@ GreyscaleLuminanceSource(ArrayRef greyData, } } -ArrayRef GreyscaleLuminanceSource::getRow(int y, ArrayRef row) const { +ArrayRef GreyscaleLuminanceSource::getRow(int y, ArrayRef row) const { if (y < 0 || y >= this->getHeight()) { throw IllegalArgumentException("Requested row is outside the image."); } int width = getWidth(); if (!row || row->size() < width) { - ArrayRef temp (width); + ArrayRef temp (width); row = temp; } int offset = (y + top_) * dataWidth_ + left_; @@ -56,9 +57,9 @@ ArrayRef GreyscaleLuminanceSource::getRow(int y, ArrayRef row) const return row; } -ArrayRef GreyscaleLuminanceSource::getMatrix() const { +ArrayRef GreyscaleLuminanceSource::getMatrix() const { int size = getWidth() * getHeight(); - ArrayRef result (size); + ArrayRef result (size); if (left_ == 0 && top_ == 0 && dataWidth_ == getWidth() && dataHeight_ == getHeight()) { memcpy(&result[0], &greyData_[0], size); } else { @@ -78,3 +79,5 @@ Ref GreyscaleLuminanceSource::rotateCounterClockwise() const { top_, left_, getHeight(), getWidth())); return result; } + +} diff --git a/src/zxing/zxing/common/GreyscaleLuminanceSource.h b/src/zxing/zxing/common/GreyscaleLuminanceSource.h index 8275323..20ae936 100644 --- a/src/zxing/zxing/common/GreyscaleLuminanceSource.h +++ b/src/zxing/zxing/common/GreyscaleLuminanceSource.h @@ -28,18 +28,18 @@ class GreyscaleLuminanceSource : public LuminanceSource { private: typedef LuminanceSource Super; - ArrayRef greyData_; + ArrayRef greyData_; const int dataWidth_; const int dataHeight_; const int left_; const int top_; public: - GreyscaleLuminanceSource(ArrayRef greyData, int dataWidth, int dataHeight, int left, + GreyscaleLuminanceSource(ArrayRef greyData, int dataWidth, int dataHeight, int left, int top, int width, int height); - ArrayRef getRow(int y, ArrayRef row) const; - ArrayRef getMatrix() const; + ArrayRef getRow(int y, ArrayRef row) const; + ArrayRef getMatrix() const; bool isRotateSupported() const { return true; diff --git a/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.cpp b/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.cpp index 1d053f8..ceed28d 100644 --- a/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.cpp +++ b/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.cpp @@ -23,13 +23,14 @@ #include using zxing::ArrayRef; -using zxing::GreyscaleRotatedLuminanceSource; + +namespace zxing { // Note that dataWidth and dataHeight are not reversed, as we need to // be able to traverse the greyData correctly, which does not get // rotated. GreyscaleRotatedLuminanceSource:: -GreyscaleRotatedLuminanceSource(ArrayRef greyData, +GreyscaleRotatedLuminanceSource(ArrayRef greyData, int dataWidth, int dataHeight, int left, int top, int width, int height) @@ -44,13 +45,13 @@ GreyscaleRotatedLuminanceSource(ArrayRef greyData, } // The API asks for rows, but we're rotated, so we return columns. -ArrayRef -GreyscaleRotatedLuminanceSource::getRow(int y, ArrayRef row) const { +ArrayRef +GreyscaleRotatedLuminanceSource::getRow(int y, ArrayRef row) const { if (y < 0 || y >= getHeight()) { throw IllegalArgumentException("Requested row is outside the image."); } if (!row || row->size() < getWidth()) { - row = ArrayRef(getWidth()); + row = ArrayRef(getWidth()); } int offset = (left_ * dataWidth_) + (dataWidth_ - 1 - (y + top_)); using namespace std; @@ -67,10 +68,10 @@ GreyscaleRotatedLuminanceSource::getRow(int y, ArrayRef row) const { return row; } -ArrayRef GreyscaleRotatedLuminanceSource::getMatrix() const { - ArrayRef result (getWidth() * getHeight()); +ArrayRef GreyscaleRotatedLuminanceSource::getMatrix() const { + ArrayRef result (getWidth() * getHeight()); for (int y = 0; y < getHeight(); y++) { - char* row = &result[y * getWidth()]; + byte* row = &result[y * getWidth()]; int offset = (left_ * dataWidth_) + (dataWidth_ - 1 - (y + top_)); for (int x = 0; x < getWidth(); x++) { row[x] = greyData_[offset]; @@ -79,3 +80,5 @@ ArrayRef GreyscaleRotatedLuminanceSource::getMatrix() const { } return result; } + +} diff --git a/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.h b/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.h index 6af60f9..2ef8287 100644 --- a/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.h +++ b/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.h @@ -28,17 +28,17 @@ namespace zxing { class GreyscaleRotatedLuminanceSource : public LuminanceSource { private: typedef LuminanceSource Super; - ArrayRef greyData_; + ArrayRef greyData_; const int dataWidth_; const int left_; const int top_; public: - GreyscaleRotatedLuminanceSource(ArrayRef greyData, int dataWidth, int dataHeight, + GreyscaleRotatedLuminanceSource(ArrayRef greyData, int dataWidth, int dataHeight, int left, int top, int width, int height); - ArrayRef getRow(int y, ArrayRef row) const; - ArrayRef getMatrix() const; + ArrayRef getRow(int y, ArrayRef row) const; + ArrayRef getMatrix() const; }; } diff --git a/src/zxing/zxing/common/HybridBinarizer.cpp b/src/zxing/zxing/common/HybridBinarizer.cpp index 1789e24..060c715 100644 --- a/src/zxing/zxing/common/HybridBinarizer.cpp +++ b/src/zxing/zxing/common/HybridBinarizer.cpp @@ -59,7 +59,7 @@ Ref HybridBinarizer::getBlackMatrix() { int width = source.getWidth(); int height = source.getHeight(); if (width >= MINIMUM_DIMENSION && height >= MINIMUM_DIMENSION) { - ArrayRef luminances = source.getMatrix(); + ArrayRef luminances = source.getMatrix(); int subWidth = width >> BLOCK_SIZE_POWER; if ((width & BLOCK_SIZE_MASK) != 0) { subWidth++; @@ -94,7 +94,7 @@ namespace { } void -HybridBinarizer::calculateThresholdForBlock(ArrayRef luminances, +HybridBinarizer::calculateThresholdForBlock(ArrayRef luminances, int subWidth, int subHeight, int width, @@ -130,7 +130,7 @@ HybridBinarizer::calculateThresholdForBlock(ArrayRef luminances, } } -void HybridBinarizer::thresholdBlock(ArrayRef luminances, +void HybridBinarizer::thresholdBlock(ArrayRef luminances, int xoffset, int yoffset, int threshold, @@ -157,7 +157,7 @@ namespace { } -ArrayRef HybridBinarizer::calculateBlackPoints(ArrayRef luminances, +ArrayRef HybridBinarizer::calculateBlackPoints(ArrayRef luminances, int subWidth, int subHeight, int width, diff --git a/src/zxing/zxing/common/HybridBinarizer.h b/src/zxing/zxing/common/HybridBinarizer.h index 932c2a2..b85c4b0 100644 --- a/src/zxing/zxing/common/HybridBinarizer.h +++ b/src/zxing/zxing/common/HybridBinarizer.h @@ -42,19 +42,19 @@ namespace zxing { private: // We'll be using one-D arrays because C++ can't dynamically allocate 2D // arrays - ArrayRef calculateBlackPoints(ArrayRef luminances, + ArrayRef calculateBlackPoints(ArrayRef luminances, int subWidth, int subHeight, int width, int height); - void calculateThresholdForBlock(ArrayRef luminances, + void calculateThresholdForBlock(ArrayRef luminances, int subWidth, int subHeight, int width, int height, ArrayRef blackPoints, Ref const& matrix); - void thresholdBlock(ArrayRefluminances, + void thresholdBlock(ArrayRefluminances, int xoffset, int yoffset, int threshold, diff --git a/src/zxing/zxing/datamatrix/decoder/BitMatrixParser.h b/src/zxing/zxing/datamatrix/decoder/BitMatrixParser.h index aed7b61..37c4514 100644 --- a/src/zxing/zxing/datamatrix/decoder/BitMatrixParser.h +++ b/src/zxing/zxing/datamatrix/decoder/BitMatrixParser.h @@ -41,7 +41,7 @@ private: public: BitMatrixParser(Ref bitMatrix); Ref readVersion(Ref bitMatrix); - ArrayRef readCodewords(); + ArrayRef readCodewords(); bool readModule(int row, int column, int numRows, int numColumns); private: diff --git a/src/zxing/zxing/datamatrix/decoder/DataBlock.h b/src/zxing/zxing/datamatrix/decoder/DataBlock.h index 5bc48db..9ff8dc3 100644 --- a/src/zxing/zxing/datamatrix/decoder/DataBlock.h +++ b/src/zxing/zxing/datamatrix/decoder/DataBlock.h @@ -32,15 +32,15 @@ namespace datamatrix { class DataBlock : public Counted { private: int numDataCodewords_; - ArrayRef codewords_; + ArrayRef codewords_; - DataBlock(int numDataCodewords, ArrayRef codewords); + DataBlock(int numDataCodewords, ArrayRef codewords); public: - static std::vector > getDataBlocks(ArrayRef rawCodewords, Version *version); + static std::vector > getDataBlocks(ArrayRef rawCodewords, Version *version); int getNumDataCodewords(); - ArrayRef getCodewords(); + ArrayRef getCodewords(); }; } diff --git a/src/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp b/src/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp index 9463468..37b242e 100644 --- a/src/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp +++ b/src/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp @@ -57,8 +57,8 @@ Ref BitMatrixParser::readVersion(Ref bitMatrix) { throw ReaderException("Couldn't decode version"); } -ArrayRef BitMatrixParser::readCodewords() { - ArrayRef result(parsedVersion_->getTotalCodewords()); +ArrayRef BitMatrixParser::readCodewords() { + ArrayRef result(parsedVersion_->getTotalCodewords()); int resultOffset = 0; int row = 4; int column = 0; @@ -75,22 +75,22 @@ ArrayRef BitMatrixParser::readCodewords() { do { // Check the four corner cases if ((row == numRows) && (column == 0) && !corner1Read) { - result[resultOffset++] = (char) readCorner1(numRows, numColumns); + result[resultOffset++] = (byte) readCorner1(numRows, numColumns); row -= 2; column +=2; corner1Read = true; } else if ((row == numRows-2) && (column == 0) && ((numColumns & 0x03) != 0) && !corner2Read) { - result[resultOffset++] = (char) readCorner2(numRows, numColumns); + result[resultOffset++] = (byte) readCorner2(numRows, numColumns); row -= 2; column +=2; corner2Read = true; } else if ((row == numRows+4) && (column == 2) && ((numColumns & 0x07) == 0) && !corner3Read) { - result[resultOffset++] = (char) readCorner3(numRows, numColumns); + result[resultOffset++] = (byte) readCorner3(numRows, numColumns); row -= 2; column +=2; corner3Read = true; } else if ((row == numRows-2) && (column == 0) && ((numColumns & 0x07) == 4) && !corner4Read) { - result[resultOffset++] = (char) readCorner4(numRows, numColumns); + result[resultOffset++] = (byte) readCorner4(numRows, numColumns); row -= 2; column +=2; corner4Read = true; @@ -98,7 +98,7 @@ ArrayRef BitMatrixParser::readCodewords() { // Sweep upward diagonally to the right do { if ((row < numRows) && (column >= 0) && !readBitMatrix_->get(column, row)) { - result[resultOffset++] = (char) readUtah(row, column, numRows, numColumns); + result[resultOffset++] = (byte) readUtah(row, column, numRows, numColumns); } row -= 2; column +=2; @@ -109,7 +109,7 @@ ArrayRef BitMatrixParser::readCodewords() { // Sweep downward diagonally to the left do { if ((row >= 0) && (column < numColumns) && !readBitMatrix_->get(column, row)) { - result[resultOffset++] = (char) readUtah(row, column, numRows, numColumns); + result[resultOffset++] = (byte) readUtah(row, column, numRows, numColumns); } row += 2; column -=2; diff --git a/src/zxing/zxing/datamatrix/decoder/DataMatrixDataBlock.cpp b/src/zxing/zxing/datamatrix/decoder/DataMatrixDataBlock.cpp index 1cbfaf3..474fd48 100644 --- a/src/zxing/zxing/datamatrix/decoder/DataMatrixDataBlock.cpp +++ b/src/zxing/zxing/datamatrix/decoder/DataMatrixDataBlock.cpp @@ -26,7 +26,7 @@ namespace datamatrix { using namespace std; -DataBlock::DataBlock(int numDataCodewords, ArrayRef codewords) : +DataBlock::DataBlock(int numDataCodewords, ArrayRef codewords) : numDataCodewords_(numDataCodewords), codewords_(codewords) { } @@ -34,11 +34,11 @@ int DataBlock::getNumDataCodewords() { return numDataCodewords_; } -ArrayRef DataBlock::getCodewords() { +ArrayRef DataBlock::getCodewords() { return codewords_; } -std::vector > DataBlock::getDataBlocks(ArrayRef rawCodewords, Version *version) { +std::vector > DataBlock::getDataBlocks(ArrayRef rawCodewords, Version *version) { // Figure out the number and size of data blocks used by this version and // error correction level ECBlocks* ecBlocks = version->getECBlocks(); @@ -58,7 +58,7 @@ std::vector > DataBlock::getDataBlocks(ArrayRef rawCodeword for (int i = 0; i < ecBlock->getCount(); i++) { int numDataCodewords = ecBlock->getDataCodewords(); int numBlockCodewords = ecBlocks->getECCodewords() + numDataCodewords; - ArrayRef buffer(numBlockCodewords); + ArrayRef buffer(numBlockCodewords); Ref blockRef(new DataBlock(numDataCodewords, buffer)); result[numResultBlocks++] = blockRef; } diff --git a/src/zxing/zxing/datamatrix/decoder/DataMatrixDecodedBitStreamParser.cpp b/src/zxing/zxing/datamatrix/decoder/DataMatrixDecodedBitStreamParser.cpp index 0ec2854..b4dbf2e 100644 --- a/src/zxing/zxing/datamatrix/decoder/DataMatrixDecodedBitStreamParser.cpp +++ b/src/zxing/zxing/datamatrix/decoder/DataMatrixDecodedBitStreamParser.cpp @@ -48,14 +48,14 @@ const char DecodedBitStreamParser::TEXT_BASIC_SET_CHARS[] = { const char DecodedBitStreamParser::TEXT_SHIFT3_SET_CHARS[] = { '\'', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~', (char) 127 + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~', (byte) 127 }; Ref DecodedBitStreamParser::decode(ArrayRef bytes) { Ref bits(new BitSource(bytes)); ostringstream result; ostringstream resultTrailer; - vector byteSegments; + vector byteSegments; int mode = ASCII_ENCODE; do { if (mode == ASCII_ENCODE) { @@ -102,7 +102,7 @@ int DecodedBitStreamParser::decodeAsciiSegment(Ref bits, ostringstrea } else if (oneByte <= 128) { // ASCII data (ASCII value + 1) oneByte = upperShift ? (oneByte + 128) : oneByte; // upperShift = false; - result << (char) (oneByte - 1); + result << (byte) (oneByte - 1); return ASCII_ENCODE; } else if (oneByte == 129) { // Pad return PAD_ENCODE; @@ -117,7 +117,7 @@ int DecodedBitStreamParser::decodeAsciiSegment(Ref bits, ostringstrea } else if (oneByte == 231) { // Latch to Base 256 encodation return BASE256_ENCODE; } else if (oneByte == 232) { // FNC1 - result << ((char) 29); // translate as ASCII 29 + result << ((byte) 29); // translate as ASCII 29 } else if (oneByte == 233 || oneByte == 234) { // Structured Append, Reader Programming // Ignore these symbols for now @@ -178,7 +178,7 @@ void DecodedBitStreamParser::decodeC40Segment(Ref bits, ostringstream shift = cValue + 1; } else { if (upperShift) { - result << (char) (C40_BASIC_SET_CHARS[cValue] + 128); + result << (byte) (C40_BASIC_SET_CHARS[cValue] + 128); upperShift = false; } else { result << C40_BASIC_SET_CHARS[cValue]; @@ -187,23 +187,23 @@ void DecodedBitStreamParser::decodeC40Segment(Ref bits, ostringstream break; case 1: if (upperShift) { - result << (char) (cValue + 128); + result << (byte) (cValue + 128); upperShift = false; } else { - result << (char) cValue; + result << (byte) cValue; } shift = 0; break; case 2: if (cValue < 27) { if (upperShift) { - result << (char) (C40_SHIFT2_SET_CHARS[cValue] + 128); + result << (byte) (C40_SHIFT2_SET_CHARS[cValue] + 128); upperShift = false; } else { result << C40_SHIFT2_SET_CHARS[cValue]; } } else if (cValue == 27) { // FNC1 - result << ((char) 29); // translate as ASCII 29 + result << ((byte) 29); // translate as ASCII 29 } else if (cValue == 30) { // Upper Shift upperShift = true; } else { @@ -213,10 +213,10 @@ void DecodedBitStreamParser::decodeC40Segment(Ref bits, ostringstream break; case 3: if (upperShift) { - result << (char) (cValue + 224); + result << (byte) (cValue + 224); upperShift = false; } else { - result << (char) (cValue + 96); + result << (byte) (cValue + 96); } shift = 0; break; @@ -255,7 +255,7 @@ void DecodedBitStreamParser::decodeTextSegment(Ref bits, ostringstrea shift = cValue + 1; } else { if (upperShift) { - result << (char) (TEXT_BASIC_SET_CHARS[cValue] + 128); + result << (byte) (TEXT_BASIC_SET_CHARS[cValue] + 128); upperShift = false; } else { result << (TEXT_BASIC_SET_CHARS[cValue]); @@ -264,10 +264,10 @@ void DecodedBitStreamParser::decodeTextSegment(Ref bits, ostringstrea break; case 1: if (upperShift) { - result << (char) (cValue + 128); + result << (byte) (cValue + 128); upperShift = false; } else { - result << (char) (cValue); + result << (byte) (cValue); } shift = 0; break; @@ -275,13 +275,13 @@ void DecodedBitStreamParser::decodeTextSegment(Ref bits, ostringstrea // Shift 2 for Text is the same encoding as C40 if (cValue < 27) { if (upperShift) { - result << (char) (C40_SHIFT2_SET_CHARS[cValue] + 128); + result << (byte) (C40_SHIFT2_SET_CHARS[cValue] + 128); upperShift = false; } else { result << (C40_SHIFT2_SET_CHARS[cValue]); } } else if (cValue == 27) { // FNC1 - result << ((char) 29); // translate as ASCII 29 + result << ((byte) 29); // translate as ASCII 29 } else if (cValue == 30) { // Upper Shift upperShift = true; } else { @@ -291,7 +291,7 @@ void DecodedBitStreamParser::decodeTextSegment(Ref bits, ostringstrea break; case 3: if (upperShift) { - result << (char) (TEXT_SHIFT3_SET_CHARS[cValue] + 128); + result << (byte) (TEXT_SHIFT3_SET_CHARS[cValue] + 128); upperShift = false; } else { result << (TEXT_SHIFT3_SET_CHARS[cValue]); @@ -333,9 +333,9 @@ void DecodedBitStreamParser::decodeAnsiX12Segment(Ref bits, ostringst } else if (cValue == 3) { // space result << ' '; } else if (cValue < 14) { // 0 - 9 - result << (char) (cValue + 44); + result << (byte) (cValue + 44); } else if (cValue < 40) { // A - Z - result << (char) (cValue + 51); + result << (byte) (cValue + 51); } else { throw FormatException("decodeAnsiX12Segment: no case"); } @@ -376,12 +376,12 @@ void DecodedBitStreamParser::decodeEdifactSegment(Ref bits, ostringst if ((edifactValue & 0x20) == 0) { // no 1 in the leading (6th) bit edifactValue |= 0x40; // Add a leading 01 to the 6 bit binary value } - result << (char)(edifactValue); + result << (byte)(edifactValue); } } while (bits->available() > 0); } -void DecodedBitStreamParser::decodeBase256Segment(Ref bits, ostringstream& result, vector byteSegments) { +void DecodedBitStreamParser::decodeBase256Segment(Ref bits, ostringstream& result, vector byteSegments) { // Figure out how long the Base 256 Segment is. int codewordPosition = 1 + bits->getByteOffset(); // position is 1-indexed int d1 = unrandomize255State(bits->readBits(8), codewordPosition++); @@ -408,7 +408,7 @@ void DecodedBitStreamParser::decodeBase256Segment(Ref bits, ostringst } bytes[i] = unrandomize255State(bits->readBits(8), codewordPosition++); byteSegments.push_back(bytes[i]); - result << (char)bytes[i]; + result << (byte)bytes[i]; } } } diff --git a/src/zxing/zxing/datamatrix/decoder/DataMatrixDecoder.cpp b/src/zxing/zxing/datamatrix/decoder/DataMatrixDecoder.cpp index 1842fa1..0d3afb2 100644 --- a/src/zxing/zxing/datamatrix/decoder/DataMatrixDecoder.cpp +++ b/src/zxing/zxing/datamatrix/decoder/DataMatrixDecoder.cpp @@ -39,7 +39,7 @@ using zxing::BitMatrix; Decoder::Decoder() : rsDecoder_(GenericGF::DATA_MATRIX_FIELD_256) {} -void Decoder::correctErrors(ArrayRef codewordBytes, int numDataCodewords) { +void Decoder::correctErrors(ArrayRef codewordBytes, int numDataCodewords) { int numCodewords = codewordBytes->size(); ArrayRef codewordInts(numCodewords); for (int i = 0; i < numCodewords; i++) { @@ -55,7 +55,7 @@ void Decoder::correctErrors(ArrayRef codewordBytes, int numDataCodewords) // Copy back into array of bytes -- only need to worry about the bytes that were data // We don't care about errors in the error-correction codewords for (int i = 0; i < numDataCodewords; i++) { - codewordBytes[i] = (char)codewordInts[i]; + codewordBytes[i] = (byte)codewordInts[i]; } } @@ -65,7 +65,7 @@ Ref Decoder::decode(Ref bits) { Version *version = parser.readVersion(bits); // Read codewords - ArrayRef codewords(parser.readCodewords()); + ArrayRef codewords(parser.readCodewords()); // Separate into data blocks std::vector > dataBlocks = DataBlock::getDataBlocks(codewords, version); @@ -81,7 +81,7 @@ Ref Decoder::decode(Ref bits) { // Error-correct and copy data blocks together into a stream of bytes for (int j = 0; j < dataBlocksCount; j++) { Ref dataBlock(dataBlocks[j]); - ArrayRef codewordBytes = dataBlock->getCodewords(); + ArrayRef codewordBytes = dataBlock->getCodewords(); int numDataCodewords = dataBlock->getNumDataCodewords(); correctErrors(codewordBytes, numDataCodewords); for (int i = 0; i < numDataCodewords; i++) { diff --git a/src/zxing/zxing/datamatrix/decoder/DecodedBitStreamParser.h b/src/zxing/zxing/datamatrix/decoder/DecodedBitStreamParser.h index 93aa0b4..7ee2a6e 100644 --- a/src/zxing/zxing/datamatrix/decoder/DecodedBitStreamParser.h +++ b/src/zxing/zxing/datamatrix/decoder/DecodedBitStreamParser.h @@ -79,7 +79,7 @@ private: /** * See ISO 16022:2006, 5.2.9 and Annex B, B.2 */ - void decodeBase256Segment(Ref bits, std::ostringstream &result, std::vector byteSegments); + void decodeBase256Segment(Ref bits, std::ostringstream &result, std::vector byteSegments); void parseTwoBytes(int firstByte, int secondByte, int* result); /** @@ -89,7 +89,7 @@ private: int base256CodewordPosition) { int pseudoRandomNumber = ((149 * base256CodewordPosition) % 255) + 1; int tempVariable = randomizedBase256Codeword - pseudoRandomNumber; - return (char) (tempVariable >= 0 ? tempVariable : (tempVariable + 256)); + return (byte) (tempVariable >= 0 ? tempVariable : (tempVariable + 256)); }; void append(std::ostream &ost, const char *bufIn, size_t nIn, const char *src); diff --git a/src/zxing/zxing/datamatrix/decoder/Decoder.h b/src/zxing/zxing/datamatrix/decoder/Decoder.h index 6394a9f..31c0743 100644 --- a/src/zxing/zxing/datamatrix/decoder/Decoder.h +++ b/src/zxing/zxing/datamatrix/decoder/Decoder.h @@ -35,7 +35,7 @@ class Decoder { private: ReedSolomonDecoder rsDecoder_; - void correctErrors(ArrayRef bytes, int numDataCodewords); + void correctErrors(ArrayRef bytes, int numDataCodewords); public: Decoder(); diff --git a/src/zxing/zxing/oned/CodaBarReader.cpp b/src/zxing/zxing/oned/CodaBarReader.cpp index d107d96..2913ab2 100644 --- a/src/zxing/zxing/oned/CodaBarReader.cpp +++ b/src/zxing/zxing/oned/CodaBarReader.cpp @@ -96,7 +96,7 @@ Ref CodaBarReader::decodeRow(int rowNumber, Ref row) { // Hack: We store the position in the alphabet table into a // StringBuilder, so that we can access the decoded patterns in // validatePattern. We'll translate to the actual characters later. - decodeRowResult.append(1, (char)charOffset); + decodeRowResult.append(1, (byte)charOffset); nextStart += 8; // Stop as soon as we see the end character. if (decodeRowResult.length() > 1 && diff --git a/src/zxing/zxing/oned/Code128Reader.cpp b/src/zxing/zxing/oned/Code128Reader.cpp index 437f368..7eb7933 100644 --- a/src/zxing/zxing/oned/Code128Reader.cpp +++ b/src/zxing/zxing/oned/Code128Reader.cpp @@ -271,7 +271,7 @@ Ref Code128Reader::decodeRow(int rowNumber, Ref row) { bool isNextShifted = false; string result; - vector rawCodes(20, 0); + vector rawCodes(20, 0); int lastStart = startPatternInfo[0]; int nextStart = startPatternInfo[1]; @@ -324,9 +324,9 @@ Ref Code128Reader::decodeRow(int rowNumber, Ref row) { case CODE_CODE_A: if (code < 64) { - result.append(1, (char) (' ' + code)); + result.append(1, (byte) (' ' + code)); } else if (code < 96) { - result.append(1, (char) (code - 64)); + result.append(1, (byte) (code - 64)); } else { // Don't let CODE_STOP, which always appears, affect whether whether we think the // last code was printable or not. @@ -342,7 +342,7 @@ Ref Code128Reader::decodeRow(int rowNumber, Ref row) { result.append("]C1"); } else { // GS1 specification 5.4.7.5. Every subsequent FNC1 is returned as ASCII 29 (GS) - result.append(1, (char) 29); + result.append(1, (byte) 29); } } break; @@ -369,7 +369,7 @@ Ref Code128Reader::decodeRow(int rowNumber, Ref row) { break; case CODE_CODE_B: if (code < 96) { - result.append(1, (char) (' ' + code)); + result.append(1, (byte) (' ' + code)); } else { if (code != CODE_STOP) { lastCharacterWasPrintable = false; diff --git a/src/zxing/zxing/oned/Code39Reader.cpp b/src/zxing/zxing/oned/Code39Reader.cpp index 0ae9b83..312260b 100644 --- a/src/zxing/zxing/oned/Code39Reader.cpp +++ b/src/zxing/zxing/oned/Code39Reader.cpp @@ -283,7 +283,7 @@ Ref Code39Reader::decodeExtended(std::string encoded){ case '+': // +A to +Z map to a to z if (next >= 'A' && next <= 'Z') { - decodedChar = (char) (next + 32); + decodedChar = (byte) (next + 32); } else { throw ReaderException(""); } @@ -291,7 +291,7 @@ Ref Code39Reader::decodeExtended(std::string encoded){ case '$': // $A to $Z map to control codes SH to SB if (next >= 'A' && next <= 'Z') { - decodedChar = (char) (next - 64); + decodedChar = (byte) (next - 64); } else { throw ReaderException(""); } @@ -299,9 +299,9 @@ Ref Code39Reader::decodeExtended(std::string encoded){ case '%': // %A to %E map to control codes ESC to US if (next >= 'A' && next <= 'E') { - decodedChar = (char) (next - 38); + decodedChar = (byte) (next - 38); } else if (next >= 'F' && next <= 'W') { - decodedChar = (char) (next - 11); + decodedChar = (byte) (next - 11); } else { throw ReaderException(""); } @@ -309,7 +309,7 @@ Ref Code39Reader::decodeExtended(std::string encoded){ case '/': // /A to /O map to ! to , and /Z maps to : if (next >= 'A' && next <= 'O') { - decodedChar = (char) (next - 32); + decodedChar = (byte) (next - 32); } else if (next == 'Z') { decodedChar = ':'; } else { diff --git a/src/zxing/zxing/oned/Code93Reader.cpp b/src/zxing/zxing/oned/Code93Reader.cpp index e5b14a8..8fd64e1 100644 --- a/src/zxing/zxing/oned/Code93Reader.cpp +++ b/src/zxing/zxing/oned/Code93Reader.cpp @@ -226,7 +226,7 @@ Ref Code93Reader::decodeExtended(string const& encoded) { case 'd': // +A to +Z map to a to z if (next >= 'A' && next <= 'Z') { - decodedChar = (char) (next + 32); + decodedChar = (byte) (next + 32); } else { throw FormatException::getFormatInstance(); } @@ -234,7 +234,7 @@ Ref Code93Reader::decodeExtended(string const& encoded) { case 'a': // $A to $Z map to control codes SH to SB if (next >= 'A' && next <= 'Z') { - decodedChar = (char) (next - 64); + decodedChar = (byte) (next - 64); } else { throw FormatException::getFormatInstance(); } @@ -242,9 +242,9 @@ Ref Code93Reader::decodeExtended(string const& encoded) { case 'b': // %A to %E map to control codes ESC to US if (next >= 'A' && next <= 'E') { - decodedChar = (char) (next - 38); + decodedChar = (byte) (next - 38); } else if (next >= 'F' && next <= 'W') { - decodedChar = (char) (next - 11); + decodedChar = (byte) (next - 11); } else { throw FormatException::getFormatInstance(); } @@ -252,7 +252,7 @@ Ref Code93Reader::decodeExtended(string const& encoded) { case 'c': // /A to /O map to ! to , and /Z maps to : if (next >= 'A' && next <= 'O') { - decodedChar = (char) (next - 32); + decodedChar = (byte) (next - 32); } else if (next == 'Z') { decodedChar = ':'; } else { diff --git a/src/zxing/zxing/oned/EAN13Reader.cpp b/src/zxing/zxing/oned/EAN13Reader.cpp index 9b9a640..86b823e 100644 --- a/src/zxing/zxing/oned/EAN13Reader.cpp +++ b/src/zxing/zxing/oned/EAN13Reader.cpp @@ -44,7 +44,7 @@ int EAN13Reader::decodeMiddle(Ref row, for (int x = 0; x < 6 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_AND_G_PATTERNS); - resultString.append(1, (char) ('0' + bestMatch % 10)); + resultString.append(1, (byte) ('0' + bestMatch % 10)); for (int i = 0, end = counters.size(); i row, for (int x = 0; x < 6 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); - resultString.append(1, (char) ('0' + bestMatch)); + resultString.append(1, (byte) ('0' + bestMatch)); for (int i = 0, end = counters.size(); i < end; i++) { rowOffset += counters[i]; } @@ -73,7 +73,7 @@ void EAN13Reader::determineFirstDigit(std::string& resultString, int lgPatternFo // std::cerr << "K " << resultString << " " << lgPatternFound << " " < row, for (int x = 0; x < 4 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); - result.append(1, (char) ('0' + bestMatch)); + result.append(1, (byte) ('0' + bestMatch)); for (int i = 0, end = counters.size(); i < end; i++) { rowOffset += counters[i]; } @@ -52,7 +52,7 @@ int EAN8Reader::decodeMiddle(Ref row, rowOffset = middleRange[1]; for (int x = 0; x < 4 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); - result.append(1, (char) ('0' + bestMatch)); + result.append(1, (byte) ('0' + bestMatch)); for (int i = 0, end = counters.size(); i < end; i++) { rowOffset += counters[i]; } diff --git a/src/zxing/zxing/oned/ITFReader.cpp b/src/zxing/zxing/oned/ITFReader.cpp index d593c40..59e7a56 100644 --- a/src/zxing/zxing/oned/ITFReader.cpp +++ b/src/zxing/zxing/oned/ITFReader.cpp @@ -151,9 +151,9 @@ void ITFReader::decodeMiddle(Ref row, } int bestMatch = decodeDigit(counterBlack); - resultString.append(1, (char) ('0' + bestMatch)); + resultString.append(1, (byte) ('0' + bestMatch)); bestMatch = decodeDigit(counterWhite); - resultString.append(1, (char) ('0' + bestMatch)); + resultString.append(1, (byte) ('0' + bestMatch)); for (int i = 0, e = counterDigitPair.size(); i < e; i++) { payloadStart += counterDigitPair[i]; diff --git a/src/zxing/zxing/oned/UPCEReader.cpp b/src/zxing/zxing/oned/UPCEReader.cpp index 799467f..faff7c2 100644 --- a/src/zxing/zxing/oned/UPCEReader.cpp +++ b/src/zxing/zxing/oned/UPCEReader.cpp @@ -64,7 +64,7 @@ int UPCEReader::decodeMiddle(Ref row, Range const& startRange, string& for (int x = 0; x < 6 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_AND_G_PATTERNS); - result.append(1, (char) ('0' + bestMatch % 10)); + result.append(1, (byte) ('0' + bestMatch % 10)); for (int i = 0, e = counters.size(); i < e; i++) { rowOffset += counters[i]; } @@ -91,8 +91,8 @@ bool UPCEReader::determineNumSysAndCheckDigit(std::string& resultString, int lgP for (int numSys = 0; numSys <= 1; numSys++) { for (int d = 0; d < 10; d++) { if (lgPatternFound == NUMSYS_AND_CHECK_DIGIT_PATTERNS[numSys][d]) { - resultString.insert((size_t)0, (size_t)1, (char) ('0' + numSys)); - resultString.append(1, (char) ('0' + d)); + resultString.insert((size_t)0, (size_t)1, (byte) ('0' + numSys)); + resultString.append(1, (byte) ('0' + d)); return true; } } diff --git a/src/zxing/zxing/pdf417/decoder/PDF417DecodedBitStreamParser.cpp b/src/zxing/zxing/pdf417/decoder/PDF417DecodedBitStreamParser.cpp index 73bf6c8..fd19718 100644 --- a/src/zxing/zxing/pdf417/decoder/PDF417DecodedBitStreamParser.cpp +++ b/src/zxing/zxing/pdf417/decoder/PDF417DecodedBitStreamParser.cpp @@ -28,6 +28,9 @@ using zxing::Ref; using zxing::DecoderResult; using zxing::String; +namespace zxing { +namespace pdf417 { + const int DecodedBitStreamParser::TEXT_COMPACTION_MODE_LATCH = 900; const int DecodedBitStreamParser::BYTE_COMPACTION_MODE_LATCH = 901; const int DecodedBitStreamParser::NUMERIC_COMPACTION_MODE_LATCH = 902; @@ -214,7 +217,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef textCompactionDa // Alpha (uppercase alphabetic) if (subModeCh < 26) { // Upper case Alpha Character - ch = (char) ('A' + subModeCh); + ch = (byte) ('A' + subModeCh); } else { if (subModeCh == 26) { ch = ' '; @@ -227,7 +230,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef textCompactionDa priorToShiftMode = subMode; subMode = PUNCT_SHIFT; } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { - result->append((char) byteCompactionData[i]); + result->append((byte) byteCompactionData[i]); } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { subMode = ALPHA; } @@ -237,7 +240,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef textCompactionDa case LOWER: // Lower (lowercase alphabetic) if (subModeCh < 26) { - ch = (char) ('a' + subModeCh); + ch = (byte) ('a' + subModeCh); } else { if (subModeCh == 26) { ch = ' '; @@ -252,7 +255,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef textCompactionDa priorToShiftMode = subMode; subMode = PUNCT_SHIFT; } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { - result->append((char) byteCompactionData[i]); + result->append((byte) byteCompactionData[i]); } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { subMode = ALPHA; } @@ -277,7 +280,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef textCompactionDa priorToShiftMode = subMode; subMode = PUNCT_SHIFT; } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { - result->append((char) byteCompactionData[i]); + result->append((byte) byteCompactionData[i]); } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { subMode = ALPHA; } @@ -292,7 +295,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef textCompactionDa if (subModeCh == PAL) { subMode = ALPHA; } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { - result->append((char) byteCompactionData[i]); + result->append((byte) byteCompactionData[i]); } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { subMode = ALPHA; } @@ -303,7 +306,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef textCompactionDa // Restore sub-mode subMode = priorToShiftMode; if (subModeCh < 26) { - ch = (char) ('A' + subModeCh); + ch = (byte) ('A' + subModeCh); } else { if (subModeCh == 26) { ch = ' '; @@ -329,7 +332,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef textCompactionDa } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { // PS before Shift-to-Byte is used as a padding character, // see 5.4.2.4 of the specification - result->append((char) byteCompactionData[i]); + result->append((byte) byteCompactionData[i]); } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { subMode = ALPHA; } @@ -363,7 +366,7 @@ int DecodedBitStreamParser::byteCompaction(int mode, // is not a multiple of 6 int count = 0; int64_t value = 0; - ArrayRef decodedData = new Array(6); + ArrayRef decodedData = new Array(6); ArrayRef byteCompactedCodewords = new Array(6); bool end = false; int nextCode = codewords[codeIndex++]; @@ -391,10 +394,10 @@ int DecodedBitStreamParser::byteCompaction(int mode, // Convert to Base 256 for (int j = 0; j < 6; ++j) { - decodedData[5 - j] = (char) (value%256); + decodedData[5 - j] = (byte) (value%256); value >>= 8; } - result->append(string(&(decodedData->values()[0]), decodedData->values().size())); + result->append(string((char*)&(decodedData->values()[0]), decodedData->values().size())); count = 0; } } @@ -409,7 +412,7 @@ int DecodedBitStreamParser::byteCompaction(int mode, // as one byte per codeword, without compaction. for (int i = 0; i < count; i++) { - result->append((char)byteCompactedCodewords[i]); + result->append((byte)byteCompactedCodewords[i]); } } else if (mode == BYTE_COMPACTION_MODE_LATCH_6) { @@ -439,12 +442,12 @@ int DecodedBitStreamParser::byteCompaction(int mode, if ((count % 5 == 0) && (count > 0)) { // Decode every 5 codewords // Convert to Base 256 - ArrayRef decodedData = new Array(6); + ArrayRef decodedData = new Array(6); for (int j = 0; j < 6; ++j) { - decodedData[5 - j] = (char) (value & 0xFF); + decodedData[5 - j] = (byte) (value & 0xFF); value >>= 8; } - result->append(string(&decodedData[0],6)); + result->append(string((char*)&decodedData[0],6)); // 2012-11-27 hfn after recent java code/fix by srowen count = 0; } @@ -561,3 +564,6 @@ Ref DecodedBitStreamParser::decodeBase900toBase10(ArrayRef codeword Ref res (new String(resultString2)); return res; } + +} +} diff --git a/src/zxing/zxing/qrcode/QRCodeReader.cpp b/src/zxing/zxing/qrcode/QRCodeReader.cpp index dee6606..7025052 100644 --- a/src/zxing/zxing/qrcode/QRCodeReader.cpp +++ b/src/zxing/zxing/qrcode/QRCodeReader.cpp @@ -25,28 +25,28 @@ #include namespace zxing { - namespace qrcode { - - using namespace std; - - QRCodeReader::QRCodeReader() :decoder_() { - } + namespace qrcode { + + using namespace std; + + QRCodeReader::QRCodeReader() :decoder_() { + } //TODO : see if any of the other files in the qrcode tree need tryHarder - Ref QRCodeReader::decode(Ref image, DecodeHints hints) { - Detector detector(image->getBlackMatrix()); - Ref detectorResult(detector.detect(hints)); - ArrayRef< Ref > points (detectorResult->getPoints()); - Ref decoderResult(decoder_.decode(detectorResult->getBits())); - Ref result( + Ref QRCodeReader::decode(Ref image, DecodeHints hints) { + Detector detector(image->getBlackMatrix()); + Ref detectorResult(detector.detect(hints)); + ArrayRef< Ref > points (detectorResult->getPoints()); + Ref decoderResult(decoder_.decode(detectorResult->getBits())); + Ref result( new Result(decoderResult->getText(), decoderResult->getRawBytes(), points, BarcodeFormat::QR_CODE, decoderResult->charSet())); - return result; - } - - QRCodeReader::~QRCodeReader() { - } - + return result; + } + + QRCodeReader::~QRCodeReader() { + } + Decoder& QRCodeReader::getDecoder() { return decoder_; } - } + } } diff --git a/src/zxing/zxing/qrcode/QRFormatInformation.cpp b/src/zxing/zxing/qrcode/QRFormatInformation.cpp index a2b653c..dfe4847 100644 --- a/src/zxing/zxing/qrcode/QRFormatInformation.cpp +++ b/src/zxing/zxing/qrcode/QRFormatInformation.cpp @@ -20,6 +20,7 @@ #include #include +#include namespace zxing { namespace qrcode { @@ -39,7 +40,7 @@ int FormatInformation::N_FORMAT_INFO_DECODE_LOOKUPS = 32; int FormatInformation::BITS_SET_IN_HALF_BYTE[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; FormatInformation::FormatInformation(int formatInfo) : - errorCorrectionLevel_(ErrorCorrectionLevel::forBits((formatInfo >> 3) & 0x03)), dataMask_((char)(formatInfo & 0x07)) { + errorCorrectionLevel_(ErrorCorrectionLevel::forBits((formatInfo >> 3) & 0x03)), dataMask_((byte)(formatInfo & 0x07)) { } ErrorCorrectionLevel& FormatInformation::getErrorCorrectionLevel() { diff --git a/src/zxing/zxing/qrcode/decoder/BitMatrixParser.h b/src/zxing/zxing/qrcode/decoder/BitMatrixParser.h index 4819c66..ed76f05 100644 --- a/src/zxing/zxing/qrcode/decoder/BitMatrixParser.h +++ b/src/zxing/zxing/qrcode/decoder/BitMatrixParser.h @@ -43,7 +43,7 @@ public: BitMatrixParser(Ref bitMatrix); Ref readFormatInformation(); Version *readVersion(); - ArrayRef readCodewords(); + ArrayRef readCodewords(); void remask(); void setMirror(boolean mirror); void mirror(); diff --git a/src/zxing/zxing/qrcode/decoder/DataBlock.h b/src/zxing/zxing/qrcode/decoder/DataBlock.h index f314530..96c76d4 100644 --- a/src/zxing/zxing/qrcode/decoder/DataBlock.h +++ b/src/zxing/zxing/qrcode/decoder/DataBlock.h @@ -32,16 +32,16 @@ namespace qrcode { class DataBlock : public Counted { private: int numDataCodewords_; - ArrayRef codewords_; + ArrayRef codewords_; - DataBlock(int numDataCodewords, ArrayRef codewords); + DataBlock(int numDataCodewords, ArrayRef codewords); public: static std::vector > - getDataBlocks(ArrayRef rawCodewords, Version *version, ErrorCorrectionLevel &ecLevel); + getDataBlocks(ArrayRef rawCodewords, Version *version, ErrorCorrectionLevel &ecLevel); int getNumDataCodewords(); - ArrayRef getCodewords(); + ArrayRef getCodewords(); }; } diff --git a/src/zxing/zxing/qrcode/decoder/Decoder.h b/src/zxing/zxing/qrcode/decoder/Decoder.h index 31ca6bd..401cfed 100644 --- a/src/zxing/zxing/qrcode/decoder/Decoder.h +++ b/src/zxing/zxing/qrcode/decoder/Decoder.h @@ -33,7 +33,7 @@ class Decoder { private: ReedSolomonDecoder rsDecoder_; - void correctErrors(ArrayRef bytes, int numDataCodewords); + void correctErrors(ArrayRef bytes, int numDataCodewords); public: Decoder(); diff --git a/src/zxing/zxing/qrcode/decoder/QRBitMatrixParser.cpp b/src/zxing/zxing/qrcode/decoder/QRBitMatrixParser.cpp index 8a9779f..a348b94 100644 --- a/src/zxing/zxing/qrcode/decoder/QRBitMatrixParser.cpp +++ b/src/zxing/zxing/qrcode/decoder/QRBitMatrixParser.cpp @@ -116,7 +116,7 @@ Version *BitMatrixParser::readVersion() { throw ReaderException("Could not decode version"); } -ArrayRef BitMatrixParser::readCodewords() { +ArrayRef BitMatrixParser::readCodewords() { Ref formatInfo = readFormatInformation(); Version *version = readVersion(); @@ -138,7 +138,7 @@ ArrayRef BitMatrixParser::readCodewords() { // cout << *functionPattern << endl; bool readingUp = true; - ArrayRef result(version->getTotalCodewords()); + ArrayRef result(version->getTotalCodewords()); int resultOffset = 0; int currentByte = 0; int bitsRead = 0; @@ -163,7 +163,7 @@ ArrayRef BitMatrixParser::readCodewords() { } // If we've made a whole byte, save it off if (bitsRead == 8) { - result[resultOffset++] = (char)currentByte; + result[resultOffset++] = (byte)currentByte; bitsRead = 0; currentByte = 0; } diff --git a/src/zxing/zxing/qrcode/decoder/QRDataBlock.cpp b/src/zxing/zxing/qrcode/decoder/QRDataBlock.cpp index ef1dc96..56c5c09 100644 --- a/src/zxing/zxing/qrcode/decoder/QRDataBlock.cpp +++ b/src/zxing/zxing/qrcode/decoder/QRDataBlock.cpp @@ -26,7 +26,7 @@ namespace qrcode { using namespace std; -DataBlock::DataBlock(int numDataCodewords, ArrayRef codewords) : +DataBlock::DataBlock(int numDataCodewords, ArrayRef codewords) : numDataCodewords_(numDataCodewords), codewords_(codewords) { } @@ -34,12 +34,12 @@ int DataBlock::getNumDataCodewords() { return numDataCodewords_; } -ArrayRef DataBlock::getCodewords() { +ArrayRef DataBlock::getCodewords() { return codewords_; } -std::vector > DataBlock::getDataBlocks(ArrayRef rawCodewords, Version *version, +std::vector > DataBlock::getDataBlocks(ArrayRef rawCodewords, Version *version, ErrorCorrectionLevel &ecLevel) { @@ -63,7 +63,7 @@ std::vector > DataBlock::getDataBlocks(ArrayRef rawCodeword for (int i = 0; i < ecBlock->getCount(); i++) { int numDataCodewords = ecBlock->getDataCodewords(); int numBlockCodewords = ecBlocks.getECCodewordsPerBloc() + numDataCodewords; - ArrayRef buffer(numBlockCodewords); + ArrayRef buffer(numBlockCodewords); Ref blockRef(new DataBlock(numDataCodewords, buffer)); result[numResultBlocks++] = blockRef; } diff --git a/src/zxing/zxing/qrcode/decoder/QRDecodedBitStreamParser.cpp b/src/zxing/zxing/qrcode/decoder/QRDecodedBitStreamParser.cpp index caa0309..9d4f076 100644 --- a/src/zxing/zxing/qrcode/decoder/QRDecodedBitStreamParser.cpp +++ b/src/zxing/zxing/qrcode/decoder/QRDecodedBitStreamParser.cpp @@ -132,8 +132,8 @@ void DecodedBitStreamParser::decodeHanziSegment(Ref bits_, // In the 0xB0A1 to 0xFAFE range assembledTwoBytes += 0x0A6A1; } - buffer[offset] = (char) ((assembledTwoBytes >> 8) & 0xFF); - buffer[offset + 1] = (char) (assembledTwoBytes & 0xFF); + buffer[offset] = (byte) ((assembledTwoBytes >> 8) & 0xFF); + buffer[offset + 1] = (byte) (assembledTwoBytes & 0xFF); offset += 2; count--; } @@ -167,8 +167,8 @@ void DecodedBitStreamParser::decodeKanjiSegment(Ref bits, std::string // In the 0xE040 to 0xEBBF range assembledTwoBytes += 0x0C140; } - buffer[offset] = (char)(assembledTwoBytes >> 8); - buffer[offset + 1] = (char)assembledTwoBytes; + buffer[offset] = (byte)(assembledTwoBytes >> 8); + buffer[offset + 1] = (byte)assembledTwoBytes; offset += 2; count--; } @@ -319,7 +319,7 @@ void DecodedBitStreamParser::decodeAlphanumericSegment(Ref bits_, r << s[i++]; } else { // In alpha mode, % should be converted to FNC1 separator 0x1D - r << (char)0x1D; + r << (byte)0x1D; } } } diff --git a/src/zxing/zxing/qrcode/decoder/QRDecoder.cpp b/src/zxing/zxing/qrcode/decoder/QRDecoder.cpp index df437b0..82602f3 100644 --- a/src/zxing/zxing/qrcode/decoder/QRDecoder.cpp +++ b/src/zxing/zxing/qrcode/decoder/QRDecoder.cpp @@ -43,7 +43,7 @@ Decoder::Decoder() : rsDecoder_(GenericGF::QR_CODE_FIELD_256) { } -void Decoder::correctErrors(ArrayRef codewordBytes, int numDataCodewords) { +void Decoder::correctErrors(ArrayRef codewordBytes, int numDataCodewords) { int numCodewords = codewordBytes->size(); ArrayRef codewordInts(numCodewords); for (int i = 0; i < numCodewords; i++) { @@ -59,7 +59,7 @@ void Decoder::correctErrors(ArrayRef codewordBytes, int numDataCodewords) } for (int i = 0; i < numDataCodewords; i++) { - codewordBytes[i] = (char)codewordInts[i]; + codewordBytes[i] = (byte)codewordInts[i]; } } @@ -74,7 +74,7 @@ Ref Decoder::decode(Ref bits) { // Read codewords - ArrayRef codewords(parser.readCodewords()); + ArrayRef codewords(parser.readCodewords()); // Separate into data blocks @@ -93,7 +93,7 @@ Ref Decoder::decode(Ref bits) { // Error-correct and copy data blocks together into a stream of bytes for (size_t j = 0; j < dataBlocks.size(); j++) { Ref dataBlock(dataBlocks[j]); - ArrayRef codewordBytes = dataBlock->getCodewords(); + ArrayRef codewordBytes = dataBlock->getCodewords(); int numDataCodewords = dataBlock->getNumDataCodewords(); correctErrors(codewordBytes, numDataCodewords); for (int i = 0; i < numDataCodewords; i++) { diff --git a/src/zxing/zxing/qrcode/encoder/BlockPair.h b/src/zxing/zxing/qrcode/encoder/BlockPair.h index 08e6f28..d5ab54d 100644 --- a/src/zxing/zxing/qrcode/encoder/BlockPair.h +++ b/src/zxing/zxing/qrcode/encoder/BlockPair.h @@ -13,17 +13,17 @@ class BlockPair { private: ArrayRef data_; - ArrayRef errorCorrection_; + ArrayRef errorCorrection_; public: - BlockPair(ArrayRef data, ArrayRef errorCorrection) : + BlockPair(ArrayRef data, ArrayRef errorCorrection) : data_(data), errorCorrection_(errorCorrection) {} BlockPair(const BlockPair& other) : data_(other.data_), errorCorrection_(other.errorCorrection_) {} ArrayRef getDataBytes() { return data_; } - ArrayRef getErrorCorrectionBytes() { return errorCorrection_; } + ArrayRef getErrorCorrectionBytes() { return errorCorrection_; } }; } diff --git a/src/zxing/zxing/qrcode/encoder/Encoder.h b/src/zxing/zxing/qrcode/encoder/Encoder.h index d923935..67ea888 100644 --- a/src/zxing/zxing/qrcode/encoder/Encoder.h +++ b/src/zxing/zxing/qrcode/encoder/Encoder.h @@ -93,7 +93,7 @@ protected: int numDataBytes, int numRSBlocks); - static ArrayRef generateECBytes(const std::vector &dataBytes, int numEcBytesInBlock); + static ArrayRef generateECBytes(const std::vector &dataBytes, int numEcBytesInBlock); /** * Append mode info. On success, store the result in "bits". diff --git a/src/zxing/zxing/qrcode/encoder/QREncoder.cpp b/src/zxing/zxing/qrcode/encoder/QREncoder.cpp index 6548340..9dc58e8 100644 --- a/src/zxing/zxing/qrcode/encoder/QREncoder.cpp +++ b/src/zxing/zxing/qrcode/encoder/QREncoder.cpp @@ -182,7 +182,7 @@ Mode Encoder::chooseMode(const QString& content, const QString& encoding) //bool Encoder::isOnlyDoubleByteKanji(const QString& content) //{ -// std::vector bytes; +// std::vector bytes; // try { // bytes = content.getBytes("Shift_JIS"); // } catch (UnsupportedEncodingException ignored) { @@ -374,7 +374,7 @@ BitArray* Encoder::interleaveWithECBytes(const BitArray& bits, std::vector dataBytes; dataBytes.resize(size); bits.toBytes(8*dataBytesOffset, dataBytes, 0, size); - ArrayRef ecBytes = generateECBytes(dataBytes, numEcBytesInBlock[0]); + ArrayRef ecBytes = generateECBytes(dataBytes, numEcBytesInBlock[0]); blocks.push_back(BlockPair(ArrayRef(dataBytes.data(), dataBytes.size()),ecBytes)); //?? please revisit maxNumDataBytes = max(maxNumDataBytes, size); @@ -399,7 +399,7 @@ BitArray* Encoder::interleaveWithECBytes(const BitArray& bits, // Then, place error correction blocks. for (int i = 0; i < maxNumEcBytes; i++) { for (std::vector< BlockPair >::iterator it=blocks.begin(); it != blocks.end(); it++) { - ArrayRef ecBytes = it->getErrorCorrectionBytes(); + ArrayRef ecBytes = it->getErrorCorrectionBytes(); if (i < ecBytes.array_->size()) { result->appendBits(ecBytes[i], 8); } @@ -417,7 +417,7 @@ BitArray* Encoder::interleaveWithECBytes(const BitArray& bits, return result; } -ArrayRef Encoder::generateECBytes(const std::vector& dataBytes, int numEcBytesInBlock) +ArrayRef Encoder::generateECBytes(const std::vector& dataBytes, int numEcBytesInBlock) { int numDataBytes = dataBytes.size(); std::vector toEncode; @@ -429,9 +429,9 @@ ArrayRef Encoder::generateECBytes(const std::vector& dataBytes, int zxing::ReedSolomonEncoder encoder(GenericGF::QR_CODE_FIELD_256); encoder.encode(toEncode, numEcBytesInBlock); - ArrayRef ecBytes(numEcBytesInBlock); + ArrayRef ecBytes(numEcBytesInBlock); for (int i = 0; i < numEcBytesInBlock; i++) { - ecBytes[i] = (char) toEncode[numDataBytes + i]; + ecBytes[i] = (byte) toEncode[numDataBytes + i]; } return ecBytes; }