diff --git a/src/CameraImageWrapper.cpp b/src/CameraImageWrapper.cpp index 3a33614..d063a83 100644 --- a/src/CameraImageWrapper.cpp +++ b/src/CameraImageWrapper.cpp @@ -179,7 +179,7 @@ ArrayRef CameraImageWrapper::getMatrixP() const return imageBytes; } -zxing::byte CameraImageWrapper::gray(unsigned int r, unsigned int g, unsigned int b) +zxing::byte CameraImageWrapper::gray(const unsigned int r, const unsigned int g, const unsigned int b) { //the values are not masked with (x & 0xFF) because functions qRed, qGreen, qBlue already do it return R_TO_GREYSCALE[r] + G_TO_GREYSCALE[g] + B_TO_GREYSCALE[b]; diff --git a/src/CameraImageWrapper.h b/src/CameraImageWrapper.h index 2e570f7..0b78e7f 100644 --- a/src/CameraImageWrapper.h +++ b/src/CameraImageWrapper.h @@ -45,7 +45,7 @@ public: Ref invert() const; Ref rotateCounterClockwise() const; - inline zxing::byte gray(unsigned int r, unsigned int g, unsigned int b); + inline zxing::byte gray(const unsigned int r, const unsigned int g, const unsigned int b); private: ArrayRef getRowP(int y, ArrayRef row) const; diff --git a/src/ImageHandler.cpp b/src/ImageHandler.cpp index 1a26e01..d9d257f 100644 --- a/src/ImageHandler.cpp +++ b/src/ImageHandler.cpp @@ -81,8 +81,8 @@ QImage ImageHandler::extractQImage(QObject *imageObj, int offsetX, int offsetY, if (offsetX || offsetY || width || height) return img.copy(offsetX, offsetY, width, height); - else - return img; + + return img; } void ImageHandler::save(QObject *imageObj, const QString &path, diff --git a/src/ImageHandler.h b/src/ImageHandler.h index 398f892..f0fb92d 100644 --- a/src/ImageHandler.h +++ b/src/ImageHandler.h @@ -35,7 +35,7 @@ public: int width = 0, int height = 0); public slots: - void save(QObject *item, const QString &path, + void save(QObject *imageObj, const QString &path, const int offsetX = 0, const int offsetY = 0, const int width = 0, const int height = 0); private: diff --git a/src/QZXing.cpp b/src/QZXing.cpp index 1798906..7d75da4 100644 --- a/src/QZXing.cpp +++ b/src/QZXing.cpp @@ -340,7 +340,7 @@ QRectF getTagRect(const ArrayRef > &resultPoints, const RefgetY()); qreal yMax = yMin; - for (unsigned int i = 1; i < resultRectPoints.size(); ++i) { + for (size_t i = 1; i < resultRectPoints.size(); ++i) { qreal y = qreal(resultRectPoints[i]->getY()); if (y < yMin) yMin = y; @@ -549,7 +549,7 @@ QString QZXing::decodeSubImageQML(const QUrl &imageUrl, if (imagePath.startsWith("/")) imagePath = imagePath.right(imagePath.length() - 1); QQmlEngine *engine = QQmlEngine::contextForObject(this)->engine(); - QQuickImageProvider *imageProvider = static_cast(engine->imageProvider(imageUrl.host())); + QQuickImageProvider *imageProvider = dynamic_cast(engine->imageProvider(imageUrl.host())); QSize imgSize; img = imageProvider->requestImage(imagePath, &imgSize, QSize()); } else { diff --git a/src/QZXing.h b/src/QZXing.h index 880571b..1d23ddd 100644 --- a/src/QZXing.h +++ b/src/QZXing.h @@ -114,7 +114,7 @@ public: #endif //QT_VERSION >= Qt 4.7 #if QT_VERSION >= 0x050000 - static void registerQMLImageProvider(QQmlEngine& view); + static void registerQMLImageProvider(QQmlEngine& engine); #endif //QT_VERSION >= Qt 5.0 #endif //QZXING_QML diff --git a/src/zxing/zxing/EncodeHint.h b/src/zxing/zxing/EncodeHint.h index 4112ffa..a87d8c9 100644 --- a/src/zxing/zxing/EncodeHint.h +++ b/src/zxing/zxing/EncodeHint.h @@ -33,7 +33,7 @@ private: public: EncodeHint(); - const std::string getCharacterSet() const { return characterSet_; } + std::string getCharacterSet() const { return characterSet_; } const zxing::qrcode::ErrorCorrectionLevel* getErrorCorrectionLevel() { return errorCorrectionLevel_; } void setCharacterSet(const std::string& characterSet) { characterSet_ = characterSet; } diff --git a/src/zxing/zxing/InvertedLuminanceSource.cpp b/src/zxing/zxing/InvertedLuminanceSource.cpp index e1b5e08..f7f2044 100644 --- a/src/zxing/zxing/InvertedLuminanceSource.cpp +++ b/src/zxing/zxing/InvertedLuminanceSource.cpp @@ -31,7 +31,7 @@ ArrayRef InvertedLuminanceSource::getRow(int y, ArrayRefgetRow(y, row); int width = getWidth(); for (int i = 0; i < width; i++) { - row[i] = (zxing::byte) (255 - (row[i] & 0xFF)); + row[i] = 0xFF - row[i]; } return row; } @@ -41,7 +41,7 @@ ArrayRef InvertedLuminanceSource::getMatrix() const { int length = getWidth() * getHeight(); ArrayRef invertedMatrix(length); for (int i = 0; i < length; i++) { - invertedMatrix[i] = (zxing::byte) (255 - (matrix[i] & 0xFF)); + invertedMatrix[i] = 0xFF - matrix[i]; } return invertedMatrix; } diff --git a/src/zxing/zxing/LuminanceSource.cpp b/src/zxing/zxing/LuminanceSource.cpp index 1553ced..810ee42 100644 --- a/src/zxing/zxing/LuminanceSource.cpp +++ b/src/zxing/zxing/LuminanceSource.cpp @@ -57,7 +57,7 @@ LuminanceSource::operator std::string() const { for (int y = 0; y < getHeight(); y++) { row = getRow(y, row); for (int x = 0; x < getWidth(); x++) { - int luminance = row[x] & 0xFF; + int luminance = row[x];// & 0xFF; char c; if (luminance < 0x40) { c = '#'; diff --git a/src/zxing/zxing/MultiFormatReader.cpp b/src/zxing/zxing/MultiFormatReader.cpp index b4c8069..e26bc95 100644 --- a/src/zxing/zxing/MultiFormatReader.cpp +++ b/src/zxing/zxing/MultiFormatReader.cpp @@ -63,7 +63,7 @@ Ref MultiFormatReader::decode(Ref image, DecodeHints hints Ref MultiFormatReader::decodeWithState(Ref image) { // Make sure to set up the default state so we don't crash - if (readers_.size() == 0) { + if (readers_.empty()) { setHints(DecodeHints::DEFAULT_HINT); } return decodeInternal(image); @@ -75,7 +75,7 @@ void MultiFormatReader::setHints(DecodeHints hints) { enableReaders(hints, false); - if (readers_.size() == 0) + if (readers_.empty()) enableReaders(hints, true); } @@ -138,7 +138,7 @@ void MultiFormatReader::enableReaders(zxing::DecodeHints hints, bool allowAll) } Ref MultiFormatReader::decodeInternal(Ref image) { - for (unsigned int i = 0; i < readers_.size(); i++) { + for (size_t i = 0; i < readers_.size(); i++) { try { return readers_[i]->decode(image, hints_); } catch (ReaderException const& re) { diff --git a/src/zxing/zxing/Result.cpp b/src/zxing/zxing/Result.cpp index fdfec54..9776927 100644 --- a/src/zxing/zxing/Result.cpp +++ b/src/zxing/zxing/Result.cpp @@ -35,7 +35,7 @@ namespace zxing { Result::Result(Ref text, ArrayRef rawBytes, ArrayRef< Ref > resultPoints, - BarcodeFormat format, std::string charSet, + BarcodeFormat format, const std::string &charSet, ResultMetadata metadata) : text_(text), rawBytes_(rawBytes), resultPoints_(resultPoints), format_(format), charSet_(charSet), metadata_(metadata) { } diff --git a/src/zxing/zxing/Result.h b/src/zxing/zxing/Result.h index 9a4e6b8..f9acca1 100644 --- a/src/zxing/zxing/Result.h +++ b/src/zxing/zxing/Result.h @@ -44,7 +44,7 @@ public: Result(Ref text, ArrayRef rawBytes, ArrayRef< Ref > resultPoints, - BarcodeFormat format, std::string charSet = "", + BarcodeFormat format, const std::string &charSet = "", ResultMetadata metadata = ResultMetadata()); ~Result(); Ref getText(); diff --git a/src/zxing/zxing/ResultPoint.cpp b/src/zxing/zxing/ResultPoint.cpp index 44bbc4b..7c7cf34 100644 --- a/src/zxing/zxing/ResultPoint.cpp +++ b/src/zxing/zxing/ResultPoint.cpp @@ -42,7 +42,7 @@ float ResultPoint::getY() const { return posY_; } -bool ResultPoint::equals(Ref other) { +bool ResultPoint::equals(const Ref &other) { return posX_ == other->getX() && posY_ == other->getY(); } diff --git a/src/zxing/zxing/ResultPoint.h b/src/zxing/zxing/ResultPoint.h index 5934485..393dad7 100644 --- a/src/zxing/zxing/ResultPoint.h +++ b/src/zxing/zxing/ResultPoint.h @@ -40,7 +40,7 @@ public: virtual float getX() const; virtual float getY() const; - bool equals(Ref other); + bool equals(const Ref &other); static void orderBestPatterns(std::vector > &patterns); static float distance(Ref point1, Ref point2); diff --git a/src/zxing/zxing/common/BitArray.cpp b/src/zxing/zxing/common/BitArray.cpp index 5e441ca..fc95f04 100644 --- a/src/zxing/zxing/common/BitArray.cpp +++ b/src/zxing/zxing/common/BitArray.cpp @@ -280,7 +280,7 @@ void BitArray::toBytes(int bitOffset, std::vector& array, int offse } } -const std::string BitArray::toString() const +std::string BitArray::toString() const { std::stringstream result;// = new StringBuilder(2 * width * height + 2); diff --git a/src/zxing/zxing/common/BitArray.h b/src/zxing/zxing/common/BitArray.h index 95bbd2c..21d5690 100644 --- a/src/zxing/zxing/common/BitArray.h +++ b/src/zxing/zxing/common/BitArray.h @@ -76,7 +76,7 @@ public: void toBytes(int bitOffset, std::vector& array, int offset, int numBytes) const; - const std::string toString() const; + std::string toString() const; static ArrayRef makeArray(int size) { return ArrayRef((size + 31) / 32); diff --git a/src/zxing/zxing/common/ByteArray.h b/src/zxing/zxing/common/ByteArray.h index acd4f59..d6b2946 100644 --- a/src/zxing/zxing/common/ByteArray.h +++ b/src/zxing/zxing/common/ByteArray.h @@ -27,15 +27,15 @@ namespace zxing { /** * ByteArray is an extension of std::vector. */ -class ByteArray : public std::vector +class ByteArray : public std::vector { public: ByteArray() {} - ByteArray(std::initializer_list list) : std::vector(list) {} - explicit ByteArray(int len) : std::vector(len, 0) {} + ByteArray(std::initializer_list list) : std::vector(list) {} + explicit ByteArray(int len) : std::vector(len, 0) {} int length() const { return static_cast(size()); } - const zxing::byte* bytePtr() const { return reinterpret_cast(data()); } - zxing::byte* bytePtr() { return reinterpret_cast(data()); } + const zxing::byte* bytePtr() const { return data(); } + zxing::byte* bytePtr() { return data(); } }; } diff --git a/src/zxing/zxing/common/CharacterSetECI.cpp b/src/zxing/zxing/common/CharacterSetECI.cpp index 610690f..d7b07df 100644 --- a/src/zxing/zxing/common/CharacterSetECI.cpp +++ b/src/zxing/zxing/common/CharacterSetECI.cpp @@ -16,12 +16,10 @@ */ #include -#include #include #include using std::string; -using zxing::IllegalArgumentException; namespace zxing { namespace common { @@ -89,7 +87,7 @@ int CharacterSetECI::getValue() const { return values_[0]; } -void CharacterSetECI::addCharacterSet(const std::vector values, const std::vector names) { +void CharacterSetECI::addCharacterSet(const std::vector &values, const std::vector &names) { CharacterSetECI* charSet = new CharacterSetECI(values, names); for(size_t i=0; i values, const std::vector names); - static void addCharacterSet(const std::vector value, const std::vector encodingNames); + static void addCharacterSet(const std::vector &value, const std::vector &encodingNames); public: char const* name() const; diff --git a/src/zxing/zxing/common/Counted.cpp b/src/zxing/zxing/common/Counted.cpp index a80807f..0d32aee 100644 --- a/src/zxing/zxing/common/Counted.cpp +++ b/src/zxing/zxing/common/Counted.cpp @@ -26,7 +26,7 @@ void Counted::release() } } -int Counted::count() const +size_t Counted::count() const { return count_; } diff --git a/src/zxing/zxing/common/Counted.h b/src/zxing/zxing/common/Counted.h index bcf4b17..6c944ac 100644 --- a/src/zxing/zxing/common/Counted.h +++ b/src/zxing/zxing/common/Counted.h @@ -25,7 +25,7 @@ namespace zxing { /* base class for reference-counted objects */ class Counted { private: - unsigned int count_; + size_t count_; public: Counted(); @@ -36,7 +36,7 @@ public: void release(); /* return the current count for denugging purposes or similar */ - int count() const; + size_t count() const; }; /* counting reference to reference-counted objects */ diff --git a/src/zxing/zxing/common/GreyscaleLuminanceSource.cpp b/src/zxing/zxing/common/GreyscaleLuminanceSource.cpp index 001e6c0..bab13db 100644 --- a/src/zxing/zxing/common/GreyscaleLuminanceSource.cpp +++ b/src/zxing/zxing/common/GreyscaleLuminanceSource.cpp @@ -58,16 +58,15 @@ ArrayRef GreyscaleLuminanceSource::getRow(int y, ArrayRef GreyscaleLuminanceSource::getMatrix() const { - if (left_ == 0 && top_ == 0 && dataWidth_ == getWidth() && dataHeight_ == getHeight()) { + if (left_ == 0 && top_ == 0 && dataWidth_ == getWidth() && dataHeight_ == getHeight()) return greyData_; - } else { - int size = getWidth() * getHeight(); - ArrayRef result (size); - for (int row = 0; row < getHeight(); row++) { - memcpy(&result[row * getWidth()], &greyData_[(top_ + row) * dataWidth_ + left_], getWidth()); - } - return result; + + int size = getWidth() * getHeight(); + ArrayRef result (size); + for (int row = 0; row < getHeight(); row++) { + memcpy(&result[row * getWidth()], &greyData_[(top_ + row) * dataWidth_ + left_], getWidth()); } + return result; } Ref GreyscaleLuminanceSource::rotateCounterClockwise() const { @@ -81,3 +80,4 @@ Ref GreyscaleLuminanceSource::rotateCounterClockwise() const { } } + diff --git a/src/zxing/zxing/common/PerspectiveTransform.cpp b/src/zxing/zxing/common/PerspectiveTransform.cpp index 8f33e43..c233739 100644 --- a/src/zxing/zxing/common/PerspectiveTransform.cpp +++ b/src/zxing/zxing/common/PerspectiveTransform.cpp @@ -44,11 +44,13 @@ Ref PerspectiveTransform::squareToQuadrilateral(float x0, float y2, float x3, float y3) { float dx3 = x0 - x1 + x2 - x3; float dy3 = y0 - y1 + y2 - y3; + Ref result; if (dx3 == 0.0f && dy3 == 0.0f) { - Ref result(new PerspectiveTransform(x1 - x0, x2 - x1, x0, y1 - y0, y2 - y1, y0, 0.0f, - 0.0f, 1.0f)); - return result; - } else { + result = new PerspectiveTransform(x1 - x0, x2 - x1, x0, y1 - y0, y2 - y1, y0, 0.0f, + 0.0f, 1.0f); + } + else + { float dx1 = x1 - x2; float dx2 = x3 - x2; float dy1 = y1 - y2; @@ -56,10 +58,11 @@ Ref PerspectiveTransform::squareToQuadrilateral(float x0, float denominator = dx1 * dy2 - dx2 * dy1; float a13 = (dx3 * dy2 - dx2 * dy3) / denominator; float a23 = (dx1 * dy3 - dx3 * dy1) / denominator; - Ref result(new PerspectiveTransform(x1 - x0 + a13 * x1, x3 - x0 + a23 * x3, x0, y1 - y0 - + a13 * y1, y3 - y0 + a23 * y3, y0, a13, a23, 1.0f)); - return result; + result = new PerspectiveTransform(x1 - x0 + a13 * x1, x3 - x0 + a23 * x3, x0, y1 - y0 + + a13 * y1, y3 - y0 + a23 * y3, y0, a13, a23, 1.0f); } + + return result; } Ref PerspectiveTransform::quadrilateralToSquare(float x0, float y0, float x1, float y1, float x2, diff --git a/src/zxing/zxing/common/Types.h b/src/zxing/zxing/common/Types.h index cecffe9..f266913 100644 --- a/src/zxing/zxing/common/Types.h +++ b/src/zxing/zxing/common/Types.h @@ -8,7 +8,7 @@ namespace zxing { -typedef unsigned char byte; +typedef uint8_t byte; typedef bool boolean; } diff --git a/src/zxing/zxing/common/reedsolomon/GenericGF.cpp b/src/zxing/zxing/common/reedsolomon/GenericGF.cpp index 27ad073..e21222c 100644 --- a/src/zxing/zxing/common/reedsolomon/GenericGF.cpp +++ b/src/zxing/zxing/common/reedsolomon/GenericGF.cpp @@ -59,7 +59,7 @@ void GenericGF::initialize() { int x = 1; - for (int i = 0; i < size; i++) { + for (size_t i = 0; i < size; i++) { expTable[i] = x; x <<= 1; // x = x * 2; we're assuming the generator alpha is 2 if (x >= size) { @@ -67,8 +67,8 @@ void GenericGF::initialize() { x &= size-1; } } - for (int i = 0; i < size-1; i++) { - logTable[expTable[i]] = i; + for (size_t i = 0; i < size-1; i++) { + logTable.at(expTable.at(i)) = i; } //logTable[0] == 0 but this should never be used ArrayRef coefficients_zero(1); @@ -148,7 +148,7 @@ int GenericGF::multiply(int a, int b) { return expTable[(logTable[a] + logTable[b]) % (size - 1)]; } -int GenericGF::getSize() { +size_t GenericGF::getSize() { return size; } diff --git a/src/zxing/zxing/common/reedsolomon/GenericGF.h b/src/zxing/zxing/common/reedsolomon/GenericGF.h index bcc0c31..230405f 100644 --- a/src/zxing/zxing/common/reedsolomon/GenericGF.h +++ b/src/zxing/zxing/common/reedsolomon/GenericGF.h @@ -58,7 +58,7 @@ namespace zxing { Ref getZero(); Ref getOne(); - int getSize(); + size_t getSize(); int getGeneratorBase(); Ref buildMonomial(int degree, int coefficient); diff --git a/src/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp b/src/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp index 630392b..4797336 100644 --- a/src/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp +++ b/src/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp @@ -51,7 +51,7 @@ void ReedSolomonEncoder::encode(std::vector &toEncode, int ecBytes) ArrayRef infoCoefficients(dataBytes); //to-do optimize the following loop - for(int i=0; i< dataBytes; i++) + for(size_t i=0; i< dataBytes; i++) infoCoefficients[i] = toEncode[size_t(i)]; Ref info(new GenericGFPoly(field_, infoCoefficients)); @@ -64,7 +64,7 @@ void ReedSolomonEncoder::encode(std::vector &toEncode, int ecBytes) } for (int i = 0; i < coefficients->size(); i++) - toEncode[size_t(dataBytes + numZeroCoefficients + i)] = zxing::byte(coefficients[int(i)]); + toEncode[size_t(dataBytes + numZeroCoefficients + i)] = zxing::byte(coefficients[i]); } } diff --git a/src/zxing/zxing/qrcode/QRVersion.cpp b/src/zxing/zxing/qrcode/QRVersion.cpp index 932b012..76a58b0 100644 --- a/src/zxing/zxing/qrcode/QRVersion.cpp +++ b/src/zxing/zxing/qrcode/QRVersion.cpp @@ -44,14 +44,24 @@ int ECB::getDataCodewords() { } ECBlocks::ECBlocks(int ecCodewordsPerBloc, ECB *ecBlocks) : - ecCodewordsPerBloc_(ecCodewordsPerBloc), ecBlocks_(1, ecBlocks) { + ecCodewordsPerBloc_(ecCodewordsPerBloc), ecBlocks_() { + ecBlocks_.push_back(ecBlocks); } ECBlocks::ECBlocks(int ecCodewordsPerBloc, ECB *ecBlocks1, ECB *ecBlocks2) : - ecCodewordsPerBloc_(ecCodewordsPerBloc), ecBlocks_(1, ecBlocks1) { + ecCodewordsPerBloc_(ecCodewordsPerBloc), ecBlocks_() { + ecBlocks_.push_back(ecBlocks1); ecBlocks_.push_back(ecBlocks2); } +int ECBlocks::numBlocks() const +{ + int sumSizeOfBlocks = 0; + for (size_t i=0; igetCount(); + return sumSizeOfBlocks; +} + int ECBlocks::getECCodewordsPerBloc() { return ecCodewordsPerBloc_; @@ -59,7 +69,7 @@ int ECBlocks::getECCodewordsPerBloc() int ECBlocks::getTotalECCodewords() { - return ecCodewordsPerBloc_ * int(ecBlocks_.size()); + return ecCodewordsPerBloc_ * numBlocks();//int(ecBlocks_.size()); } std::vector& ECBlocks::getECBlocks() { diff --git a/src/zxing/zxing/qrcode/Version.h b/src/zxing/zxing/qrcode/Version.h index d96c8fd..19b939a 100644 --- a/src/zxing/zxing/qrcode/Version.h +++ b/src/zxing/zxing/qrcode/Version.h @@ -47,6 +47,7 @@ private: public: ECBlocks(int ecCodewordsPerBloc, ECB *ecBlocks); ECBlocks(int ecCodewordsPerBloc, ECB *ecBlocks1, ECB *ecBlocks2); + int numBlocks() const; int getECCodewordsPerBloc(); int getTotalECCodewords(); std::vector& getECBlocks();