├── LICENSE ├── QZXing ├── CameraImageWrapper.cpp ├── CameraImageWrapper.h ├── LICENSE.txt ├── QZXing.h ├── QZXing.pri ├── QZXing.pro ├── QZXing_global.h ├── imagehandler.cpp ├── imagehandler.h ├── qzxing.cpp └── zxing │ ├── bigint │ ├── BigInteger.cc │ ├── BigInteger.hh │ ├── BigIntegerAlgorithms.cc │ ├── BigIntegerAlgorithms.hh │ ├── BigIntegerLibrary.hh │ ├── BigIntegerUtils.cc │ ├── BigIntegerUtils.hh │ ├── BigUnsigned.cc │ ├── BigUnsigned.hh │ ├── BigUnsignedInABase.cc │ ├── BigUnsignedInABase.hh │ ├── ChangeLog │ ├── NumberlikeArray.hh │ └── README │ ├── win32 │ └── zxing │ │ ├── iconv.h │ │ ├── msvc │ │ └── stdint.h │ │ └── win_iconv.c │ └── zxing │ ├── BarcodeFormat.cpp │ ├── BarcodeFormat.h │ ├── Binarizer.cpp │ ├── Binarizer.h │ ├── BinaryBitmap.cpp │ ├── BinaryBitmap.h │ ├── ChecksumException.cpp │ ├── ChecksumException.h │ ├── DecodeHints.cpp │ ├── DecodeHints.h │ ├── Exception.cpp │ ├── Exception.h │ ├── FormatException.cpp │ ├── FormatException.h │ ├── IllegalStateException.h │ ├── InvertedLuminanceSource.cpp │ ├── InvertedLuminanceSource.h │ ├── LuminanceSource.cpp │ ├── LuminanceSource.h │ ├── MultiFormatReader.cpp │ ├── MultiFormatReader.h │ ├── NotFoundException.h │ ├── Reader.cpp │ ├── Reader.h │ ├── ReaderException.h │ ├── Result.cpp │ ├── Result.h │ ├── ResultIO.cpp │ ├── ResultPoint.cpp │ ├── ResultPoint.h │ ├── ResultPointCallback.cpp │ ├── ResultPointCallback.h │ ├── WriterException.h │ ├── ZXing.h │ ├── aztec │ ├── AztecDetectorResult.cpp │ ├── AztecDetectorResult.h │ ├── AztecReader.cpp │ ├── AztecReader.h │ ├── decoder │ │ ├── AztecDecoder.cpp │ │ └── Decoder.h │ └── detector │ │ ├── AztecDetector.cpp │ │ └── Detector.h │ ├── common │ ├── Array.h │ ├── BitArray.cpp │ ├── BitArray.h │ ├── BitArrayIO.cpp │ ├── BitMatrix.cpp │ ├── BitMatrix.h │ ├── BitSource.cpp │ ├── BitSource.h │ ├── CharacterSetECI.cpp │ ├── CharacterSetECI.h │ ├── Counted.h │ ├── DecoderResult.cpp │ ├── DecoderResult.h │ ├── DetectorResult.cpp │ ├── DetectorResult.h │ ├── GlobalHistogramBinarizer.cpp │ ├── GlobalHistogramBinarizer.h │ ├── GreyscaleLuminanceSource.cpp │ ├── GreyscaleLuminanceSource.h │ ├── GreyscaleRotatedLuminanceSource.cpp │ ├── GreyscaleRotatedLuminanceSource.h │ ├── GridSampler.cpp │ ├── GridSampler.h │ ├── HybridBinarizer.cpp │ ├── HybridBinarizer.h │ ├── IllegalArgumentException.cpp │ ├── IllegalArgumentException.h │ ├── PerspectiveTransform.cpp │ ├── PerspectiveTransform.h │ ├── Point.h │ ├── Str.cpp │ ├── Str.h │ ├── StringUtils.cpp │ ├── StringUtils.h │ ├── detector │ │ ├── JavaMath.h │ │ ├── MathUtils.h │ │ ├── MonochromeRectangleDetector.cpp │ │ ├── MonochromeRectangleDetector.h │ │ ├── WhiteRectangleDetector.cpp │ │ └── WhiteRectangleDetector.h │ └── reedsolomon │ │ ├── GenericGF.cpp │ │ ├── GenericGF.h │ │ ├── GenericGFPoly.cpp │ │ ├── GenericGFPoly.h │ │ ├── ReedSolomonDecoder.cpp │ │ ├── ReedSolomonDecoder.h │ │ ├── ReedSolomonException.cpp │ │ └── ReedSolomonException.h │ ├── datamatrix │ ├── DataMatrixReader.cpp │ ├── DataMatrixReader.h │ ├── DataMatrixVersion.cpp │ ├── Version.h │ ├── decoder │ │ ├── BitMatrixParser.h │ │ ├── DataBlock.h │ │ ├── DataMatrixBitMatrixParser.cpp │ │ ├── DataMatrixDataBlock.cpp │ │ ├── DataMatrixDecodedBitStreamParser.cpp │ │ ├── DataMatrixDecoder.cpp │ │ ├── DecodedBitStreamParser.h │ │ └── Decoder.h │ └── detector │ │ ├── CornerPoint.h │ │ ├── DataMatrixCornerPoint.cpp │ │ ├── DataMatrixDetector.cpp │ │ ├── DataMatrixDetectorException.cpp │ │ ├── Detector.h │ │ └── DetectorException.h │ ├── multi │ ├── ByQuadrantReader.cpp │ ├── ByQuadrantReader.h │ ├── GenericMultipleBarcodeReader.cpp │ ├── GenericMultipleBarcodeReader.h │ ├── MultipleBarcodeReader.cpp │ ├── MultipleBarcodeReader.h │ └── qrcode │ │ ├── QRCodeMultiReader.cpp │ │ ├── QRCodeMultiReader.h │ │ └── detector │ │ ├── MultiDetector.cpp │ │ ├── MultiDetector.h │ │ ├── MultiFinderPatternFinder.cpp │ │ └── MultiFinderPatternFinder.h │ ├── oned │ ├── CodaBarReader.cpp │ ├── CodaBarReader.h │ ├── Code128Reader.cpp │ ├── Code128Reader.h │ ├── Code39Reader.cpp │ ├── Code39Reader.h │ ├── Code93Reader.cpp │ ├── Code93Reader.h │ ├── EAN13Reader.cpp │ ├── EAN13Reader.h │ ├── EAN8Reader.cpp │ ├── EAN8Reader.h │ ├── ITFReader.cpp │ ├── ITFReader.h │ ├── MultiFormatOneDReader.cpp │ ├── MultiFormatOneDReader.h │ ├── MultiFormatUPCEANReader.cpp │ ├── MultiFormatUPCEANReader.h │ ├── OneDReader.cpp │ ├── OneDReader.h │ ├── OneDResultPoint.cpp │ ├── OneDResultPoint.h │ ├── UPCAReader.cpp │ ├── UPCAReader.h │ ├── UPCEANReader.cpp │ ├── UPCEANReader.h │ ├── UPCEReader.cpp │ └── UPCEReader.h │ ├── pdf417 │ ├── PDF417Reader.cpp │ ├── PDF417Reader.h │ ├── decoder │ │ ├── BitMatrixParser.h │ │ ├── DecodedBitStreamParser.h │ │ ├── Decoder.h │ │ ├── PDF417BitMatrixParser.cpp │ │ ├── PDF417DecodedBitStreamParser.cpp │ │ ├── PDF417Decoder.cpp │ │ └── ec │ │ │ ├── ErrorCorrection.cpp │ │ │ ├── ErrorCorrection.h │ │ │ ├── ModulusGF.cpp │ │ │ ├── ModulusGF.h │ │ │ ├── ModulusPoly.cpp │ │ │ └── ModulusPoly.h │ └── detector │ │ ├── Detector.h │ │ ├── LinesSampler.cpp │ │ ├── LinesSampler.h │ │ └── PDF417Detector.cpp │ └── qrcode │ ├── ErrorCorrectionLevel.h │ ├── FormatInformation.h │ ├── QRCodeReader.cpp │ ├── QRCodeReader.h │ ├── QRErrorCorrectionLevel.cpp │ ├── QRFormatInformation.cpp │ ├── QRVersion.cpp │ ├── Version.h │ ├── decoder │ ├── BitMatrixParser.h │ ├── DataBlock.h │ ├── DataMask.h │ ├── DecodedBitStreamParser.h │ ├── Decoder.h │ ├── Mode.h │ ├── QRBitMatrixParser.cpp │ ├── QRDataBlock.cpp │ ├── QRDataMask.cpp │ ├── QRDecodedBitStreamParser.cpp │ ├── QRDecoder.cpp │ └── QRMode.cpp │ └── detector │ ├── AlignmentPattern.h │ ├── AlignmentPatternFinder.h │ ├── Detector.h │ ├── FinderPattern.h │ ├── FinderPatternFinder.h │ ├── FinderPatternInfo.h │ ├── QRAlignmentPattern.cpp │ ├── QRAlignmentPatternFinder.cpp │ ├── QRDetector.cpp │ ├── QRFinderPattern.cpp │ ├── QRFinderPatternFinder.cpp │ └── QRFinderPatternInfo.cpp ├── README.md ├── build └── categories.txt └── src ├── BillDownloader.pro ├── cnetclient.cpp ├── cnetclient.h ├── cwimage.cpp ├── cwimage.h ├── dialogcopytext.cpp ├── dialogcopytext.h ├── dialogcopytext.ui ├── dialogscanreceipt.cpp ├── dialogscanreceipt.h ├── dialogscanreceipt.ui ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h └── mainwindow.ui /QZXing/CameraImageWrapper.h: -------------------------------------------------------------------------------- 1 | #ifndef CAMERAIMAGE_H 2 | #define CAMERAIMAGE_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace zxing; 9 | 10 | class CameraImageWrapper : public LuminanceSource 11 | { 12 | public: 13 | CameraImageWrapper(); 14 | CameraImageWrapper(const QImage& sourceImage); 15 | CameraImageWrapper(CameraImageWrapper& otherInstance); 16 | ~CameraImageWrapper(); 17 | 18 | static CameraImageWrapper* Factory(const QImage& image, int maxWidth=-1, int maxHeight=-1, bool smoothTransformation=false); 19 | 20 | int getWidth() const; 21 | int getHeight() const; 22 | 23 | unsigned char getPixel(int x, int y) const; 24 | unsigned char* copyMatrix() const; 25 | 26 | QImage grayScaleImage(QImage::Format f); 27 | QImage getOriginalImage(); 28 | 29 | // Callers take ownership of the returned memory and must call delete [] on it themselves. 30 | ArrayRef getRow(int y, ArrayRef row) const; 31 | ArrayRef getMatrix() const; 32 | 33 | private: 34 | QImage image; 35 | unsigned char* pRow; 36 | unsigned char* pMatrix; 37 | }; 38 | 39 | #endif //CAMERAIMAGE_H 40 | -------------------------------------------------------------------------------- /QZXing/QZXing.pro: -------------------------------------------------------------------------------- 1 | include(QZXing.pri) 2 | 3 | VERSION = 2.3 4 | 5 | TARGET = QZXing 6 | TEMPLATE = lib 7 | 8 | # CONFIG += staticlib 9 | 10 | DEFINES -= DISABLE_LIBRARY_FEATURES 11 | symbian { 12 | TARGET.UID3 = 0xE618743C 13 | TARGET.EPOCALLOWDLLDATA = 1 14 | addFiles.sources = QZXing.dll 15 | addFiles.path = !:/sys/bin 16 | DEPLOYMENT += addFiles 17 | # TARGET.CAPABILITY = All -TCB -AllFiles -DRM 18 | TARGET.CAPABILITY += NetworkServices \ 19 | ReadUserData \ 20 | WriteUserData \ 21 | LocalServices \ 22 | UserEnvironment \ 23 | Location 24 | } 25 | 26 | OTHER_FILES += \ 27 | qtc_packaging/debian_fremantle/rules \ 28 | qtc_packaging/debian_fremantle/README \ 29 | qtc_packaging/debian_fremantle/copyright \ 30 | qtc_packaging/debian_fremantle/control \ 31 | qtc_packaging/debian_fremantle/compat \ 32 | qtc_packaging/debian_fremantle/changelog \ 33 | qtc_packaging/debian_harmattan/rules \ 34 | qtc_packaging/debian_harmattan/README \ 35 | qtc_packaging/debian_harmattan/manifest.aegis \ 36 | qtc_packaging/debian_harmattan/copyright \ 37 | qtc_packaging/debian_harmattan/control \ 38 | qtc_packaging/debian_harmattan/compat \ 39 | qtc_packaging/debian_harmattan/changelog \ 40 | qtc_packaging/debian_harmattan/rules \ 41 | qtc_packaging/debian_harmattan/README \ 42 | qtc_packaging/debian_harmattan/manifest.aegis \ 43 | qtc_packaging/debian_harmattan/copyright \ 44 | qtc_packaging/debian_harmattan/control \ 45 | qtc_packaging/debian_harmattan/compat \ 46 | qtc_packaging/debian_harmattan/changelog \ 47 | qtc_packaging/debian_fremantle/rules \ 48 | qtc_packaging/debian_fremantle/README \ 49 | qtc_packaging/debian_fremantle/copyright \ 50 | qtc_packaging/debian_fremantle/control \ 51 | qtc_packaging/debian_fremantle/compat \ 52 | qtc_packaging/debian_fremantle/changelog 53 | 54 | 55 | -------------------------------------------------------------------------------- /QZXing/QZXing_global.h: -------------------------------------------------------------------------------- 1 | #ifndef QZXING_GLOBAL_H 2 | #define QZXING_GLOBAL_H 3 | 4 | #include 5 | #include 6 | 7 | #if defined(QZXING_LIBRARY) 8 | # define QZXINGSHARED_EXPORT Q_DECL_EXPORT 9 | #else 10 | # define QZXINGSHARED_EXPORT Q_DECL_IMPORT 11 | #endif 12 | 13 | #endif //QZXING_GLOBAL_H 14 | -------------------------------------------------------------------------------- /QZXing/imagehandler.cpp: -------------------------------------------------------------------------------- 1 | #include "imagehandler.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | ImageHandler::ImageHandler(QObject *parent) : 9 | QObject(parent) 10 | { 11 | } 12 | 13 | QImage ImageHandler::extractQImage(QObject *imageObj, 14 | const double offsetX, const double offsetY, 15 | const double width, const double height) 16 | { 17 | QGraphicsObject *item = qobject_cast(imageObj); 18 | 19 | if (!item) { 20 | qDebug() << "Item is NULL"; 21 | return QImage(); 22 | } 23 | 24 | QImage img(item->boundingRect().size().toSize(), QImage::Format_RGB32); 25 | img.fill(QColor(255, 255, 255).rgb()); 26 | QPainter painter(&img); 27 | QStyleOptionGraphicsItem styleOption; 28 | item->paint(&painter, &styleOption); 29 | 30 | if(offsetX == 0 && offsetY == 0 && width == 0 && height == 0) 31 | return img; 32 | else 33 | { 34 | return img.copy(offsetX, offsetY, width, height); 35 | } 36 | } 37 | 38 | void ImageHandler::save(QObject *imageObj, const QString &path, 39 | const double offsetX, const double offsetY, 40 | const double width, const double height) 41 | { 42 | QImage img = extractQImage(imageObj, offsetX, offsetY, width, height); 43 | img.save(path); 44 | } 45 | 46 | -------------------------------------------------------------------------------- /QZXing/imagehandler.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGEHANDLER_H 2 | #define IMAGEHANDLER_H 3 | 4 | #include 5 | #include 6 | 7 | class ImageHandler : public QObject 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit ImageHandler(QObject *parent = 0); 12 | 13 | QImage extractQImage(QObject *imageObj, 14 | const double offsetX = 0 , const double offsetY = 0, 15 | const double width = 0, const double height = 0); 16 | 17 | public slots: 18 | void save(QObject *item, const QString &path, 19 | const double offsetX = 0, const double offsetY = 0, 20 | const double width = 0, const double height = 0); 21 | }; 22 | 23 | #endif // IMAGEHANDLER_H 24 | -------------------------------------------------------------------------------- /QZXing/zxing/bigint/BigIntegerAlgorithms.cc: -------------------------------------------------------------------------------- 1 | #include "BigIntegerAlgorithms.hh" 2 | 3 | BigUnsigned gcd(BigUnsigned a, BigUnsigned b) { 4 | BigUnsigned trash; 5 | // Neat in-place alternating technique. 6 | for (;;) { 7 | if (b.isZero()) 8 | return a; 9 | a.divideWithRemainder(b, trash); 10 | if (a.isZero()) 11 | return b; 12 | b.divideWithRemainder(a, trash); 13 | } 14 | } 15 | 16 | void extendedEuclidean(BigInteger m, BigInteger n, 17 | BigInteger &g, BigInteger &r, BigInteger &s) { 18 | if (&g == &r || &g == &s || &r == &s) 19 | throw "BigInteger extendedEuclidean: Outputs are aliased"; 20 | BigInteger r1(1), s1(0), r2(0), s2(1), q; 21 | /* Invariants: 22 | * r1*m(orig) + s1*n(orig) == m(current) 23 | * r2*m(orig) + s2*n(orig) == n(current) */ 24 | for (;;) { 25 | if (n.isZero()) { 26 | r = r1; s = s1; g = m; 27 | return; 28 | } 29 | // Subtract q times the second invariant from the first invariant. 30 | m.divideWithRemainder(n, q); 31 | r1 -= q*r2; s1 -= q*s2; 32 | 33 | if (m.isZero()) { 34 | r = r2; s = s2; g = n; 35 | return; 36 | } 37 | // Subtract q times the first invariant from the second invariant. 38 | n.divideWithRemainder(m, q); 39 | r2 -= q*r1; s2 -= q*s1; 40 | } 41 | } 42 | 43 | BigUnsigned modinv(const BigInteger &x, const BigUnsigned &n) { 44 | BigInteger g, r, s; 45 | extendedEuclidean(x, n, g, r, s); 46 | if (g == 1) 47 | // r*x + s*n == 1, so r*x === 1 (mod n), so r is the answer. 48 | return (r % n).getMagnitude(); // (r % n) will be nonnegative 49 | else 50 | throw "BigInteger modinv: x and n have a common factor"; 51 | } 52 | 53 | BigUnsigned modexp(const BigInteger &base, const BigUnsigned &exponent, 54 | const BigUnsigned &modulus) { 55 | BigUnsigned ans = 1, base2 = (base % modulus).getMagnitude(); 56 | BigUnsigned::Index i = exponent.bitLength(); 57 | // For each bit of the exponent, most to least significant... 58 | while (i > 0) { 59 | i--; 60 | // Square. 61 | ans *= ans; 62 | ans %= modulus; 63 | // And multiply if the bit is a 1. 64 | if (exponent.getBit(i)) { 65 | ans *= base2; 66 | ans %= modulus; 67 | } 68 | } 69 | return ans; 70 | } 71 | -------------------------------------------------------------------------------- /QZXing/zxing/bigint/BigIntegerAlgorithms.hh: -------------------------------------------------------------------------------- 1 | #ifndef BIGINTEGERALGORITHMS_H 2 | #define BIGINTEGERALGORITHMS_H 3 | 4 | #include "BigInteger.hh" 5 | 6 | /* Some mathematical algorithms for big integers. 7 | * This code is new and, as such, experimental. */ 8 | 9 | // Returns the greatest common divisor of a and b. 10 | BigUnsigned gcd(BigUnsigned a, BigUnsigned b); 11 | 12 | /* Extended Euclidean algorithm. 13 | * Given m and n, finds gcd g and numbers r, s such that r*m + s*n == g. */ 14 | void extendedEuclidean(BigInteger m, BigInteger n, 15 | BigInteger &g, BigInteger &r, BigInteger &s); 16 | 17 | /* Returns the multiplicative inverse of x modulo n, or throws an exception if 18 | * they have a common factor. */ 19 | BigUnsigned modinv(const BigInteger &x, const BigUnsigned &n); 20 | 21 | // Returns (base ^ exponent) % modulus. 22 | BigUnsigned modexp(const BigInteger &base, const BigUnsigned &exponent, 23 | const BigUnsigned &modulus); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /QZXing/zxing/bigint/BigIntegerLibrary.hh: -------------------------------------------------------------------------------- 1 | // This header file includes all of the library header files. 2 | 3 | #include "NumberlikeArray.hh" 4 | #include "BigUnsigned.hh" 5 | #include "BigInteger.hh" 6 | #include "BigIntegerAlgorithms.hh" 7 | #include "BigUnsignedInABase.hh" 8 | #include "BigIntegerUtils.hh" 9 | -------------------------------------------------------------------------------- /QZXing/zxing/bigint/BigIntegerUtils.cc: -------------------------------------------------------------------------------- 1 | #include "BigIntegerUtils.hh" 2 | #include "BigUnsignedInABase.hh" 3 | 4 | std::string bigUnsignedToString(const BigUnsigned &x) { 5 | return std::string(BigUnsignedInABase(x, 10)); 6 | } 7 | 8 | std::string bigIntegerToString(const BigInteger &x) { 9 | return (x.getSign() == BigInteger::negative) 10 | ? (std::string("-") + bigUnsignedToString(x.getMagnitude())) 11 | : (bigUnsignedToString(x.getMagnitude())); 12 | } 13 | 14 | BigUnsigned stringToBigUnsigned(const std::string &s) { 15 | return BigUnsigned(BigUnsignedInABase(s, 10)); 16 | } 17 | 18 | BigInteger stringToBigInteger(const std::string &s) { 19 | // Recognize a sign followed by a BigUnsigned. 20 | return (s[0] == '-') ? BigInteger(stringToBigUnsigned(s.substr(1, s.length() - 1)), BigInteger::negative) 21 | : (s[0] == '+') ? BigInteger(stringToBigUnsigned(s.substr(1, s.length() - 1))) 22 | : BigInteger(stringToBigUnsigned(s)); 23 | } 24 | 25 | std::ostream &operator <<(std::ostream &os, const BigUnsigned &x) { 26 | BigUnsignedInABase::Base base; 27 | long osFlags = os.flags(); 28 | if (osFlags & os.dec) 29 | base = 10; 30 | else if (osFlags & os.hex) { 31 | base = 16; 32 | if (osFlags & os.showbase) 33 | os << "0x"; 34 | } else if (osFlags & os.oct) { 35 | base = 8; 36 | if (osFlags & os.showbase) 37 | os << '0'; 38 | } else 39 | throw "std::ostream << BigUnsigned: Could not determine the desired base from output-stream flags"; 40 | std::string s = std::string(BigUnsignedInABase(x, base)); 41 | os << s; 42 | return os; 43 | } 44 | 45 | std::ostream &operator <<(std::ostream &os, const BigInteger &x) { 46 | if (x.getSign() == BigInteger::negative) 47 | os << '-'; 48 | os << x.getMagnitude(); 49 | return os; 50 | } 51 | -------------------------------------------------------------------------------- /QZXing/zxing/win32/zxing/iconv.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIBICONV_H 2 | #define _LIBICONV_H 3 | #include 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | typedef void* iconv_t; 8 | iconv_t iconv_open(const char *tocode, const char *fromcode); 9 | int iconv_close(iconv_t cd); 10 | size_t iconv(iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | #endif//_LIBICONV_H -------------------------------------------------------------------------------- /QZXing/zxing/zxing/BarcodeFormat.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * Created by Christian Brunschen on 13/05/2008. 4 | * Copyright 2008 ZXing authors All rights reserved. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include 20 | 21 | const char* zxing::BarcodeFormat::barcodeFormatNames[] = { 22 | 0, 23 | "AZTEC", 24 | "CODABAR", 25 | "CODE_39", 26 | "CODE_93", 27 | "CODE_128", 28 | "DATA_MATRIX", 29 | "EAN_8", 30 | "EAN_13", 31 | "ITF", 32 | "MAXICODE", 33 | "PDF_417", 34 | "QR_CODE", 35 | "RSS_14", 36 | "RSS_EXPANDED", 37 | "UPC_A", 38 | "UPC_E", 39 | "UPC_EAN_EXTENSION" 40 | }; 41 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/BarcodeFormat.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __BARCODE_FORMAT_H__ 3 | #define __BARCODE_FORMAT_H__ 4 | 5 | /* 6 | * BarcodeFormat.h 7 | * zxing 8 | * 9 | * Copyright 2010 ZXing authors All rights reserved. 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | namespace zxing { 25 | 26 | class BarcodeFormat { 27 | public: 28 | // if you update the enum, update BarcodeFormat.cpp 29 | 30 | enum Value { 31 | NONE, 32 | AZTEC, 33 | CODABAR, 34 | CODE_39, 35 | CODE_93, 36 | CODE_128, 37 | DATA_MATRIX, 38 | EAN_8, 39 | EAN_13, 40 | ITF, 41 | MAXICODE, 42 | PDF_417, 43 | QR_CODE, 44 | RSS_14, 45 | RSS_EXPANDED, 46 | UPC_A, 47 | UPC_E, 48 | UPC_EAN_EXTENSION 49 | }; 50 | 51 | BarcodeFormat(Value v) : value(v) {} 52 | const Value value; 53 | operator Value () const {return value;} 54 | 55 | static char const* barcodeFormatNames[]; 56 | }; 57 | 58 | } 59 | 60 | #endif // __BARCODE_FORMAT_H__ 61 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/Binarizer.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * Binarizer.cpp 4 | * zxing 5 | * 6 | * Created by Ralf Kistner on 16/10/2009. 7 | * Copyright 2008 ZXing authors All rights reserved. 8 | * Modified by Lukasz Warchol on 02/02/2010. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | 25 | namespace zxing { 26 | 27 | Binarizer::Binarizer(Ref source) : source_(source) { 28 | } 29 | 30 | Binarizer::~Binarizer() { 31 | } 32 | 33 | Ref Binarizer::getLuminanceSource() const { 34 | return source_; 35 | } 36 | 37 | int Binarizer::getWidth() const { 38 | return source_->getWidth(); 39 | } 40 | 41 | int Binarizer::getHeight() const { 42 | return source_->getHeight(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/Binarizer.h: -------------------------------------------------------------------------------- 1 | #ifndef BINARIZER_H_ 2 | #define BINARIZER_H_ 3 | 4 | /* 5 | * Binarizer.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace zxing { 29 | 30 | class Binarizer : public Counted { 31 | private: 32 | Ref source_; 33 | 34 | public: 35 | Binarizer(Ref source); 36 | virtual ~Binarizer(); 37 | 38 | virtual Ref getBlackRow(int y, Ref row) = 0; 39 | virtual Ref getBlackMatrix() = 0; 40 | 41 | Ref getLuminanceSource() const ; 42 | virtual Ref createBinarizer(Ref source) = 0; 43 | 44 | int getWidth() const; 45 | int getHeight() const; 46 | 47 | }; 48 | 49 | } 50 | #endif /* BINARIZER_H_ */ 51 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/BinaryBitmap.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * Copyright 2010 ZXing authors All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include 19 | 20 | using zxing::Ref; 21 | using zxing::BitArray; 22 | using zxing::BitMatrix; 23 | using zxing::LuminanceSource; 24 | using zxing::BinaryBitmap; 25 | 26 | // VC++ 27 | using zxing::Binarizer; 28 | 29 | BinaryBitmap::BinaryBitmap(Ref binarizer) : binarizer_(binarizer) { 30 | } 31 | 32 | BinaryBitmap::~BinaryBitmap() { 33 | } 34 | 35 | Ref BinaryBitmap::getBlackRow(int y, Ref row) { 36 | return binarizer_->getBlackRow(y, row); 37 | } 38 | 39 | Ref BinaryBitmap::getBlackMatrix() { 40 | return binarizer_->getBlackMatrix(); 41 | } 42 | 43 | int BinaryBitmap::getWidth() const { 44 | return getLuminanceSource()->getWidth(); 45 | } 46 | 47 | int BinaryBitmap::getHeight() const { 48 | return getLuminanceSource()->getHeight(); 49 | } 50 | 51 | Ref BinaryBitmap::getLuminanceSource() const { 52 | return binarizer_->getLuminanceSource(); 53 | } 54 | 55 | 56 | bool BinaryBitmap::isCropSupported() const { 57 | return getLuminanceSource()->isCropSupported(); 58 | } 59 | 60 | Ref BinaryBitmap::crop(int left, int top, int width, int height) { 61 | return Ref (new BinaryBitmap(binarizer_->createBinarizer(getLuminanceSource()->crop(left, top, width, height)))); 62 | } 63 | 64 | bool BinaryBitmap::isRotateSupported() const { 65 | return getLuminanceSource()->isRotateSupported(); 66 | } 67 | 68 | Ref BinaryBitmap::rotateCounterClockwise() { 69 | return Ref (new BinaryBitmap(binarizer_->createBinarizer(getLuminanceSource()->rotateCounterClockwise()))); 70 | } 71 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/BinaryBitmap.h: -------------------------------------------------------------------------------- 1 | #ifndef __BINARYBITMAP_H__ 2 | #define __BINARYBITMAP_H__ 3 | 4 | /* 5 | * BinaryBitmap.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace zxing { 29 | 30 | class BinaryBitmap : public Counted { 31 | private: 32 | Ref binarizer_; 33 | 34 | public: 35 | BinaryBitmap(Ref binarizer); 36 | virtual ~BinaryBitmap(); 37 | 38 | Ref getBlackRow(int y, Ref row); 39 | Ref getBlackMatrix(); 40 | 41 | Ref getLuminanceSource() const; 42 | 43 | int getWidth() const; 44 | int getHeight() const; 45 | 46 | bool isRotateSupported() const; 47 | Ref rotateCounterClockwise(); 48 | 49 | bool isCropSupported() const; 50 | Ref crop(int left, int top, int width, int height); 51 | 52 | }; 53 | 54 | } 55 | 56 | #endif /* BINARYBITMAP_H_ */ 57 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/ChecksumException.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * ChecksumException.cpp 4 | * zxing 5 | * 6 | * Created by Christian Brunschen on 13/05/2008. 7 | * Copyright 2008 ZXing authors All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include 23 | 24 | using zxing::ChecksumException; 25 | 26 | ChecksumException::ChecksumException() throw() {} 27 | ChecksumException::ChecksumException(const char *msg) throw() : ReaderException(msg) {} 28 | ChecksumException::~ChecksumException() throw() {} 29 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/ChecksumException.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | 3 | #ifndef __CHECKSUM_EXCEPTION_H__ 4 | #define __NOT_FOUND_EXCEPTION_H__ 5 | 6 | /* 7 | * Copyright 20011 ZXing authors 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include 23 | 24 | namespace zxing { 25 | class ChecksumException : public ReaderException { 26 | typedef ReaderException Base; 27 | public: 28 | ChecksumException() throw(); 29 | ChecksumException(const char *msg) throw(); 30 | ~ChecksumException() throw(); 31 | }; 32 | } 33 | 34 | #endif // __CHECKSUM_EXCEPTION_H__ 35 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/Exception.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * Exception.cpp 4 | * ZXing 5 | * 6 | * Created by Christian Brunschen on 03/06/2008. 7 | * Copyright 2008-2011 ZXing authors All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | using zxing::Exception; 28 | 29 | void Exception::deleteMessage() { 30 | delete [] message; 31 | } 32 | 33 | char const* Exception::copy(char const* msg) { 34 | char* message = 0; 35 | if (msg) { 36 | int l = strlen(msg)+1; 37 | if (l) { 38 | message = new char[l]; 39 | strcpy(message, msg); 40 | } 41 | } 42 | return message; 43 | } 44 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/Exception.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __EXCEPTION_H__ 3 | #define __EXCEPTION_H__ 4 | 5 | /* 6 | * Exception.h 7 | * ZXing 8 | * 9 | * Copyright 2010 ZXing authors All rights reserved. 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | #include 25 | #include 26 | 27 | namespace zxing { 28 | 29 | class Exception : public std::exception { 30 | private: 31 | char const* const message; 32 | 33 | public: 34 | Exception() throw() : message(0) {} 35 | Exception(const char* msg) throw() : message(copy(msg)) {} 36 | Exception(Exception const& that) throw() : std::exception(that), message(copy(that.message)) {} 37 | ~Exception() throw() { 38 | if(message) { 39 | deleteMessage(); 40 | } 41 | } 42 | char const* what() const throw() {return message ? message : "";} 43 | 44 | private: 45 | static char const* copy(char const*); 46 | void deleteMessage(); 47 | }; 48 | 49 | } 50 | 51 | #endif // __EXCEPTION_H__ 52 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/FormatException.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * FormatException.cpp 4 | * zxing 5 | * 6 | * Created by Christian Brunschen on 13/05/2008. 7 | * Copyright 2008 ZXing authors All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include 23 | 24 | namespace zxing { 25 | 26 | FormatException::FormatException() {} 27 | 28 | FormatException::FormatException(const char *msg) : 29 | ReaderException(msg) { 30 | } 31 | 32 | FormatException::~FormatException() throw() { 33 | } 34 | 35 | FormatException const& 36 | FormatException::getFormatInstance() { 37 | static FormatException instance; 38 | return instance; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/FormatException.h: -------------------------------------------------------------------------------- 1 | #ifndef __FORMAT_EXCEPTION_H__ 2 | #define __FORMAT_EXCEPTION_H__ 3 | 4 | /* 5 | * FormatException.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | 25 | namespace zxing { 26 | 27 | class FormatException : public ReaderException { 28 | public: 29 | FormatException(); 30 | FormatException(const char *msg); 31 | ~FormatException() throw(); 32 | 33 | static FormatException const& getFormatInstance(); 34 | }; 35 | 36 | } 37 | #endif // __FORMAT_EXCEPTION_H__ 38 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/IllegalStateException.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | 3 | #ifndef __ILLEGAL_STATE_EXCEPTION_H__ 4 | #define __ILLEGAL_STATE_EXCEPTION_H__ 5 | 6 | /* 7 | * Copyright 20011 ZXing authors 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may illegal use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include 23 | 24 | namespace zxing { 25 | 26 | class IllegalStateException : public ReaderException { 27 | public: 28 | IllegalStateException() throw() {} 29 | IllegalStateException(const char *msg) throw() : ReaderException(msg) {} 30 | ~IllegalStateException() throw() {} 31 | }; 32 | 33 | } 34 | 35 | #endif // __ILLEGAL_STATE_EXCEPTION_H__ 36 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/InvertedLuminanceSource.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __INVERTEDLUMINANCESOURCE_H__ 3 | #define __INVERTEDLUMINANCESOURCE_H__ 4 | /* 5 | * Copyright 2013 ZXing authors All rights reserved. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | namespace zxing { 24 | 25 | class InvertedLuminanceSource : public LuminanceSource { 26 | private: 27 | typedef LuminanceSource Super; 28 | const Ref delegate; 29 | 30 | public: 31 | InvertedLuminanceSource(Ref const&); 32 | 33 | ArrayRef getRow(int y, ArrayRef row) const; 34 | ArrayRef getMatrix() const; 35 | 36 | boolean isCropSupported() const; 37 | Ref crop(int left, int top, int width, int height) const; 38 | 39 | boolean isRotateSupported() const; 40 | 41 | virtual Ref invert() const; 42 | 43 | Ref rotateCounterClockwise() const; 44 | }; 45 | 46 | } 47 | 48 | #endif /* INVERTEDLUMINANCESOURCE_H_ */ 49 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/LuminanceSource.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __LUMINANCESOURCE_H__ 3 | #define __LUMINANCESOURCE_H__ 4 | /* 5 | * LuminanceSource.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | namespace zxing { 28 | 29 | class LuminanceSource : public Counted { 30 | private: 31 | const int width; 32 | const int height; 33 | 34 | public: 35 | LuminanceSource(int width, int height); 36 | virtual ~LuminanceSource(); 37 | 38 | int getWidth() const { return width; } 39 | int getHeight() const { return height; } 40 | 41 | // Callers take ownership of the returned memory and must call delete [] on it themselves. 42 | virtual ArrayRef getRow(int y, ArrayRef row) const = 0; 43 | virtual ArrayRef getMatrix() const = 0; 44 | 45 | virtual bool isCropSupported() const; 46 | virtual Ref crop(int left, int top, int width, int height) const; 47 | 48 | virtual bool isRotateSupported() const; 49 | 50 | virtual Ref invert() const; 51 | 52 | virtual Ref rotateCounterClockwise() const; 53 | 54 | operator std::string () const; 55 | }; 56 | 57 | } 58 | 59 | #endif /* LUMINANCESOURCE_H_ */ 60 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/MultiFormatReader.h: -------------------------------------------------------------------------------- 1 | #ifndef __MULTI_FORMAT_READER_H__ 2 | #define __MULTI_FORMAT_READER_H__ 3 | 4 | /* 5 | * MultiFormatBarcodeReader.h 6 | * ZXing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | namespace zxing { 30 | class MultiFormatReader : public Reader { 31 | private: 32 | Ref decodeInternal(Ref image); 33 | 34 | std::vector > readers_; 35 | DecodeHints hints_; 36 | 37 | public: 38 | MultiFormatReader(); 39 | 40 | Ref decode(Ref image); 41 | Ref decode(Ref image, DecodeHints hints); 42 | Ref decodeWithState(Ref image); 43 | void setHints(DecodeHints hints); 44 | ~MultiFormatReader(); 45 | }; 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/NotFoundException.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | 3 | #ifndef __NOT_FOUND_EXCEPTION_H__ 4 | #define __NOT_FOUND_EXCEPTION_H__ 5 | 6 | /* 7 | * Copyright 20011 ZXing authors 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include 23 | 24 | namespace zxing { 25 | 26 | class NotFoundException : public ReaderException { 27 | public: 28 | NotFoundException() throw() {} 29 | NotFoundException(const char *msg) throw() : ReaderException(msg) {} 30 | ~NotFoundException() throw() {} 31 | }; 32 | 33 | } 34 | 35 | #endif // __NOT_FOUND_EXCEPTION_H__ 36 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/Reader.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Reader.cpp 3 | * zxing 4 | * 5 | * Created by Christian Brunschen on 13/05/2008. 6 | * Copyright 2008 ZXing authors All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | #include 22 | 23 | namespace zxing { 24 | 25 | Reader::~Reader() { } 26 | 27 | Ref Reader::decode(Ref image) { 28 | return decode(image, DecodeHints::DEFAULT_HINT); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/Reader.h: -------------------------------------------------------------------------------- 1 | #ifndef __READER_H__ 2 | #define __READER_H__ 3 | 4 | /* 5 | * Reader.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | namespace zxing { 28 | 29 | class Reader : public Counted { 30 | protected: 31 | Reader() {} 32 | public: 33 | virtual Ref decode(Ref image); 34 | virtual Ref decode(Ref image, DecodeHints hints) = 0; 35 | virtual ~Reader(); 36 | }; 37 | 38 | } 39 | 40 | #endif // __READER_H__ 41 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/ReaderException.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __READER_EXCEPTION_H__ 3 | #define __READER_EXCEPTION_H__ 4 | 5 | /* 6 | * ReaderException.h 7 | * zxing 8 | * 9 | * Copyright 2010 ZXing authors All rights reserved. 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | #include 25 | 26 | namespace zxing { 27 | 28 | class ReaderException : public Exception { 29 | public: 30 | ReaderException() throw() {} 31 | ReaderException(char const* msg) throw() : Exception(msg) {} 32 | ~ReaderException() throw() {} 33 | }; 34 | 35 | } 36 | 37 | #endif // __READER_EXCEPTION_H__ 38 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/Result.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * Result.cpp 4 | * zxing 5 | * 6 | * Created by Christian Brunschen on 13/05/2008. 7 | * Copyright 2008 ZXing authors All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include 23 | 24 | using zxing::Result; 25 | using zxing::Ref; 26 | using zxing::ArrayRef; 27 | using zxing::String; 28 | using zxing::ResultPoint; 29 | 30 | // VC++ 31 | using zxing::BarcodeFormat; 32 | 33 | Result::Result(Ref text, 34 | ArrayRef rawBytes, 35 | ArrayRef< Ref > resultPoints, 36 | BarcodeFormat format, std::string charSet) : 37 | text_(text), rawBytes_(rawBytes), resultPoints_(resultPoints), format_(format), charSet_(charSet) { 38 | } 39 | 40 | Result::~Result() { 41 | } 42 | 43 | Ref Result::getText() { 44 | return text_; 45 | } 46 | 47 | ArrayRef Result::getRawBytes() { 48 | return rawBytes_; 49 | } 50 | 51 | ArrayRef< Ref > const& Result::getResultPoints() const { 52 | return resultPoints_; 53 | } 54 | 55 | ArrayRef< Ref >& Result::getResultPoints() { 56 | return resultPoints_; 57 | } 58 | 59 | zxing::BarcodeFormat Result::getBarcodeFormat() const { 60 | return format_; 61 | } 62 | 63 | std::string Result::getCharSet() const 64 | { 65 | return charSet_; 66 | } 67 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/Result.h: -------------------------------------------------------------------------------- 1 | #ifndef __RESULT_H__ 2 | #define __RESULT_H__ 3 | 4 | /* 5 | * Result.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | namespace zxing { 31 | 32 | class Result : public Counted { 33 | private: 34 | Ref text_; 35 | ArrayRef rawBytes_; 36 | ArrayRef< Ref > resultPoints_; 37 | BarcodeFormat format_; 38 | std::string charSet_; 39 | 40 | public: 41 | Result(Ref text, 42 | ArrayRef rawBytes, 43 | ArrayRef< Ref > resultPoints, 44 | BarcodeFormat format, std::string charSet = ""); 45 | ~Result(); 46 | Ref getText(); 47 | ArrayRef getRawBytes(); 48 | ArrayRef< Ref > const& getResultPoints() const; 49 | ArrayRef< Ref >& getResultPoints(); 50 | BarcodeFormat getBarcodeFormat() const; 51 | std::string getCharSet() const; 52 | 53 | friend std::ostream& operator<<(std::ostream &out, Result& result); 54 | }; 55 | 56 | } 57 | #endif // __RESULT_H__ 58 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/ResultIO.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * ResultIO.cpp 4 | * zxing 5 | * 6 | * Created by Christian Brunschen on 13/05/2008. 7 | * Copyright 2008 ZXing authors All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include 23 | 24 | using zxing::Result; 25 | using std::ostream; 26 | 27 | ostream& zxing::operator<<(ostream &out, Result& result) { 28 | if (result.text_ != 0) { 29 | out << result.text_->getText(); 30 | } else { 31 | out << "[" << result.rawBytes_->size() << " bytes]"; 32 | } 33 | return out; 34 | } 35 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/ResultPoint.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __RESULT_POINT_H__ 3 | #define __RESULT_POINT_H__ 4 | 5 | /* 6 | * ResultPoint.h 7 | * zxing 8 | * 9 | * Copyright 2010 ZXing authors All rights reserved. 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | #include 25 | #include 26 | 27 | namespace zxing { 28 | 29 | class ResultPoint : public Counted { 30 | protected: 31 | const float posX_; 32 | const float posY_; 33 | 34 | public: 35 | ResultPoint(); 36 | ResultPoint(float x, float y); 37 | ResultPoint(int x, int y); 38 | virtual ~ResultPoint(); 39 | 40 | virtual float getX() const; 41 | virtual float getY() const; 42 | 43 | bool equals(Ref other); 44 | 45 | static void orderBestPatterns(std::vector > &patterns); 46 | static float distance(Ref point1, Ref point2); 47 | static float distance(float x1, float x2, float y1, float y2); 48 | 49 | private: 50 | static float crossProductZ(Ref pointA, Ref pointB, Ref pointC); 51 | }; 52 | 53 | } 54 | 55 | #endif // __RESULT_POINT_H__ 56 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/ResultPointCallback.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ResultPointCallback.cpp 3 | * zxing 4 | * 5 | * Copyright 2010 ZXing authors All rights reserved. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include 21 | 22 | namespace zxing { 23 | 24 | ResultPointCallback::~ResultPointCallback() {} 25 | 26 | } 27 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/ResultPointCallback.h: -------------------------------------------------------------------------------- 1 | #ifndef __RESULT_POINT_CALLBACK_H__ 2 | #define __RESULT_POINT_CALLBACK_H__ 3 | 4 | /* 5 | * ResultPointCallback.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | 25 | namespace zxing { 26 | 27 | class ResultPoint; 28 | 29 | class ResultPointCallback : public Counted { 30 | protected: 31 | ResultPointCallback() {} 32 | public: 33 | virtual void foundPossibleResultPoint(ResultPoint const& point) = 0; 34 | virtual ~ResultPointCallback(); 35 | }; 36 | 37 | } 38 | 39 | #endif // __RESULT_POINT_CALLBACK_H__ 40 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/WriterException.h: -------------------------------------------------------------------------------- 1 | #ifndef WRITEREXCEPTION_H 2 | #define WRITEREXCEPTION_H 3 | 4 | #include 5 | 6 | namespace zxing { 7 | 8 | class WriterException : public Exception { 9 | public: 10 | WriterException() throw() {} 11 | WriterException(char const* msg) throw() : Exception(msg) {} 12 | ~WriterException() throw() {} 13 | }; 14 | 15 | } 16 | 17 | #endif // WRITEREXCEPTION_H 18 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/aztec/AztecDetectorResult.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * AtztecDetecorResult.cpp 4 | * zxing 5 | * 6 | * Created by Lukas Stabe on 08/02/2012. 7 | * Copyright 2012 ZXing authors All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include 23 | 24 | using zxing::aztec::AztecDetectorResult; 25 | 26 | // VC++ 27 | using zxing::Ref; 28 | using zxing::ArrayRef; 29 | using zxing::BitMatrix; 30 | using zxing::ResultPoint; 31 | 32 | 33 | AztecDetectorResult::AztecDetectorResult(Ref bits, 34 | ArrayRef< Ref > points, 35 | bool compact, 36 | int nbDatablocks, 37 | int nbLayers) 38 | : DetectorResult(bits, points), 39 | compact_(compact), 40 | nbDatablocks_(nbDatablocks), 41 | nbLayers_(nbLayers) { 42 | } 43 | 44 | bool AztecDetectorResult::isCompact() { 45 | return compact_; 46 | } 47 | 48 | int AztecDetectorResult::getNBDatablocks() { 49 | return nbDatablocks_; 50 | } 51 | 52 | int AztecDetectorResult::getNBLayers() { 53 | return nbLayers_; 54 | } 55 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/aztec/AztecDetectorResult.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * AtztecDetecorResult.h 4 | * zxing 5 | * 6 | * Created by Lukas Stabe on 08/02/2012. 7 | * Copyright 2012 ZXing authors All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include 23 | 24 | #ifndef ZXingWidget_AtztecDetecorResult_h 25 | #define ZXingWidget_AtztecDetecorResult_h 26 | 27 | namespace zxing { 28 | namespace aztec { 29 | 30 | class AztecDetectorResult : public DetectorResult { 31 | private: 32 | bool compact_; 33 | int nbDatablocks_, nbLayers_; 34 | public: 35 | AztecDetectorResult(Ref bits, 36 | ArrayRef< Ref > points, 37 | bool compact, 38 | int nbDatablocks, 39 | int nbLayers); 40 | bool isCompact(); 41 | int getNBDatablocks(); 42 | int getNBLayers(); 43 | }; 44 | 45 | } 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/aztec/AztecReader.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * AztecReader.cpp 4 | * zxing 5 | * 6 | * Created by Lukas Stabe on 08/02/2012. 7 | * Copyright 2012 ZXing authors All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | using zxing::Ref; 28 | using zxing::ArrayRef; 29 | using zxing::Result; 30 | using zxing::aztec::AztecReader; 31 | 32 | // VC++ 33 | using zxing::BinaryBitmap; 34 | using zxing::DecodeHints; 35 | 36 | AztecReader::AztecReader() : decoder_() { 37 | // nothing 38 | } 39 | 40 | Ref AztecReader::decode(Ref image) { 41 | Detector detector(image->getBlackMatrix()); 42 | 43 | Ref detectorResult(detector.detect()); 44 | 45 | ArrayRef< Ref > points(detectorResult->getPoints()); 46 | 47 | Ref decoderResult(decoder_.decode(detectorResult)); 48 | 49 | Ref result(new Result(decoderResult->getText(), 50 | decoderResult->getRawBytes(), 51 | points, 52 | BarcodeFormat::AZTEC)); 53 | 54 | return result; 55 | } 56 | 57 | Ref AztecReader::decode(Ref image, DecodeHints) { 58 | //cout << "decoding with hints not supported for aztec" << "\n" << flush; 59 | return this->decode(image); 60 | } 61 | 62 | AztecReader::~AztecReader() { 63 | // nothing 64 | } 65 | 66 | zxing::aztec::Decoder& AztecReader::getDecoder() { 67 | return decoder_; 68 | } 69 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/aztec/AztecReader.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * AztecReader.h 4 | * zxing 5 | * 6 | * Created by Lukas Stabe on 08/02/2012. 7 | * Copyright 2012 ZXing authors All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #ifndef ZXingWidget_AztecReader_h 27 | #define ZXingWidget_AztecReader_h 28 | 29 | namespace zxing { 30 | namespace aztec { 31 | 32 | class AztecReader : public Reader { 33 | private: 34 | Decoder decoder_; 35 | 36 | protected: 37 | Decoder &getDecoder(); 38 | 39 | public: 40 | AztecReader(); 41 | virtual Ref decode(Ref image); 42 | virtual Ref decode(Ref image, DecodeHints hints); 43 | virtual ~AztecReader(); 44 | }; 45 | 46 | } 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/aztec/decoder/Decoder.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * Decoder.h 4 | * zxing 5 | * 6 | * Created by Lukas Stabe on 08/02/2012. 7 | * Copyright 2012 ZXing authors All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #ifndef __ZXING_AZTEC_DECODER_DECODER_H__ 23 | #define __ZXING_AZTEC_DECODER_DECODER_H__ 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace zxing { 30 | 31 | class DecoderResult; 32 | 33 | namespace aztec { 34 | 35 | class Decoder : public Counted { 36 | private: 37 | enum Table { 38 | UPPER, 39 | LOWER, 40 | MIXED, 41 | DIGIT, 42 | PUNCT, 43 | BINARY 44 | }; 45 | 46 | static Table getTable(char t); 47 | static const char* getCharacter(Table table, int code); 48 | 49 | int numCodewords_; 50 | int codewordSize_; 51 | Ref ddata_; 52 | int invertedBitCount_; 53 | 54 | Ref getEncodedData(Ref correctedBits); 55 | Ref correctBits(Ref rawbits); 56 | Ref extractBits(Ref matrix); 57 | static Ref removeDashedLines(Ref matrix); 58 | static int readCode(Ref rawbits, int startIndex, int length); 59 | 60 | 61 | public: 62 | Decoder(); 63 | Ref decode(Ref detectorResult); 64 | }; 65 | 66 | } 67 | } 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/BitArrayIO.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * Copyright 2010 ZXing authors. All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include 19 | 20 | using zxing::BitArray; 21 | using std::ostream; 22 | 23 | ostream& zxing::operator << (ostream& os, BitArray const& ba) { 24 | for (int i = 0, size = ba.getSize(); i < size; i++) { 25 | if ((i & 0x07) == 0) { 26 | os << ' '; 27 | } 28 | os << (ba.get(i) ? 'X' : '.'); 29 | } 30 | return os; 31 | } 32 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/BitSource.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * BitSource.cpp 4 | * zxing 5 | * 6 | * Created by Christian Brunschen on 09/05/2008. 7 | * Copyright 2008 Google UK. All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace zxing { 27 | 28 | int BitSource::readBits(int numBits) { 29 | if (numBits < 0 || numBits > 32 || numBits > available()) { 30 | std::ostringstream oss; 31 | oss << numBits; 32 | throw IllegalArgumentException(oss.str().c_str()); 33 | } 34 | 35 | int result = 0; 36 | 37 | // First, read remainder from current byte 38 | if (bitOffset_ > 0) { 39 | int bitsLeft = 8 - bitOffset_; 40 | int toRead = numBits < bitsLeft ? numBits : bitsLeft; 41 | int bitsToNotRead = bitsLeft - toRead; 42 | int mask = (0xFF >> (8 - toRead)) << bitsToNotRead; 43 | result = (bytes_[byteOffset_] & mask) >> bitsToNotRead; 44 | numBits -= toRead; 45 | bitOffset_ += toRead; 46 | if (bitOffset_ == 8) { 47 | bitOffset_ = 0; 48 | byteOffset_++; 49 | } 50 | } 51 | 52 | // Next read whole bytes 53 | if (numBits > 0) { 54 | while (numBits >= 8) { 55 | result = (result << 8) | (bytes_[byteOffset_] & 0xFF); 56 | byteOffset_++; 57 | numBits -= 8; 58 | } 59 | 60 | 61 | // Finally read a partial byte 62 | if (numBits > 0) { 63 | int bitsToNotRead = 8 - numBits; 64 | int mask = (0xFF >> bitsToNotRead) << bitsToNotRead; 65 | result = (result << numBits) | ((bytes_[byteOffset_] & mask) >> bitsToNotRead); 66 | bitOffset_ += numBits; 67 | } 68 | } 69 | 70 | return result; 71 | } 72 | 73 | int BitSource::available() { 74 | return 8 * (bytes_->size() - byteOffset_) - bitOffset_; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/BitSource.h: -------------------------------------------------------------------------------- 1 | #ifndef __BIT_SOURCE_H__ 2 | #define __BIT_SOURCE_H__ 3 | 4 | /* 5 | * BitSource.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | 25 | namespace zxing { 26 | /** 27 | *

This provides an easy abstraction to read bits at a time from a sequence of bytes, where the 28 | * number of bits read is not often a multiple of 8.

29 | * 30 | *

This class is not thread-safe.

31 | * 32 | * @author srowen@google.com (Sean Owen) 33 | * @author christian.brunschen@gmail.com (Christian Brunschen) 34 | */ 35 | class BitSource : public Counted { 36 | typedef char byte; 37 | private: 38 | ArrayRef bytes_; 39 | int byteOffset_; 40 | int bitOffset_; 41 | public: 42 | /** 43 | * @param bytes bytes from which this will read bits. Bits will be read from the first byte first. 44 | * Bits are read within a byte from most-significant to least-significant bit. 45 | */ 46 | BitSource(ArrayRef &bytes) : 47 | bytes_(bytes), byteOffset_(0), bitOffset_(0) { 48 | } 49 | 50 | int getBitOffset() { 51 | return bitOffset_; 52 | } 53 | 54 | int getByteOffset() { 55 | return byteOffset_; 56 | } 57 | 58 | /** 59 | * @param numBits number of bits to read 60 | * @return int representing the bits read. The bits will appear as the least-significant 61 | * bits of the int 62 | * @throws IllegalArgumentException if numBits isn't in [1,32] 63 | */ 64 | int readBits(int numBits); 65 | 66 | /** 67 | * @return number of bits that can be read successfully 68 | */ 69 | int available(); 70 | }; 71 | 72 | } 73 | 74 | #endif // __BIT_SOURCE_H__ 75 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/CharacterSetECI.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | 3 | #ifndef __CHARACTERSET_ECI__ 4 | #define __CHARACTERSET_ECI__ 5 | 6 | /* 7 | * Copyright 2008-2011 ZXing authors 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | namespace zxing { 26 | namespace common { 27 | 28 | class CharacterSetECI { 29 | private: 30 | static std::map VALUE_TO_ECI; 31 | static std::map NAME_TO_ECI; 32 | static const bool inited; 33 | static bool init_tables(); 34 | 35 | int const* const values_; 36 | char const* const* const names_; 37 | 38 | CharacterSetECI(int const* values, char const* const* names); 39 | 40 | static void addCharacterSet(int const* value, char const* const* encodingNames); 41 | 42 | public: 43 | char const* name() const; 44 | int getValue() const; 45 | 46 | static CharacterSetECI* getCharacterSetECIByValue(int value); 47 | static CharacterSetECI* getCharacterSetECIByName(std::string const& name); 48 | }; 49 | 50 | } 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/DecoderResult.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * DecoderResult.cpp 4 | * zxing 5 | * 6 | * Created by Christian Brunschen on 20/05/2008. 7 | * Copyright 2008-2011 ZXing authors All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include 23 | 24 | using namespace std; 25 | using namespace zxing; 26 | 27 | DecoderResult::DecoderResult(ArrayRef rawBytes, 28 | Ref text, 29 | ArrayRef< ArrayRef >& byteSegments, 30 | string const& ecLevel, string charSet) : 31 | rawBytes_(rawBytes), 32 | text_(text), 33 | byteSegments_(byteSegments), 34 | ecLevel_(ecLevel), charSet_(charSet) {} 35 | 36 | DecoderResult::DecoderResult(ArrayRef rawBytes, 37 | Ref text) 38 | : rawBytes_(rawBytes), text_(text),charSet_("") {} 39 | 40 | ArrayRef DecoderResult::getRawBytes() { 41 | return rawBytes_; 42 | } 43 | 44 | Ref DecoderResult::getText() { 45 | return text_; 46 | } 47 | 48 | string DecoderResult::charSet() 49 | { 50 | return charSet_; 51 | } 52 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/DecoderResult.h: -------------------------------------------------------------------------------- 1 | #ifndef __DECODER_RESULT_H__ 2 | #define __DECODER_RESULT_H__ 3 | 4 | /* 5 | * DecoderResult.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace zxing { 29 | 30 | class DecoderResult : public Counted { 31 | private: 32 | ArrayRef rawBytes_; 33 | Ref text_; 34 | ArrayRef< ArrayRef > byteSegments_; 35 | std::string ecLevel_; 36 | std::string charSet_; 37 | 38 | public: 39 | DecoderResult(ArrayRef rawBytes, 40 | Ref text, 41 | ArrayRef< ArrayRef >& byteSegments, 42 | std::string const& ecLevel, 43 | std::string charSet = ""); 44 | 45 | DecoderResult(ArrayRef rawBytes, Ref text); 46 | 47 | ArrayRef getRawBytes(); 48 | Ref getText(); 49 | std::string charSet(); 50 | }; 51 | 52 | } 53 | 54 | #endif // __DECODER_RESULT_H__ 55 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/DetectorResult.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * DetectorResult.cpp 4 | * zxing 5 | * 6 | * Created by Christian Brunschen on 14/05/2008. 7 | * Copyright 2008 ZXing authors All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include 23 | 24 | namespace zxing { 25 | 26 | DetectorResult::DetectorResult(Ref bits, 27 | ArrayRef< Ref > points) 28 | : bits_(bits), points_(points) { 29 | } 30 | 31 | Ref DetectorResult::getBits() { 32 | return bits_; 33 | } 34 | 35 | ArrayRef< Ref > DetectorResult::getPoints() { 36 | return points_; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/DetectorResult.h: -------------------------------------------------------------------------------- 1 | #ifndef __DETECTOR_RESULT_H__ 2 | #define __DETECTOR_RESULT_H__ 3 | 4 | /* 5 | * DetectorResult.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace zxing { 29 | 30 | class DetectorResult : public Counted { 31 | private: 32 | Ref bits_; 33 | ArrayRef< Ref > points_; 34 | 35 | public: 36 | DetectorResult(Ref bits, ArrayRef< Ref > points); 37 | Ref getBits(); 38 | ArrayRef< Ref > getPoints(); 39 | }; 40 | 41 | } 42 | 43 | #endif // __DETECTOR_RESULT_H__ 44 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/GlobalHistogramBinarizer.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __GLOBALHISTOGRAMBINARIZER_H__ 3 | #define __GLOBALHISTOGRAMBINARIZER_H__ 4 | /* 5 | * GlobalHistogramBinarizer.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace zxing { 29 | 30 | class GlobalHistogramBinarizer : public Binarizer { 31 | private: 32 | ArrayRef luminances; 33 | ArrayRef buckets; 34 | public: 35 | GlobalHistogramBinarizer(Ref source); 36 | virtual ~GlobalHistogramBinarizer(); 37 | 38 | virtual Ref getBlackRow(int y, Ref row); 39 | virtual Ref getBlackMatrix(); 40 | static int estimateBlackPoint(ArrayRef const& buckets); 41 | Ref createBinarizer(Ref source); 42 | private: 43 | void initArrays(int luminanceSize); 44 | }; 45 | 46 | } 47 | 48 | #endif /* GLOBALHISTOGRAMBINARIZER_H_ */ 49 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/GreyscaleLuminanceSource.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __GREYSCALE_LUMINANCE_SOURCE__ 3 | #define __GREYSCALE_LUMINANCE_SOURCE__ 4 | /* 5 | * GreyscaleLuminanceSource.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | 25 | namespace zxing { 26 | 27 | class GreyscaleLuminanceSource : public LuminanceSource { 28 | 29 | private: 30 | typedef LuminanceSource Super; 31 | ArrayRef greyData_; 32 | const int dataWidth_; 33 | const int dataHeight_; 34 | const int left_; 35 | const int top_; 36 | 37 | public: 38 | GreyscaleLuminanceSource(ArrayRef greyData, int dataWidth, int dataHeight, int left, 39 | int top, int width, int height); 40 | 41 | ArrayRef getRow(int y, ArrayRef row) const; 42 | ArrayRef getMatrix() const; 43 | 44 | bool isRotateSupported() const { 45 | return true; 46 | } 47 | 48 | Ref rotateCounterClockwise() const; 49 | }; 50 | 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/GreyscaleRotatedLuminanceSource.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __GREYSCALE_ROTATED_LUMINANCE_SOURCE__ 3 | #define __GREYSCALE_ROTATED_LUMINANCE_SOURCE__ 4 | /* 5 | * GreyscaleRotatedLuminanceSource.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | 24 | #include 25 | 26 | namespace zxing { 27 | 28 | class GreyscaleRotatedLuminanceSource : public LuminanceSource { 29 | private: 30 | typedef LuminanceSource Super; 31 | ArrayRef greyData_; 32 | const int dataWidth_; 33 | const int left_; 34 | const int top_; 35 | 36 | public: 37 | GreyscaleRotatedLuminanceSource(ArrayRef greyData, int dataWidth, int dataHeight, 38 | int left, int top, int width, int height); 39 | 40 | ArrayRef getRow(int y, ArrayRef row) const; 41 | ArrayRef getMatrix() const; 42 | }; 43 | 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/GridSampler.h: -------------------------------------------------------------------------------- 1 | #ifndef __GRID_SAMPLER_H__ 2 | #define __GRID_SAMPLER_H__ 3 | 4 | /* 5 | * GridSampler.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | namespace zxing { 28 | class GridSampler { 29 | private: 30 | static GridSampler gridSampler; 31 | GridSampler(); 32 | 33 | public: 34 | Ref sampleGrid(Ref image, int dimension, Ref transform); 35 | Ref sampleGrid(Ref image, int dimensionX, int dimensionY, Ref transform); 36 | 37 | Ref sampleGrid(Ref image, int dimension, float p1ToX, float p1ToY, float p2ToX, float p2ToY, 38 | float p3ToX, float p3ToY, float p4ToX, float p4ToY, float p1FromX, float p1FromY, float p2FromX, 39 | float p2FromY, float p3FromX, float p3FromY, float p4FromX, float p4FromY); 40 | static void checkAndNudgePoints(Ref image, std::vector &points); 41 | static GridSampler &getInstance(); 42 | }; 43 | } 44 | 45 | #endif // __GRID_SAMPLER_H__ 46 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/IllegalArgumentException.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * IllegalArgumentException.cpp 3 | * zxing 4 | * 5 | * Created by Christian Brunschen on 06/05/2008. 6 | * Copyright 2008 Google UK. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | #include 22 | 23 | using zxing::IllegalArgumentException; 24 | 25 | IllegalArgumentException::IllegalArgumentException() : Exception() {} 26 | IllegalArgumentException::IllegalArgumentException(const char *msg) : Exception(msg) {} 27 | IllegalArgumentException::~IllegalArgumentException() throw() {} 28 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/IllegalArgumentException.h: -------------------------------------------------------------------------------- 1 | #ifndef __ILLEGAL_ARGUMENT_EXCEPTION_H__ 2 | #define __ILLEGAL_ARGUMENT_EXCEPTION_H__ 3 | 4 | /* 5 | * IllegalArgumentException.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | 25 | namespace zxing { 26 | 27 | class IllegalArgumentException : public Exception { 28 | public: 29 | IllegalArgumentException(); 30 | IllegalArgumentException(const char *msg); 31 | ~IllegalArgumentException() throw(); 32 | }; 33 | 34 | } 35 | 36 | #endif // __ILLEGAL_ARGUMENT_EXCEPTION_H__ 37 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/PerspectiveTransform.h: -------------------------------------------------------------------------------- 1 | #ifndef __PERSPECTIVE_TANSFORM_H__ 2 | #define __PERSPECTIVE_TANSFORM_H__ 3 | 4 | /* 5 | * PerspectiveTransform.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | namespace zxing { 27 | class PerspectiveTransform : public Counted { 28 | private: 29 | float a11, a12, a13, a21, a22, a23, a31, a32, a33; 30 | PerspectiveTransform(float a11, float a21, float a31, float a12, float a22, float a32, float a13, float a23, 31 | float a33); 32 | 33 | public: 34 | static Ref 35 | quadrilateralToQuadrilateral(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, 36 | float x0p, float y0p, float x1p, float y1p, float x2p, float y2p, float x3p, float y3p); 37 | static Ref squareToQuadrilateral(float x0, float y0, float x1, float y1, float x2, float y2, 38 | float x3, float y3); 39 | static Ref quadrilateralToSquare(float x0, float y0, float x1, float y1, float x2, float y2, 40 | float x3, float y3); 41 | Ref buildAdjoint(); 42 | Ref times(Ref other); 43 | void transformPoints(std::vector &points); 44 | 45 | friend std::ostream& operator<<(std::ostream& out, const PerspectiveTransform &pt); 46 | }; 47 | } 48 | 49 | #endif // __PERSPECTIVE_TANSFORM_H__ 50 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/Point.h: -------------------------------------------------------------------------------- 1 | #ifndef __POINT_H__ 2 | #define __POINT_H__ 3 | 4 | /* 5 | * Point.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | namespace zxing { 24 | class PointI { 25 | public: 26 | int x; 27 | int y; 28 | }; 29 | 30 | class Point { 31 | public: 32 | Point() : x(0.0f), y(0.0f) {}; 33 | Point(float x_, float y_) : x(x_), y(y_) {}; 34 | 35 | float x; 36 | float y; 37 | }; 38 | 39 | class Line { 40 | public: 41 | Line(Point start_, Point end_) : start(start_), end(end_) {}; 42 | 43 | Point start; 44 | Point end; 45 | }; 46 | } 47 | #endif // POINT_H_ 48 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/Str.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * String.cpp 4 | * zxing 5 | * 6 | * Created by Christian Brunschen on 20/05/2008. 7 | * Copyright 2008 ZXing authors All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include 23 | 24 | using std::string; 25 | using zxing::String; 26 | using zxing::Ref; 27 | 28 | String::String(const std::string &text) : 29 | text_(text) { 30 | } 31 | 32 | String::String(int capacity) { 33 | text_.reserve(capacity); 34 | } 35 | 36 | const std::string& String::getText() const { 37 | return text_; 38 | } 39 | 40 | char String::charAt(int i) const { return text_[i]; } 41 | 42 | int String::size() const { return text_.size(); } 43 | 44 | int String::length() const { return text_.size(); } 45 | 46 | Ref String::substring(int i) const { 47 | return Ref(new String(text_.substr(i))); 48 | } 49 | 50 | void String::append(const std::string &tail) { 51 | text_.append(tail); 52 | } 53 | 54 | void String::append(char c) { 55 | text_.append(1,c); 56 | } 57 | 58 | std::ostream& zxing::operator << (std::ostream& out, String const& s) { 59 | out << s.text_; 60 | return out; 61 | } 62 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/Str.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __STR_H__ 3 | #define __STR_H__ 4 | 5 | /* 6 | * Str.h 7 | * zxing 8 | * 9 | * Copyright 2010 ZXing authors All rights reserved. 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | namespace zxing { 29 | 30 | class String; 31 | std::ostream& operator << (std::ostream& out, String const& s); 32 | 33 | class String : public Counted { 34 | private: 35 | std::string text_; 36 | public: 37 | explicit String(const std::string &text); 38 | explicit String(int); 39 | char charAt(int) const; 40 | Ref substring(int) const; 41 | const std::string& getText() const; 42 | int size() const; 43 | void append(std::string const& tail); 44 | void append(char c); 45 | int length() const; 46 | friend std::ostream& zxing::operator << (std::ostream& out, String const& s); 47 | }; 48 | 49 | } 50 | 51 | #endif // __COMMON__STRING_H__ 52 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/StringUtils.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | 3 | #ifndef __STRING_UTILS__ 4 | #define __STRING_UTILS__ 5 | 6 | /* 7 | * Copyright (C) 2010-2011 ZXing authors 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace zxing { 27 | namespace common { 28 | 29 | class StringUtils { 30 | private: 31 | static char const* const PLATFORM_DEFAULT_ENCODING; 32 | 33 | StringUtils() {} 34 | 35 | public: 36 | static char const* const ASCII; 37 | static char const* const SHIFT_JIS; 38 | static char const* const GB2312; 39 | static char const* const EUC_JP; 40 | static char const* const UTF8; 41 | static char const* const ISO88591; 42 | static const bool ASSUME_SHIFT_JIS; 43 | 44 | typedef std::map Hashtable; 45 | 46 | static std::string guessEncoding(char* bytes, int length, Hashtable const& hints); 47 | }; 48 | 49 | } 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/detector/JavaMath.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __ZXING_COMMON_DETECTOR_MATH_H__ 3 | #define __ZXING_COMMON_DETECTOR_MATH_H__ 4 | /* 5 | * Copyright 2012 ZXing authors All rights reserved. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include 21 | 22 | namespace zxing { 23 | namespace common { 24 | namespace detector { 25 | 26 | class Math { 27 | private: 28 | Math(); 29 | ~Math(); 30 | public: 31 | 32 | // Java standard Math.round 33 | static inline int round(float a) { 34 | return (int)std::floor(a +0.5f); 35 | } 36 | 37 | }; 38 | 39 | } 40 | } 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/detector/MathUtils.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __ZXING_COMMON_DETECTOR_MATHUTILS_H__ 3 | #define __ZXING_COMMON_DETECTOR_MATHUTILS_H__ 4 | /* 5 | * Copyright 2012 ZXing authors All rights reserved. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include 21 | 22 | namespace zxing { 23 | namespace common { 24 | namespace detector { 25 | 26 | class MathUtils { 27 | private: 28 | MathUtils(); 29 | ~MathUtils(); 30 | public: 31 | 32 | /** 33 | * Ends up being a bit faster than {@link Math#round(float)}. This merely rounds its 34 | * argument to the nearest int, where x.5 rounds up to x+1. 35 | */ 36 | static inline int round(float d) { 37 | return (int) (d + 0.5f); 38 | } 39 | 40 | static inline float distance(float aX, float aY, float bX, float bY) { 41 | float xDiff = aX - bX; 42 | float yDiff = aY - bY; 43 | return sqrt(xDiff * xDiff + yDiff * yDiff); 44 | } 45 | 46 | static inline float distance(int aX, int aY, int bX, int bY) { 47 | int xDiff = aX - bX; 48 | int yDiff = aY - bY; 49 | return sqrt(float(xDiff * xDiff + yDiff * yDiff)); 50 | } 51 | }; 52 | 53 | } 54 | } 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/detector/MonochromeRectangleDetector.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | 3 | #ifndef __MONOCHROMERECTANGLEDETECTOR_H__ 4 | #define __MONOCHROMERECTANGLEDETECTOR_H__ 5 | 6 | /* 7 | * MonochromeRectangleDetector.h 8 | * y_wmk 9 | * 10 | * Created by Luiz Silva on 09/02/2010. 11 | * Copyright 2010 y_wmk authors All rights reserved. 12 | * 13 | * Licensed under the Apache License, Version 2.0 (the "License"); 14 | * you may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at 16 | * 17 | * http://www.apache.org/licenses/LICENSE-2.0 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | namespace zxing { 34 | 35 | struct TwoInts: public Counted { 36 | int start; 37 | int end; 38 | }; 39 | 40 | class MonochromeRectangleDetector : public Counted { 41 | private: 42 | static const int MAX_MODULES = 32; 43 | Ref image_; 44 | 45 | public: 46 | MonochromeRectangleDetector(Ref image) : image_(image) { }; 47 | 48 | std::vector > detect(); 49 | 50 | private: 51 | Ref findCornerFromCenter(int centerX, int deltaX, int left, int right, 52 | int centerY, int deltaY, int top, int bottom, int maxWhiteRun); 53 | 54 | Ref blackWhiteRange(int fixedDimension, int maxWhiteRun, int minDim, int maxDim, 55 | bool horizontal); 56 | 57 | int max(int a, float b) { return (float) a > b ? a : (int) b;}; 58 | }; 59 | 60 | } 61 | 62 | #endif // __MONOCHROMERECTANGLEDETECTOR_H__ 63 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/detector/WhiteRectangleDetector.h: -------------------------------------------------------------------------------- 1 | #ifndef __WHITERECTANGLEDETECTOR_H__ 2 | #define __WHITERECTANGLEDETECTOR_H__ 3 | 4 | /* 5 | * WhiteRectangleDetector.h 6 | * 7 | * 8 | * Created by Luiz Silva on 09/02/2010. 9 | * Copyright 2010 authors All rights reserved. 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | 32 | namespace zxing { 33 | 34 | class WhiteRectangleDetector : public Counted { 35 | private: 36 | static int INIT_SIZE; 37 | static int CORR; 38 | Ref image_; 39 | int width_; 40 | int height_; 41 | int leftInit_; 42 | int rightInit_; 43 | int downInit_; 44 | int upInit_; 45 | 46 | public: 47 | WhiteRectangleDetector(Ref image); 48 | WhiteRectangleDetector(Ref image, int initSize, int x, int y); 49 | std::vector > detect(); 50 | 51 | private: 52 | Ref getBlackPointOnSegment(int aX, int aY, int bX, int bY); 53 | std::vector > centerEdges(Ref y, Ref z, 54 | Ref x, Ref t); 55 | bool containsBlackPoint(int a, int b, int fixed, bool horizontal); 56 | }; 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/reedsolomon/GenericGF.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * GenericGF.h 4 | * zxing 5 | * 6 | * Created by Lukas Stabe on 13/02/2012. 7 | * Copyright 2012 ZXing authors All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #ifndef GENERICGF_H 23 | #define GENERICGF_H 24 | 25 | #include 26 | #include 27 | 28 | namespace zxing { 29 | class GenericGFPoly; 30 | 31 | class GenericGF : public Counted { 32 | 33 | private: 34 | std::vector expTable; 35 | std::vector logTable; 36 | Ref zero; 37 | Ref one; 38 | int size; 39 | int primitive; 40 | int generatorBase; 41 | bool initialized; 42 | 43 | void initialize(); 44 | void checkInit(); 45 | 46 | public: 47 | static Ref AZTEC_DATA_12; 48 | static Ref AZTEC_DATA_10; 49 | static Ref AZTEC_DATA_8; 50 | static Ref AZTEC_DATA_6; 51 | static Ref AZTEC_PARAM; 52 | static Ref QR_CODE_FIELD_256; 53 | static Ref DATA_MATRIX_FIELD_256; 54 | static Ref MAXICODE_FIELD_64; 55 | 56 | GenericGF(int primitive, int size, int b); 57 | 58 | Ref getZero(); 59 | Ref getOne(); 60 | int getSize(); 61 | int getGeneratorBase(); 62 | Ref buildMonomial(int degree, int coefficient); 63 | 64 | static int addOrSubtract(int a, int b); 65 | int exp(int a); 66 | int log(int a); 67 | int inverse(int a); 68 | int multiply(int a, int b); 69 | }; 70 | } 71 | 72 | #endif //GENERICGF_H 73 | 74 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/reedsolomon/GenericGFPoly.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * GenericGFPoly.h 4 | * zxing 5 | * 6 | * Created by Lukas Stabe on 13/02/2012. 7 | * Copyright 2012 ZXing authors All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #ifndef GENERICGFPOLY_H 23 | #define GENERICGFPOLY_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace zxing { 30 | 31 | class GenericGF; 32 | 33 | class GenericGFPoly : public Counted { 34 | private: 35 | Ref field_; 36 | ArrayRef coefficients_; 37 | 38 | public: 39 | GenericGFPoly(Ref field, ArrayRef coefficients); 40 | ArrayRef getCoefficients(); 41 | int getDegree(); 42 | bool isZero(); 43 | int getCoefficient(int degree); 44 | int evaluateAt(int a); 45 | Ref addOrSubtract(Ref other); 46 | Ref multiply(Ref other); 47 | Ref multiply(int scalar); 48 | Ref multiplyByMonomial(int degree, int coefficient); 49 | std::vector > divide(Ref other); 50 | 51 | 52 | }; 53 | 54 | } 55 | 56 | #endif //GENERICGFPOLY_H 57 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/reedsolomon/ReedSolomonDecoder.h: -------------------------------------------------------------------------------- 1 | #ifndef __REED_SOLOMON_DECODER_H__ 2 | #define __REED_SOLOMON_DECODER_H__ 3 | 4 | /* 5 | * ReedSolomonDecoder.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | namespace zxing { 31 | class GenericGFPoly; 32 | class GenericGF; 33 | 34 | class ReedSolomonDecoder { 35 | private: 36 | Ref field; 37 | public: 38 | ReedSolomonDecoder(Ref fld); 39 | ~ReedSolomonDecoder(); 40 | void decode(ArrayRef received, int twoS); 41 | std::vector > runEuclideanAlgorithm(Ref a, Ref b, int R); 42 | 43 | private: 44 | ArrayRef findErrorLocations(Ref errorLocator); 45 | ArrayRef findErrorMagnitudes(Ref errorEvaluator, ArrayRef errorLocations); 46 | }; 47 | } 48 | 49 | #endif // __REED_SOLOMON_DECODER_H__ 50 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/reedsolomon/ReedSolomonException.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ReedSolomonException.cpp 3 | * zxing 4 | * 5 | * Created by Christian Brunschen on 06/05/2008. 6 | * Copyright 2008 Google UK. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | #include 22 | 23 | namespace zxing { 24 | ReedSolomonException::ReedSolomonException(const char *msg) throw() : 25 | Exception(msg) { 26 | } 27 | ReedSolomonException::~ReedSolomonException() throw() { 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/common/reedsolomon/ReedSolomonException.h: -------------------------------------------------------------------------------- 1 | #ifndef __REED_SOLOMON_EXCEPTION_H__ 2 | #define __REED_SOLOMON_EXCEPTION_H__ 3 | 4 | /* 5 | * ReedSolomonException.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | 25 | namespace zxing { 26 | class ReedSolomonException : public Exception { 27 | public: 28 | ReedSolomonException(const char *msg) throw(); 29 | ~ReedSolomonException() throw(); 30 | }; 31 | } 32 | 33 | #endif // __REED_SOLOMON_EXCEPTION_H__ 34 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/datamatrix/DataMatrixReader.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * DataMatrixReader.cpp 4 | * zxing 5 | * 6 | * Created by Luiz Silva on 09/02/2010. 7 | * Copyright 2010 ZXing authors All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace zxing { 27 | namespace datamatrix { 28 | 29 | using namespace std; 30 | 31 | DataMatrixReader::DataMatrixReader() : 32 | decoder_() { 33 | } 34 | 35 | Ref DataMatrixReader::decode(Ref image, DecodeHints hints) { 36 | (void)hints; 37 | Detector detector(image->getBlackMatrix()); 38 | Ref detectorResult(detector.detect()); 39 | ArrayRef< Ref > points(detectorResult->getPoints()); 40 | 41 | 42 | Ref decoderResult(decoder_.decode(detectorResult->getBits())); 43 | 44 | Ref result( 45 | new Result(decoderResult->getText(), decoderResult->getRawBytes(), points, BarcodeFormat::DATA_MATRIX)); 46 | 47 | return result; 48 | } 49 | 50 | DataMatrixReader::~DataMatrixReader() { 51 | } 52 | 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/datamatrix/DataMatrixReader.h: -------------------------------------------------------------------------------- 1 | #ifndef __DATA_MATRIX_READER_H__ 2 | #define __DATA_MATRIX_READER_H__ 3 | 4 | /* 5 | * DataMatrixReader.h 6 | * zxing 7 | * 8 | * Created by Luiz Silva on 09/02/2010. 9 | * Copyright 2010 ZXing authors All rights reserved. 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | namespace zxing { 29 | namespace datamatrix { 30 | 31 | class DataMatrixReader : public Reader { 32 | private: 33 | Decoder decoder_; 34 | 35 | public: 36 | DataMatrixReader(); 37 | virtual Ref decode(Ref image, DecodeHints hints); 38 | virtual ~DataMatrixReader(); 39 | 40 | }; 41 | 42 | } 43 | } 44 | 45 | #endif // __DATA_MATRIX_READER_H__ 46 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/datamatrix/Version.h: -------------------------------------------------------------------------------- 1 | #ifndef __VERSION_H__ 2 | #define __VERSION_H__ 3 | 4 | /* 5 | * Version.h 6 | * zxing 7 | * 8 | * Created by Luiz Silva on 09/02/2010. 9 | * Copyright 2010 ZXing authors All rights reserved. 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | namespace zxing { 30 | namespace datamatrix { 31 | 32 | class ECB { 33 | private: 34 | int count_; 35 | int dataCodewords_; 36 | public: 37 | ECB(int count, int dataCodewords); 38 | int getCount(); 39 | int getDataCodewords(); 40 | }; 41 | 42 | class ECBlocks { 43 | private: 44 | int ecCodewords_; 45 | std::vector ecBlocks_; 46 | public: 47 | ECBlocks(int ecCodewords, ECB *ecBlocks); 48 | ECBlocks(int ecCodewords, ECB *ecBlocks1, ECB *ecBlocks2); 49 | int getECCodewords(); 50 | std::vector& getECBlocks(); 51 | ~ECBlocks(); 52 | }; 53 | 54 | class Version : public Counted { 55 | private: 56 | int versionNumber_; 57 | int symbolSizeRows_; 58 | int symbolSizeColumns_; 59 | int dataRegionSizeRows_; 60 | int dataRegionSizeColumns_; 61 | ECBlocks* ecBlocks_; 62 | int totalCodewords_; 63 | Version(int versionNumber, int symbolSizeRows, int symbolSizeColumns, int dataRegionSizeRows, 64 | int dataRegionSizeColumns, ECBlocks *ecBlocks); 65 | 66 | public: 67 | static std::vector > VERSIONS; 68 | 69 | ~Version(); 70 | int getVersionNumber(); 71 | int getSymbolSizeRows(); 72 | int getSymbolSizeColumns(); 73 | int getDataRegionSizeRows(); 74 | int getDataRegionSizeColumns(); 75 | int getTotalCodewords(); 76 | ECBlocks* getECBlocks(); 77 | static int buildVersions(); 78 | Ref getVersionForDimensions(int numRows, int numColumns); 79 | 80 | private: 81 | Version(const Version&); 82 | Version & operator=(const Version&); 83 | }; 84 | } 85 | } 86 | 87 | #endif // __VERSION_H__ 88 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/datamatrix/decoder/BitMatrixParser.h: -------------------------------------------------------------------------------- 1 | #ifndef __BIT_MATRIX_PARSER_DM_H__ 2 | #define __BIT_MATRIX_PARSER_DM_H__ 3 | 4 | /* 5 | * BitMatrixParser.h 6 | * zxing 7 | * 8 | * Created by Luiz Silva on 09/02/2010. 9 | * Copyright 2010 ZXing authors All rights reserved. 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | namespace zxing { 31 | namespace datamatrix { 32 | 33 | class BitMatrixParser : public Counted { 34 | private: 35 | Ref bitMatrix_; 36 | Ref parsedVersion_; 37 | Ref readBitMatrix_; 38 | 39 | int copyBit(size_t x, size_t y, int versionBits); 40 | 41 | public: 42 | BitMatrixParser(Ref bitMatrix); 43 | Ref readVersion(Ref bitMatrix); 44 | ArrayRef readCodewords(); 45 | bool readModule(int row, int column, int numRows, int numColumns); 46 | 47 | private: 48 | int readUtah(int row, int column, int numRows, int numColumns); 49 | int readCorner1(int numRows, int numColumns); 50 | int readCorner2(int numRows, int numColumns); 51 | int readCorner3(int numRows, int numColumns); 52 | int readCorner4(int numRows, int numColumns); 53 | Ref extractDataRegion(Ref bitMatrix); 54 | }; 55 | 56 | } 57 | } 58 | 59 | #endif // __BIT_MATRIX_PARSER_DM_H__ 60 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/datamatrix/decoder/DataBlock.h: -------------------------------------------------------------------------------- 1 | #ifndef __DATA_BLOCK_DM_H__ 2 | #define __DATA_BLOCK_DM_H__ 3 | 4 | /* 5 | * DataBlock.h 6 | * zxing 7 | * 8 | * Created by Luiz Silva on 09/02/2010. 9 | * Copyright 2010 ZXing authors All rights reserved. 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | namespace zxing { 30 | namespace datamatrix { 31 | 32 | class DataBlock : public Counted { 33 | private: 34 | int numDataCodewords_; 35 | ArrayRef codewords_; 36 | 37 | DataBlock(int numDataCodewords, ArrayRef codewords); 38 | 39 | public: 40 | static std::vector > getDataBlocks(ArrayRef rawCodewords, Version *version); 41 | 42 | int getNumDataCodewords(); 43 | ArrayRef getCodewords(); 44 | }; 45 | 46 | } 47 | } 48 | 49 | #endif // __DATA_BLOCK_DM_H__ 50 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/datamatrix/decoder/Decoder.h: -------------------------------------------------------------------------------- 1 | #ifndef __DECODER_DM_H__ 2 | #define __DECODER_DM_H__ 3 | 4 | /* 5 | * Decoder.h 6 | * zxing 7 | * 8 | * Created by Luiz Silva on 09/02/2010. 9 | * Copyright 2010 ZXing authors All rights reserved. 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | 31 | namespace zxing { 32 | namespace datamatrix { 33 | 34 | class Decoder { 35 | private: 36 | ReedSolomonDecoder rsDecoder_; 37 | 38 | void correctErrors(ArrayRef bytes, int numDataCodewords); 39 | 40 | public: 41 | Decoder(); 42 | 43 | Ref decode(Ref bits); 44 | }; 45 | 46 | } 47 | } 48 | 49 | #endif // __DECODER_DM_H__ 50 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/datamatrix/detector/CornerPoint.h: -------------------------------------------------------------------------------- 1 | #ifndef __CORNER_FINDER_H__ 2 | #define __CORNER_FINDER_H__ 3 | 4 | /* 5 | * CornerPoint.h 6 | * zxing 7 | * 8 | * Created by Luiz Silva on 09/02/2010. 9 | * Copyright 2010 ZXing authors All rights reserved. 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | #include 25 | #include 26 | 27 | namespace zxing { 28 | namespace datamatrix { 29 | 30 | class CornerPoint : public ResultPoint { 31 | private: 32 | int counter_; 33 | 34 | public: 35 | CornerPoint(float posX, float posY); 36 | int getCount() const; 37 | void incrementCount(); 38 | bool equals(Ref other) const; 39 | }; 40 | } 41 | } 42 | 43 | #endif // __CORNER_FINDER_H__ 44 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/datamatrix/detector/DataMatrixCornerPoint.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * CornerPoint.cpp 3 | * zxing 4 | * 5 | * Created by Luiz Silva on 09/02/2010. 6 | * Copyright 2010 ZXing authors All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | #include 22 | 23 | 24 | namespace zxing { 25 | namespace datamatrix { 26 | 27 | using namespace std; 28 | 29 | CornerPoint::CornerPoint(float posX, float posY) : 30 | ResultPoint(posX,posY), counter_(0) { 31 | } 32 | 33 | int CornerPoint::getCount() const { 34 | return counter_; 35 | } 36 | 37 | void CornerPoint::incrementCount() { 38 | counter_++; 39 | } 40 | 41 | bool CornerPoint::equals(Ref other) const { 42 | return posX_ == other->getX() && posY_ == other->getY(); 43 | } 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/datamatrix/detector/DataMatrixDetectorException.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DetectorException.cpp 3 | * 4 | * Created on: Aug 26, 2011 5 | * Author: luiz 6 | */ 7 | 8 | #include "DetectorException.h" 9 | 10 | namespace zxing { 11 | namespace datamatrix { 12 | 13 | DetectorException::DetectorException(const char *msg) : 14 | Exception(msg) { 15 | 16 | } 17 | 18 | DetectorException::~DetectorException() throw () { 19 | // TODO Auto-generated destructor stub 20 | } 21 | 22 | } 23 | } /* namespace zxing */ 24 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/datamatrix/detector/DetectorException.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DetectorException.h 3 | * 4 | * Created on: Aug 26, 2011 5 | * Author: luiz 6 | */ 7 | 8 | #ifndef DETECTOREXCEPTION_H_ 9 | #define DETECTOREXCEPTION_H_ 10 | 11 | #include 12 | 13 | namespace zxing { 14 | namespace datamatrix { 15 | 16 | class DetectorException : public Exception { 17 | public: 18 | DetectorException(const char *msg); 19 | virtual ~DetectorException() throw(); 20 | }; 21 | } /* namespace nexxera */ 22 | } /* namespace zxing */ 23 | #endif /* DETECTOREXCEPTION_H_ */ 24 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/multi/ByQuadrantReader.h: -------------------------------------------------------------------------------- 1 | #ifndef __BY_QUADRANT_READER_H__ 2 | #define __BY_QUADRANT_READER_H__ 3 | 4 | /* 5 | * Copyright 2011 ZXing authors All rights reserved. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | namespace zxing { 26 | namespace multi { 27 | 28 | class ByQuadrantReader : public Reader { 29 | private: 30 | Reader& delegate_; 31 | 32 | public: 33 | ByQuadrantReader(Reader& delegate); 34 | virtual ~ByQuadrantReader(); 35 | virtual Ref decode(Ref image); 36 | virtual Ref decode(Ref image, DecodeHints hints); 37 | }; 38 | 39 | } 40 | } 41 | 42 | #endif // __BY_QUADRANT_READER_H__ 43 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/multi/GenericMultipleBarcodeReader.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __GENERIC_MULTIPLE_BARCODE_READER_H__ 3 | #define __GENERIC_MULTIPLE_BARCODE_READER_H__ 4 | 5 | /* 6 | * Copyright 2011 ZXing authors All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | namespace zxing { 25 | namespace multi { 26 | 27 | class GenericMultipleBarcodeReader : public MultipleBarcodeReader { 28 | private: 29 | static Ref translateResultPoints(Ref result, 30 | int xOffset, 31 | int yOffset); 32 | void doDecodeMultiple(Ref image, 33 | DecodeHints hints, 34 | std::vector >& results, 35 | int xOffset, 36 | int yOffset, 37 | int currentDepth); 38 | Reader& delegate_; 39 | static const int MIN_DIMENSION_TO_RECUR = 100; 40 | static const int MAX_DEPTH = 4; 41 | 42 | public: 43 | GenericMultipleBarcodeReader(Reader& delegate); 44 | virtual ~GenericMultipleBarcodeReader(); 45 | virtual std::vector > decodeMultiple(Ref image, DecodeHints hints); 46 | }; 47 | 48 | } 49 | } 50 | 51 | #endif // __GENERIC_MULTIPLE_BARCODE_READER_H__ 52 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/multi/MultipleBarcodeReader.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 ZXing authors All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | namespace zxing { 20 | namespace multi { 21 | 22 | MultipleBarcodeReader::~MultipleBarcodeReader() { } 23 | 24 | std::vector > MultipleBarcodeReader::decodeMultiple(Ref image) { 25 | return decodeMultiple(image, DecodeHints::DEFAULT_HINT); 26 | } 27 | 28 | } // End zxing::multi namespace 29 | } // End zxing namespace 30 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/multi/MultipleBarcodeReader.h: -------------------------------------------------------------------------------- 1 | #ifndef __MULTIPLE_BARCODE_READER_H__ 2 | #define __MULTIPLE_BARCODE_READER_H__ 3 | 4 | /* 5 | * Copyright 2011 ZXing authors All rights reserved. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | namespace zxing { 27 | namespace multi { 28 | 29 | class MultipleBarcodeReader : public Counted { 30 | protected: 31 | MultipleBarcodeReader() {} 32 | public: 33 | virtual std::vector > decodeMultiple(Ref image); 34 | virtual std::vector > decodeMultiple(Ref image, DecodeHints hints) = 0; 35 | virtual ~MultipleBarcodeReader(); 36 | }; 37 | 38 | } 39 | } 40 | 41 | #endif // __MULTIPLE_BARCODE_READER_H__ 42 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/multi/qrcode/QRCodeMultiReader.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * Copyright 2011 ZXing authors All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | namespace zxing { 24 | namespace multi { 25 | QRCodeMultiReader::QRCodeMultiReader(){} 26 | 27 | QRCodeMultiReader::~QRCodeMultiReader(){} 28 | 29 | std::vector > QRCodeMultiReader::decodeMultiple(Ref image, 30 | DecodeHints hints) 31 | { 32 | std::vector > results; 33 | MultiDetector detector(image->getBlackMatrix()); 34 | 35 | std::vector > detectorResult = detector.detectMulti(hints); 36 | for (unsigned int i = 0; i < detectorResult.size(); i++) { 37 | try { 38 | Ref decoderResult = getDecoder().decode(detectorResult[i]->getBits()); 39 | ArrayRef< Ref > points = detectorResult[i]->getPoints(); 40 | Ref result = Ref(new Result(decoderResult->getText(), 41 | decoderResult->getRawBytes(), 42 | points, BarcodeFormat::QR_CODE)); 43 | // result->putMetadata(ResultMetadataType.BYTE_SEGMENTS, decoderResult->getByteSegments()); 44 | // result->putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, decoderResult->getECLevel().toString()); 45 | results.push_back(result); 46 | } catch (ReaderException const& re) { 47 | (void)re; 48 | // ignore and continue 49 | } 50 | } 51 | if (results.empty()){ 52 | throw ReaderException("No code detected"); 53 | } 54 | return results; 55 | } 56 | 57 | } // End zxing::multi namespace 58 | } // End zxing namespace 59 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/multi/qrcode/QRCodeMultiReader.h: -------------------------------------------------------------------------------- 1 | #ifndef __QRCODE_MULTI_READER_H__ 2 | #define __QRCODE_MULTI_READER_H__ 3 | 4 | /* 5 | * Copyright 2011 ZXing authors All rights reserved. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | namespace zxing { 24 | namespace multi { 25 | 26 | class QRCodeMultiReader: public zxing::qrcode::QRCodeReader, public MultipleBarcodeReader { 27 | public: 28 | QRCodeMultiReader(); 29 | virtual ~QRCodeMultiReader(); 30 | virtual std::vector > decodeMultiple(Ref image, DecodeHints hints); 31 | }; 32 | 33 | } 34 | } 35 | 36 | #endif // __QRCODE_MULTI_READER_H__ 37 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/multi/qrcode/detector/MultiDetector.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | namespace zxing { 22 | namespace multi { 23 | using namespace zxing::qrcode; 24 | 25 | MultiDetector::MultiDetector(Ref image) : Detector(image) {} 26 | 27 | MultiDetector::~MultiDetector(){} 28 | 29 | std::vector > MultiDetector::detectMulti(DecodeHints hints){ 30 | Ref image = getImage(); 31 | MultiFinderPatternFinder finder = MultiFinderPatternFinder(image, hints.getResultPointCallback()); 32 | std::vector > info = finder.findMulti(hints); 33 | std::vector > result; 34 | for(unsigned int i = 0; i < info.size(); i++){ 35 | try{ 36 | result.push_back(processFinderPatternInfo(info[i])); 37 | } catch (ReaderException const& e){ 38 | (void)e; 39 | // ignore 40 | } 41 | } 42 | 43 | return result; 44 | } 45 | 46 | } // End zxing::multi namespace 47 | } // End zxing namespace 48 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/multi/qrcode/detector/MultiDetector.h: -------------------------------------------------------------------------------- 1 | #ifndef __MULTI_DETECTOR_H__ 2 | #define __MULTI_DETECTOR_H__ 3 | 4 | /* 5 | * Copyright 2011 ZXing authors 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | namespace zxing { 25 | namespace multi { 26 | 27 | class MultiDetector : public zxing::qrcode::Detector { 28 | public: 29 | MultiDetector(Ref image); 30 | virtual ~MultiDetector(); 31 | virtual std::vector > detectMulti(DecodeHints hints); 32 | }; 33 | 34 | } 35 | } 36 | 37 | #endif // __MULTI_DETECTOR_H__ 38 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/multi/qrcode/detector/MultiFinderPatternFinder.h: -------------------------------------------------------------------------------- 1 | #ifndef __MULTI_FINDER_PATTERN_FINDER_H__ 2 | #define __MULTI_FINDER_PATTERN_FINDER_H__ 3 | 4 | /* 5 | * Copyright 2011 ZXing authors 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | namespace zxing { 25 | namespace multi { 26 | 27 | class MultiFinderPatternFinder : zxing::qrcode::FinderPatternFinder { 28 | private: 29 | std::vector > > selectBestPatterns(); 30 | 31 | static const float MAX_MODULE_COUNT_PER_EDGE; 32 | static const float MIN_MODULE_COUNT_PER_EDGE; 33 | static const float DIFF_MODSIZE_CUTOFF_PERCENT; 34 | static const float DIFF_MODSIZE_CUTOFF; 35 | 36 | public: 37 | MultiFinderPatternFinder(Ref image, Ref resultPointCallback); 38 | virtual ~MultiFinderPatternFinder(); 39 | virtual std::vector > findMulti(DecodeHints const& hints); 40 | 41 | 42 | }; 43 | 44 | } 45 | } 46 | 47 | #endif // __MULTI_FINDER_PATTERN_FINDER_H__ 48 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/oned/CodaBarReader.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __CODA_BAR_READER_H__ 3 | #define __CODA_BAR_READER_H__ 4 | /* 5 | * Copyright 2010 ZXing authors All rights reserved. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | namespace zxing { 25 | namespace oned { 26 | 27 | class CodaBarReader : public OneDReader { 28 | private: 29 | static const int MAX_ACCEPTABLE; 30 | static const int PADDING; 31 | 32 | // Keep some instance variables to avoid reallocations 33 | std::string decodeRowResult; 34 | std::vector counters; 35 | int counterLength; 36 | 37 | public: 38 | CodaBarReader(); 39 | 40 | Ref decodeRow(int rowNumber, Ref row); 41 | 42 | void validatePattern(int start); 43 | 44 | private: 45 | void setCounters(Ref row); 46 | void counterAppend(int e); 47 | int findStartPattern(); 48 | 49 | static bool arrayContains(char const array[], char key); 50 | 51 | int toNarrowWidePattern(int position); 52 | }; 53 | 54 | } 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/oned/Code128Reader.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __CODE_128_READER_H__ 3 | #define __CODE_128_READER_H__ 4 | /* 5 | * Copyright 2010 ZXing authors All rights reserved. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | namespace zxing { 25 | namespace oned { 26 | 27 | class Code128Reader : public OneDReader { 28 | private: 29 | static const int MAX_AVG_VARIANCE; 30 | static const int MAX_INDIVIDUAL_VARIANCE; 31 | 32 | static std::vector findStartPattern(Ref row); 33 | static int decodeCode(Ref row, 34 | std::vector& counters, 35 | int rowOffset); 36 | 37 | public: 38 | Ref decodeRow(int rowNumber, Ref row); 39 | Code128Reader(); 40 | ~Code128Reader(); 41 | 42 | BarcodeFormat getBarcodeFormat(); 43 | }; 44 | 45 | } 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/oned/Code39Reader.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __CODE_39_READER_H__ 3 | #define __CODE_39_READER_H__ 4 | /* 5 | * Code39Reader.h 6 | * ZXing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | namespace zxing { 28 | namespace oned { 29 | 30 | /** 31 | *

Decodes Code 39 barcodes. This does not support "Full ASCII Code 39" yet.

32 | * Ported form Java (author Sean Owen) 33 | * @author Lukasz Warchol 34 | */ 35 | class Code39Reader : public OneDReader { 36 | private: 37 | bool usingCheckDigit; 38 | bool extendedMode; 39 | std::string decodeRowResult; 40 | std::vector counters; 41 | 42 | void init(bool usingCheckDigit = false, bool extendedMode = false); 43 | 44 | static std::vector findAsteriskPattern(Ref row, 45 | std::vector& counters); 46 | static int toNarrowWidePattern(std::vector& counters); 47 | static char patternToChar(int pattern); 48 | static Ref decodeExtended(std::string encoded); 49 | 50 | void append(char* s, char c); 51 | 52 | public: 53 | Code39Reader(); 54 | Code39Reader(bool usingCheckDigit_); 55 | Code39Reader(bool usingCheckDigit_, bool extendedMode_); 56 | 57 | Ref decodeRow(int rowNumber, Ref row); 58 | }; 59 | 60 | } 61 | } 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/oned/Code93Reader.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __CODE_93_READER_H__ 3 | #define __CODE_93_READER_H__ 4 | /* 5 | * Code93Reader.h 6 | * ZXing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | namespace zxing { 28 | namespace oned { 29 | 30 | /** 31 | *

Decodes Code 93 barcodes. This does not support "Full ASCII Code 93" yet.

32 | * Ported form Java (author Sean Owen) 33 | * @author Lukasz Warchol 34 | */ 35 | class Code93Reader : public OneDReader { 36 | public: 37 | Code93Reader(); 38 | Ref decodeRow(int rowNumber, Ref row); 39 | 40 | private: 41 | std::string decodeRowResult; 42 | std::vector counters; 43 | 44 | Range findAsteriskPattern(Ref row); 45 | 46 | static int toPattern(std::vector& counters); 47 | static char patternToChar(int pattern); 48 | static Ref decodeExtended(std::string const& encoded); 49 | static void checkChecksums(std::string const& result); 50 | static void checkOneChecksum(std::string const& result, 51 | int checkPosition, 52 | int weightMax); 53 | }; 54 | 55 | } 56 | } 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/oned/EAN13Reader.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __EAN_13_READER_H__ 3 | #define __EAN_13_READER_H__ 4 | 5 | /* 6 | * EAN13Reader.h 7 | * ZXing 8 | * 9 | * Copyright 2010 ZXing authors All rights reserved. 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | #include 25 | #include 26 | 27 | namespace zxing { 28 | namespace oned { 29 | 30 | class EAN13Reader : public UPCEANReader { 31 | private: 32 | std::vector decodeMiddleCounters; 33 | static void determineFirstDigit(std::string& resultString, 34 | int lgPatternFound); 35 | 36 | public: 37 | EAN13Reader(); 38 | 39 | int decodeMiddle(Ref row, 40 | Range const& startRange, 41 | std::string& resultString); 42 | 43 | BarcodeFormat getBarcodeFormat(); 44 | }; 45 | 46 | } 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/oned/EAN8Reader.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * Copyright 2010 ZXing authors All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include "EAN8Reader.h" 19 | #include 20 | 21 | using std::vector; 22 | using zxing::oned::EAN8Reader; 23 | 24 | // VC++ 25 | using zxing::Ref; 26 | using zxing::BitArray; 27 | 28 | EAN8Reader::EAN8Reader() : decodeMiddleCounters(4, 0) {} 29 | 30 | int EAN8Reader::decodeMiddle(Ref row, 31 | Range const& startRange, 32 | std::string& result){ 33 | vector& counters (decodeMiddleCounters); 34 | counters[0] = 0; 35 | counters[1] = 0; 36 | counters[2] = 0; 37 | counters[3] = 0; 38 | 39 | int end = row->getSize(); 40 | int rowOffset = startRange[1]; 41 | 42 | for (int x = 0; x < 4 && rowOffset < end; x++) { 43 | int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); 44 | result.append(1, (char) ('0' + bestMatch)); 45 | for (int i = 0, end = counters.size(); i < end; i++) { 46 | rowOffset += counters[i]; 47 | } 48 | } 49 | 50 | Range middleRange = 51 | findGuardPattern(row, rowOffset, true, MIDDLE_PATTERN); 52 | rowOffset = middleRange[1]; 53 | for (int x = 0; x < 4 && rowOffset < end; x++) { 54 | int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); 55 | result.append(1, (char) ('0' + bestMatch)); 56 | for (int i = 0, end = counters.size(); i < end; i++) { 57 | rowOffset += counters[i]; 58 | } 59 | } 60 | return rowOffset; 61 | } 62 | 63 | zxing::BarcodeFormat EAN8Reader::getBarcodeFormat(){ 64 | return BarcodeFormat::EAN_8; 65 | } 66 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/oned/EAN8Reader.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __EAN_8_READER_H__ 3 | #define __EAN_8_READER_H__ 4 | 5 | /* 6 | * EAN8Reader.h 7 | * ZXing 8 | * 9 | * Copyright 2010 ZXing authors All rights reserved. 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | #include 25 | #include 26 | 27 | namespace zxing { 28 | namespace oned { 29 | 30 | class EAN8Reader : public UPCEANReader { 31 | private: 32 | std::vector decodeMiddleCounters; 33 | 34 | public: 35 | EAN8Reader(); 36 | 37 | int decodeMiddle(Ref row, 38 | Range const& startRange, 39 | std::string& resultString); 40 | 41 | BarcodeFormat getBarcodeFormat(); 42 | }; 43 | 44 | } 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/oned/ITFReader.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __ITF_READER_H__ 3 | #define __ITF_READER_H__ 4 | 5 | /* 6 | * Copyright 2010 ZXing authors All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace zxing { 26 | namespace oned { 27 | 28 | class ITFReader : public OneDReader { 29 | private: 30 | enum {MAX_AVG_VARIANCE = (unsigned int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 420/1000)}; 31 | enum {MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 780/1000)}; 32 | // Stores the actual narrow line width of the image being decoded. 33 | int narrowLineWidth; 34 | 35 | Range decodeStart(Ref row); 36 | Range decodeEnd(Ref row); 37 | static void decodeMiddle(Ref row, int payloadStart, int payloadEnd, std::string& resultString); 38 | void validateQuietZone(Ref row, int startPattern); 39 | static int skipWhiteSpace(Ref row); 40 | 41 | static Range findGuardPattern(Ref row, int rowOffset, std::vector const& pattern); 42 | static int decodeDigit(std::vector& counters); 43 | 44 | void append(char* s, char c); 45 | public: 46 | Ref decodeRow(int rowNumber, Ref row); 47 | ITFReader(); 48 | ~ITFReader(); 49 | }; 50 | 51 | } 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/oned/MultiFormatOneDReader.h: -------------------------------------------------------------------------------- 1 | #ifndef __MULTI_FORMAT_ONED_READER_H__ 2 | #define __MULTI_FORMAT_ONED_READER_H__ 3 | /* 4 | * MultiFormatOneDReader.h 5 | * ZXing 6 | * 7 | * Copyright 2010 ZXing authors All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include 23 | 24 | namespace zxing { 25 | namespace oned { 26 | class MultiFormatOneDReader : public OneDReader { 27 | 28 | private: 29 | std::vector > readers; 30 | public: 31 | MultiFormatOneDReader(DecodeHints hints); 32 | 33 | Ref decodeRow(int rowNumber, Ref row); 34 | }; 35 | } 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/oned/MultiFormatUPCEANReader.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __MULTI_FORMAT_UPC_EAN_READER_H__ 3 | #define __MULTI_FORMAT_UPC_EAN_READER_H__ 4 | /* 5 | * MultiFormatUPCEANReader.h 6 | * ZXing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | 25 | namespace zxing { 26 | namespace oned { 27 | 28 | class UPCEANReader; 29 | 30 | class MultiFormatUPCEANReader : public OneDReader { 31 | private: 32 | std::vector< Ref > readers; 33 | public: 34 | MultiFormatUPCEANReader(DecodeHints hints); 35 | Ref decodeRow(int rowNumber, Ref row); 36 | }; 37 | 38 | } 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/oned/OneDResultPoint.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * OneDResultPoint.cpp 3 | * ZXing 4 | * 5 | * Copyright 2010 ZXing authors All rights reserved. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "OneDResultPoint.h" 21 | 22 | namespace zxing { 23 | namespace oned { 24 | 25 | OneDResultPoint::OneDResultPoint(float posX, float posY) : ResultPoint(posX,posY) { 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/oned/OneDResultPoint.h: -------------------------------------------------------------------------------- 1 | #ifndef __ONED_RESULT_POINT_H__ 2 | #define __ONED_RESULT_POINT_H__ 3 | /* 4 | * OneDResultPoint.h 5 | * ZXing 6 | * 7 | * Copyright 2010 ZXing authors All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | #include 22 | #include 23 | 24 | namespace zxing { 25 | namespace oned { 26 | 27 | class OneDResultPoint : public ResultPoint { 28 | 29 | public: 30 | OneDResultPoint(float posX, float posY); 31 | }; 32 | } 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/oned/UPCAReader.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __UPCA_READER_H__ 3 | #define __UPCA_READER_H__ 4 | /* 5 | * UPCAReader.h 6 | * ZXing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | namespace zxing { 27 | namespace oned { 28 | 29 | class UPCAReader : public UPCEANReader { 30 | 31 | private: 32 | EAN13Reader ean13Reader; 33 | static Ref maybeReturnResult(Ref result); 34 | 35 | public: 36 | UPCAReader(); 37 | 38 | int decodeMiddle(Ref row, Range const& startRange, std::string& resultString); 39 | 40 | Ref decodeRow(int rowNumber, Ref row); 41 | Ref decodeRow(int rowNumber, Ref row, Range const& startGuardRange); 42 | Ref decode(Ref image, DecodeHints hints); 43 | 44 | BarcodeFormat getBarcodeFormat(); 45 | }; 46 | 47 | } 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/oned/UPCEReader.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __UPC_E_READER_H__ 3 | #define __UPC_E_READER_H__ 4 | 5 | /* 6 | * Copyright 2010 ZXing authors All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | namespace zxing { 25 | namespace oned { 26 | 27 | class UPCEReader : public UPCEANReader { 28 | private: 29 | std::vector decodeMiddleCounters; 30 | static bool determineNumSysAndCheckDigit(std::string& resultString, int lgPatternFound); 31 | 32 | protected: 33 | Range decodeEnd(Ref row, int endStart); 34 | bool checkChecksum(Ref const& s); 35 | public: 36 | UPCEReader(); 37 | 38 | int decodeMiddle(Ref row, Range const& startRange, std::string& resultString); 39 | static Ref convertUPCEtoUPCA(Ref const& upce); 40 | 41 | BarcodeFormat getBarcodeFormat(); 42 | }; 43 | 44 | } 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/pdf417/PDF417Reader.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __PDF417_READER_H__ 3 | #define __PDF417_READER_H__ 4 | 5 | /* 6 | * PDF417Reader.h 7 | * zxing 8 | * 9 | * Copyright 2010,2012 ZXing authors All rights reserved. 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | namespace zxing { 29 | namespace pdf417 { 30 | 31 | 32 | class PDF417Reader : public Reader { 33 | private: 34 | decoder::Decoder decoder; 35 | 36 | static Ref extractPureBits(Ref image); 37 | static int moduleSize(ArrayRef leftTopBlack, Ref image); 38 | static int findPatternStart(int x, int y, Ref image); 39 | static int findPatternEnd(int x, int y, Ref image); 40 | 41 | public: 42 | Ref decode(Ref image, DecodeHints hints); 43 | void reset(); 44 | }; 45 | 46 | } 47 | } 48 | 49 | #endif // __PDF417_READER_H__ 50 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/pdf417/decoder/Decoder.h: -------------------------------------------------------------------------------- 1 | #ifndef __DECOCER_PDF_H__ 2 | #define __DECOCER_PDF_H__ 3 | 4 | /* 5 | * Decoder.h 6 | * zxing 7 | * 8 | * Created by Hartmut Neubauer, 2012-05-25 9 | * Copyright 2010,2012 ZXing authors All rights reserved. 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | 32 | namespace zxing { 33 | namespace pdf417 { 34 | namespace decoder { 35 | 36 | /** 37 | *

The main class which implements PDF417 Code decoding -- as 38 | * opposed to locating and extracting the PDF417 Code from an image.

39 | * 40 | *

2012-06-27 HFN Reed-Solomon error correction activated, see class PDF417RSDecoder.

41 | *

2012-09-19 HFN Reed-Solomon error correction via ErrorCorrection/ModulusGF/ModulusPoly.

42 | */ 43 | 44 | class Decoder { 45 | private: 46 | static const int MAX_ERRORS; 47 | static const int MAX_EC_CODEWORDS; 48 | 49 | void correctErrors(ArrayRef codewords, 50 | ArrayRef erasures, int numECCodewords); 51 | static void verifyCodewordCount(ArrayRef codewords, int numECCodewords); 52 | 53 | public: 54 | 55 | Ref decode(Ref bits, DecodeHints const &hints); 56 | }; 57 | 58 | } 59 | } 60 | } 61 | 62 | #endif // __DECOCER_PDF_H__ 63 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/pdf417/decoder/ec/ErrorCorrection.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | 3 | #ifndef __ERROR_CORRECTION_PDF_H__ 4 | #define __ERROR_CORRECTION_PDF_H__ 5 | /* 6 | * Copyright 2012 ZXing authors 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | * 2012-09-17 HFN translation from Java into C++ 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | namespace zxing { 32 | namespace pdf417 { 33 | namespace decoder { 34 | namespace ec { 35 | 36 | 37 | /** 38 | *

PDF417 error correction implementation.

39 | * 40 | *

This example 41 | * is quite useful in understanding the algorithm.

42 | * 43 | * @author Sean Owen 44 | * @see com.google.zxing.common.reedsolomon.ReedSolomonDecoder 45 | */ 46 | class ErrorCorrection: public Counted { 47 | 48 | private: 49 | ModulusGF &field_; 50 | 51 | public: 52 | ErrorCorrection(); 53 | void decode(ArrayRef received, 54 | int numECCodewords, 55 | ArrayRef erasures); 56 | 57 | private: 58 | std::vector > runEuclideanAlgorithm(Ref a, Ref b, int R); 59 | 60 | ArrayRef findErrorLocations(Ref errorLocator); 61 | ArrayRef findErrorMagnitudes(Ref errorEvaluator, 62 | Ref errorLocator, 63 | ArrayRef errorLocations); 64 | }; 65 | 66 | } 67 | } 68 | } 69 | } 70 | 71 | #endif /* __ERROR_CORRECTION_PDF_H__ */ 72 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/pdf417/decoder/ec/ModulusGF.h: -------------------------------------------------------------------------------- 1 | #ifndef __MODULUS_GF_PDF_H__ 2 | #define __MODULUS_GF_PDF_H__ 3 | /* 4 | * Copyright 2012 ZXing authors 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * 2012-09-17 HFN translation from Java into C++ 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | namespace zxing { 27 | namespace pdf417 { 28 | namespace decoder { 29 | namespace ec { 30 | 31 | class ModulusPoly; 32 | 33 | /** 34 | *

A field based on powers of a generator integer, modulo some modulus.

35 | * 36 | * @author Sean Owen 37 | * @see com.google.zxing.common.reedsolomon.GenericGF 38 | */ 39 | class ModulusGF { 40 | 41 | public: 42 | static ModulusGF PDF417_GF; 43 | 44 | private: 45 | ArrayRef expTable_; 46 | ArrayRef logTable_; 47 | Ref zero_; 48 | Ref one_; 49 | int modulus_; 50 | 51 | public: 52 | ModulusGF(int modulus, int generator); 53 | Ref getZero(); 54 | Ref getOne(); 55 | Ref buildMonomial(int degree, int coefficient); 56 | 57 | int add(int a, int b); 58 | int subtract(int a, int b); 59 | int exp(int a); 60 | int log(int a); 61 | int inverse(int a); 62 | int multiply(int a, int b); 63 | int getSize(); 64 | 65 | }; 66 | 67 | } 68 | } 69 | } 70 | } 71 | 72 | #endif /* __MODULUS_GF_PDF_H__ */ 73 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/pdf417/decoder/ec/ModulusPoly.h: -------------------------------------------------------------------------------- 1 | #ifndef __MODULUS_GFPOLY_PDF_H__ 2 | #define __MODULUS_GFPOLY_PDF_H__ 3 | 4 | /* 5 | * Copyright 2012 ZXing authors 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * 2012-09-17 HFN translation from Java into C++ 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace zxing { 28 | namespace pdf417 { 29 | namespace decoder { 30 | namespace ec { 31 | 32 | class ModulusGF; 33 | 34 | /** 35 | * @author Sean Owen 36 | * @see com.google.zxing.common.reedsolomon.GenericGFPoly 37 | */ 38 | class ModulusPoly: public Counted { 39 | 40 | private: 41 | ModulusGF &field_; 42 | ArrayRef coefficients_; 43 | public: 44 | ModulusPoly(ModulusGF& field, ArrayRef coefficients); 45 | ~ModulusPoly(); 46 | ArrayRef getCoefficients(); 47 | int getDegree(); 48 | bool isZero(); 49 | int getCoefficient(int degree); 50 | int evaluateAt(int a); 51 | Ref add(Ref other); 52 | Ref subtract(Ref other); 53 | Ref multiply(Ref other); 54 | Ref negative(); 55 | Ref multiply(int scalar); 56 | Ref multiplyByMonomial(int degree, int coefficient); 57 | std::vector > divide(Ref other); 58 | #if 0 59 | public String toString(); 60 | #endif 61 | }; 62 | 63 | } 64 | } 65 | } 66 | } 67 | 68 | #endif /* __MODULUS_GFPOLY_PDF_H__ */ 69 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/qrcode/ErrorCorrectionLevel.h: -------------------------------------------------------------------------------- 1 | #ifndef __ERROR_CORRECTION_LEVEL_H__ 2 | #define __ERROR_CORRECTION_LEVEL_H__ 3 | 4 | /* 5 | * ErrorCorrectionLevel.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | namespace zxing { 27 | namespace qrcode { 28 | 29 | class ErrorCorrectionLevel : public Counted { 30 | private: 31 | int ordinal_; 32 | int bits_; 33 | std::string name_; 34 | ErrorCorrectionLevel(int inOrdinal, int bits, char const* name); 35 | static ErrorCorrectionLevel *FOR_BITS[]; 36 | static int N_LEVELS; 37 | public: 38 | static ErrorCorrectionLevel L; 39 | static ErrorCorrectionLevel M; 40 | static ErrorCorrectionLevel Q; 41 | static ErrorCorrectionLevel H; 42 | 43 | ErrorCorrectionLevel(const ErrorCorrectionLevel& other); 44 | 45 | int ordinal() const; 46 | int bits() const; 47 | std::string const& name() const; 48 | operator std::string const& () const; 49 | 50 | static ErrorCorrectionLevel& forBits(int bits); 51 | }; 52 | } 53 | } 54 | 55 | #endif // __ERROR_CORRECTION_LEVEL_H__ 56 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/qrcode/FormatInformation.h: -------------------------------------------------------------------------------- 1 | #ifndef __FORMAT_INFORMATION_H__ 2 | #define __FORMAT_INFORMATION_H__ 3 | 4 | /* 5 | * FormatInformation.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | namespace zxing { 28 | namespace qrcode { 29 | 30 | class FormatInformation : public Counted { 31 | private: 32 | static int FORMAT_INFO_MASK_QR; 33 | static int FORMAT_INFO_DECODE_LOOKUP[][2]; 34 | static int N_FORMAT_INFO_DECODE_LOOKUPS; 35 | static int BITS_SET_IN_HALF_BYTE[]; 36 | 37 | ErrorCorrectionLevel &errorCorrectionLevel_; 38 | char dataMask_; 39 | 40 | FormatInformation(int formatInfo); 41 | 42 | public: 43 | static int numBitsDiffering(int a, int b); 44 | static Ref decodeFormatInformation(int maskedFormatInfo1, int maskedFormatInfo2); 45 | static Ref doDecodeFormatInformation(int maskedFormatInfo1, int maskedFormatInfo2); 46 | ErrorCorrectionLevel &getErrorCorrectionLevel(); 47 | char getDataMask(); 48 | friend bool operator==(const FormatInformation &a, const FormatInformation &b); 49 | friend std::ostream& operator<<(std::ostream& out, const FormatInformation& fi); 50 | }; 51 | } 52 | } 53 | 54 | #endif // __FORMAT_INFORMATION_H__ 55 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/qrcode/QRCodeReader.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * QRCodeReader.cpp 4 | * zxing 5 | * 6 | * Created by Christian Brunschen on 20/05/2008. 7 | * Copyright 2008 ZXing authors All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | namespace zxing { 28 | namespace qrcode { 29 | 30 | using namespace std; 31 | 32 | QRCodeReader::QRCodeReader() :decoder_() { 33 | } 34 | //TODO : see if any of the other files in the qrcode tree need tryHarder 35 | Ref QRCodeReader::decode(Ref image, DecodeHints hints) { 36 | Detector detector(image->getBlackMatrix()); 37 | Ref detectorResult(detector.detect(hints)); 38 | ArrayRef< Ref > points (detectorResult->getPoints()); 39 | Ref decoderResult(decoder_.decode(detectorResult->getBits())); 40 | Ref result( 41 | new Result(decoderResult->getText(), decoderResult->getRawBytes(), points, BarcodeFormat::QR_CODE, decoderResult->charSet())); 42 | return result; 43 | } 44 | 45 | QRCodeReader::~QRCodeReader() { 46 | } 47 | 48 | Decoder& QRCodeReader::getDecoder() { 49 | return decoder_; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/qrcode/QRCodeReader.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __QR_CODE_READER_H__ 3 | #define __QR_CODE_READER_H__ 4 | 5 | /* 6 | * QRCodeReader.h 7 | * zxing 8 | * 9 | * Copyright 2010 ZXing authors All rights reserved. 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | namespace zxing { 29 | namespace qrcode { 30 | 31 | class QRCodeReader : public Reader { 32 | private: 33 | Decoder decoder_; 34 | 35 | protected: 36 | Decoder& getDecoder(); 37 | 38 | public: 39 | QRCodeReader(); 40 | virtual ~QRCodeReader(); 41 | 42 | Ref decode(Ref image, DecodeHints hints); 43 | }; 44 | 45 | } 46 | } 47 | 48 | #endif // __QR_CODE_READER_H__ 49 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/qrcode/QRErrorCorrectionLevel.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * ErrorCorrectionLevel.cpp 4 | * zxing 5 | * 6 | * Created by Christian Brunschen on 15/05/2008. 7 | * Copyright 2008-2011 ZXing authors All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include 23 | 24 | using std::string; 25 | 26 | namespace zxing { 27 | namespace qrcode { 28 | 29 | ErrorCorrectionLevel::ErrorCorrectionLevel(int inOrdinal, 30 | int bits, 31 | char const* name) : 32 | ordinal_(inOrdinal), bits_(bits), name_(name) 33 | {} 34 | 35 | ErrorCorrectionLevel::ErrorCorrectionLevel(const ErrorCorrectionLevel &other) : 36 | ordinal_(other.ordinal()), bits_(other.bits()), name_(other.name()) 37 | {} 38 | 39 | int ErrorCorrectionLevel::ordinal() const { 40 | return ordinal_; 41 | } 42 | 43 | int ErrorCorrectionLevel::bits() const { 44 | return bits_; 45 | } 46 | 47 | string const& ErrorCorrectionLevel::name() const { 48 | return name_; 49 | } 50 | 51 | ErrorCorrectionLevel::operator string const& () const { 52 | return name_; 53 | } 54 | 55 | ErrorCorrectionLevel& ErrorCorrectionLevel::forBits(int bits) { 56 | if (bits < 0 || bits >= N_LEVELS) { 57 | throw ReaderException("Ellegal error correction level bits"); 58 | } 59 | return *FOR_BITS[bits]; 60 | } 61 | 62 | ErrorCorrectionLevel ErrorCorrectionLevel::L(0, 0x01, "L"); 63 | ErrorCorrectionLevel ErrorCorrectionLevel::M(1, 0x00, "M"); 64 | ErrorCorrectionLevel ErrorCorrectionLevel::Q(2, 0x03, "Q"); 65 | ErrorCorrectionLevel ErrorCorrectionLevel::H(3, 0x02, "H"); 66 | ErrorCorrectionLevel *ErrorCorrectionLevel::FOR_BITS[] = { &M, &L, &H, &Q }; 67 | int ErrorCorrectionLevel::N_LEVELS = 4; 68 | 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/qrcode/decoder/BitMatrixParser.h: -------------------------------------------------------------------------------- 1 | #ifndef __BIT_MATRIX_PARSER_H__ 2 | #define __BIT_MATRIX_PARSER_H__ 3 | 4 | /* 5 | * BitMatrixParser.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | namespace zxing { 31 | namespace qrcode { 32 | 33 | class BitMatrixParser : public Counted { 34 | private: 35 | Ref bitMatrix_; 36 | Version *parsedVersion_; 37 | Ref parsedFormatInfo_; 38 | 39 | int copyBit(size_t x, size_t y, int versionBits); 40 | 41 | public: 42 | BitMatrixParser(Ref bitMatrix); 43 | Ref readFormatInformation(); 44 | Version *readVersion(); 45 | ArrayRef readCodewords(); 46 | 47 | private: 48 | BitMatrixParser(const BitMatrixParser&); 49 | BitMatrixParser& operator =(const BitMatrixParser&); 50 | 51 | }; 52 | 53 | } 54 | } 55 | 56 | #endif // __BIT_MATRIX_PARSER_H__ 57 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/qrcode/decoder/DataBlock.h: -------------------------------------------------------------------------------- 1 | #ifndef __DATA_BLOCK_H__ 2 | #define __DATA_BLOCK_H__ 3 | 4 | /* 5 | * DataBlock.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | namespace zxing { 30 | namespace qrcode { 31 | 32 | class DataBlock : public Counted { 33 | private: 34 | int numDataCodewords_; 35 | ArrayRef codewords_; 36 | 37 | DataBlock(int numDataCodewords, ArrayRef codewords); 38 | 39 | public: 40 | static std::vector > 41 | getDataBlocks(ArrayRef rawCodewords, Version *version, ErrorCorrectionLevel &ecLevel); 42 | 43 | int getNumDataCodewords(); 44 | ArrayRef getCodewords(); 45 | }; 46 | 47 | } 48 | } 49 | 50 | #endif // __DATA_BLOCK_H__ 51 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/qrcode/decoder/DataMask.h: -------------------------------------------------------------------------------- 1 | #ifndef __DATA_MASK_H__ 2 | #define __DATA_MASK_H__ 3 | 4 | /* 5 | * DataMask.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | namespace zxing { 30 | namespace qrcode { 31 | 32 | class DataMask : public Counted { 33 | private: 34 | static std::vector > DATA_MASKS; 35 | 36 | protected: 37 | 38 | public: 39 | static int buildDataMasks(); 40 | DataMask(); 41 | virtual ~DataMask(); 42 | void unmaskBitMatrix(BitMatrix& matrix, size_t dimension); 43 | virtual bool isMasked(size_t x, size_t y) = 0; 44 | static DataMask& forReference(int reference); 45 | }; 46 | 47 | } 48 | } 49 | 50 | #endif // __DATA_MASK_H__ 51 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/qrcode/decoder/Decoder.h: -------------------------------------------------------------------------------- 1 | #ifndef __DECODER_H__ 2 | #define __DECODER_H__ 3 | 4 | /* 5 | * Decoder.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | namespace zxing { 30 | namespace qrcode { 31 | 32 | class Decoder { 33 | private: 34 | ReedSolomonDecoder rsDecoder_; 35 | 36 | void correctErrors(ArrayRef bytes, int numDataCodewords); 37 | 38 | public: 39 | Decoder(); 40 | Ref decode(Ref bits); 41 | }; 42 | 43 | } 44 | } 45 | 46 | #endif // __DECODER_H__ 47 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/qrcode/decoder/Mode.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __MODE_H__ 3 | #define __MODE_H__ 4 | 5 | /* 6 | * Mode.h 7 | * zxing 8 | * 9 | * Copyright 2010 ZXing authors All rights reserved. 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | namespace zxing { 29 | namespace qrcode { 30 | 31 | class Mode : public Counted 32 | { 33 | private: 34 | int characterCountBitsForVersions0To9_; 35 | int characterCountBitsForVersions10To26_; 36 | int characterCountBitsForVersions27AndHigher_; 37 | int bits_; 38 | std::string name_; 39 | 40 | Mode(int cbv0_9, int cbv10_26, int cbv27, int bits, char const* name); 41 | 42 | public: 43 | Mode(const Mode& mode); 44 | Mode(); 45 | 46 | static Mode TERMINATOR; 47 | static Mode NUMERIC; 48 | static Mode ALPHANUMERIC; 49 | static Mode STRUCTURED_APPEND; 50 | static Mode BYTE; 51 | static Mode ECI; 52 | static Mode KANJI; 53 | static Mode FNC1_FIRST_POSITION; 54 | static Mode FNC1_SECOND_POSITION; 55 | static Mode HANZI; 56 | 57 | static Mode& forBits(int bits); 58 | int getCharacterCountBits(const Version *version) const; 59 | int getBits() const { return bits_; } 60 | 61 | bool operator==(const Mode& other); 62 | 63 | std::string getName() const { return name_; } 64 | }; 65 | } 66 | } 67 | 68 | #endif // __MODE_H__ 69 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/qrcode/detector/AlignmentPattern.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | 3 | #ifndef __ALIGNMENT_PATTERN_H__ 4 | #define __ALIGNMENT_PATTERN_H__ 5 | 6 | /* 7 | * AlignmentPattern.h 8 | * zxing 9 | * 10 | * Copyright 2010 ZXing authors All rights reserved. 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the "License"); 13 | * you may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #include 26 | #include 27 | 28 | namespace zxing { 29 | namespace qrcode { 30 | 31 | class AlignmentPattern : public ResultPoint { 32 | private: 33 | float estimatedModuleSize_; 34 | 35 | public: 36 | AlignmentPattern(float posX, float posY, float estimatedModuleSize); 37 | bool aboutEquals(float moduleSize, float i, float j) const; 38 | Ref combineEstimate(float i, float j, 39 | float newModuleSize) const; 40 | }; 41 | 42 | } 43 | } 44 | 45 | #endif // __ALIGNMENT_PATTERN_H__ 46 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/qrcode/detector/AlignmentPatternFinder.h: -------------------------------------------------------------------------------- 1 | #ifndef __ALIGNMENT_PATTERN_FINDER_H__ 2 | #define __ALIGNMENT_PATTERN_FINDER_H__ 3 | 4 | /* 5 | * AlignmentPatternFinder.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include "AlignmentPattern.h" 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | namespace zxing { 30 | namespace qrcode { 31 | 32 | class AlignmentPatternFinder : public Counted { 33 | private: 34 | static int CENTER_QUORUM; 35 | static int MIN_SKIP; 36 | static int MAX_MODULES; 37 | 38 | Ref image_; 39 | std::vector *possibleCenters_; 40 | int startX_; 41 | int startY_; 42 | int width_; 43 | int height_; 44 | float moduleSize_; 45 | 46 | static float centerFromEnd(std::vector &stateCount, int end); 47 | bool foundPatternCross(std::vector &stateCount); 48 | 49 | float crossCheckVertical(int startI, int centerJ, int maxCount, int originalStateCountTotal); 50 | 51 | Ref handlePossibleCenter(std::vector &stateCount, int i, int j); 52 | 53 | public: 54 | AlignmentPatternFinder(Ref image, int startX, int startY, int width, int height, 55 | float moduleSize, Refconst& callback); 56 | ~AlignmentPatternFinder(); 57 | Ref find(); 58 | 59 | private: 60 | AlignmentPatternFinder(const AlignmentPatternFinder&); 61 | AlignmentPatternFinder& operator =(const AlignmentPatternFinder&); 62 | 63 | Ref callback_; 64 | }; 65 | } 66 | } 67 | 68 | #endif // __ALIGNMENT_PATTERN_FINDER_H__ 69 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/qrcode/detector/FinderPattern.h: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | #ifndef __FINDER_PATTERN_H__ 3 | #define __FINDER_PATTERN_H__ 4 | 5 | /* 6 | * FinderPattern.h 7 | * zxing 8 | * 9 | * Copyright 2010 ZXing authors All rights reserved. 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | #include 25 | #include 26 | 27 | namespace zxing { 28 | namespace qrcode { 29 | 30 | class FinderPattern : public ResultPoint { 31 | private: 32 | float estimatedModuleSize_; 33 | int count_; 34 | 35 | FinderPattern(float posX, float posY, float estimatedModuleSize, int count); 36 | 37 | public: 38 | FinderPattern(float posX, float posY, float estimatedModuleSize); 39 | int getCount() const; 40 | float getEstimatedModuleSize() const; 41 | void incrementCount(); 42 | bool aboutEquals(float moduleSize, float i, float j) const; 43 | Ref combineEstimate(float i, float j, float newModuleSize) const; 44 | }; 45 | } 46 | } 47 | 48 | #endif // __FINDER_PATTERN_H__ 49 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/qrcode/detector/FinderPatternInfo.h: -------------------------------------------------------------------------------- 1 | #ifndef __FINDER_PATTERN_INFO_H__ 2 | #define __FINDER_PATTERN_INFO_H__ 3 | 4 | /* 5 | * FinderPatternInfo.h 6 | * zxing 7 | * 8 | * Copyright 2010 ZXing authors All rights reserved. 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace zxing { 29 | namespace qrcode { 30 | 31 | class FinderPatternInfo : public Counted { 32 | private: 33 | Ref bottomLeft_; 34 | Ref topLeft_; 35 | Ref topRight_; 36 | 37 | public: 38 | FinderPatternInfo(std::vector > patternCenters); 39 | 40 | Ref getBottomLeft(); 41 | Ref getTopLeft(); 42 | Ref getTopRight(); 43 | }; 44 | } 45 | } 46 | 47 | #endif // __FINDER_PATTERN_INFO_H__ 48 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/qrcode/detector/QRAlignmentPattern.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- 2 | /* 3 | * AlignmentPattern.cpp 4 | * zxing 5 | * 6 | * Created by Christian Brunschen on 13/05/2008. 7 | * Copyright 2008 ZXing authors All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include 23 | 24 | using std::abs; 25 | using zxing::Ref; 26 | using zxing::qrcode::AlignmentPattern; 27 | 28 | AlignmentPattern::AlignmentPattern(float posX, float posY, float estimatedModuleSize) : 29 | ResultPoint(posX,posY), estimatedModuleSize_(estimatedModuleSize) { 30 | } 31 | 32 | bool AlignmentPattern::aboutEquals(float moduleSize, float i, float j) const { 33 | if (abs(i - getY()) <= moduleSize && abs(j - getX()) <= moduleSize) { 34 | float moduleSizeDiff = abs(moduleSize - estimatedModuleSize_); 35 | return moduleSizeDiff <= 1.0f || moduleSizeDiff <= estimatedModuleSize_; 36 | } 37 | return false; 38 | } 39 | 40 | Ref AlignmentPattern::combineEstimate(float i, float j, float newModuleSize) const { 41 | float combinedX = (getX() + j) / 2.0f; 42 | float combinedY = (getY() + i) / 2.0f; 43 | float combinedModuleSize = (estimatedModuleSize_ + newModuleSize) / 2.0f; 44 | Ref result 45 | (new AlignmentPattern(combinedX, combinedY, combinedModuleSize)); 46 | return result; 47 | } 48 | -------------------------------------------------------------------------------- /QZXing/zxing/zxing/qrcode/detector/QRFinderPatternInfo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * FinderPatternInfo.cpp 3 | * zxing 4 | * 5 | * Created by Christian Brunschen on 13/05/2008. 6 | * Copyright 2008 ZXing authors All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | #include 22 | 23 | namespace zxing { 24 | namespace qrcode { 25 | 26 | FinderPatternInfo::FinderPatternInfo(std::vector > patternCenters) : 27 | bottomLeft_(patternCenters[0]), topLeft_(patternCenters[1]), topRight_(patternCenters[2]) { 28 | } 29 | 30 | Ref FinderPatternInfo::getBottomLeft() { 31 | return bottomLeft_; 32 | } 33 | Ref FinderPatternInfo::getTopLeft() { 34 | return topLeft_; 35 | } 36 | Ref FinderPatternInfo::getTopRight() { 37 | return topRight_; 38 | } 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BillDownloader 2 | Загрузчик онлайн чеков 3 | 4 | Это приложение позволяет получать из ФНС информацию по чеку. 5 | То есть имея на руках чек - мы можем отскнировать его QR код или вручную ввести данные с чека, а на выходе получить список покупок по этому чеку с весом и ценой по каждому пункту. 6 | В релизах лежит версия для винды и линукса. Для мака собирайте самостоятельно, инструкция по сборке ниже. 7 | 8 | # Как пользоваться 9 | Качаем на смартфон официальное приложение от налоговой. 10 | Регистрируемся в нём. 11 | Открываем файл catergories.txt в текстовом редакторе и заполняем его списком категорий товаров. 12 | Запускаем BillDownloader 13 | Вводим телефон и пароль, которые получили при регистрации в официальном приложении. 14 | Вводим один раз, дальше оно сохраняется локально в настройках приложения. 15 | Нажимаем Request Bill, выбираем источник видео потока для сканирования чека и сканируем чек, либо вводим данные вручную и жмём Manual, чтобы использовать введенные данные. 16 | Если на видеопотоке удастся распознать данные - окно автоматически закроется и отправится запрос на чек. 17 | Заполняем поля, все кроме гарантии - обязательные. 18 | После чего жмём Generate Result и получаем данные в текстовом виде пригодном для вставки в редактор таблиц. 19 | Покупаете что-то второй раз - все поля товара будут уже заполнены. 20 | Всё введенное сохраняется в файле items.csv 21 | 22 | # Как собрать 23 | Устанавливаете Qt Creator 24 | Открываете BillDownloader.pro в QtCreator 25 | Нажимаете кнопку Build 26 | -------------------------------------------------------------------------------- /build/categories.txt: -------------------------------------------------------------------------------- 1 | Добавьте категории в файл categories.txt. Одна категория одна строка. -------------------------------------------------------------------------------- /src/BillDownloader.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2018-03-08T14:03:34 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui multimedia multimediawidgets network 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | include(../QZXing/QZXing.pri) 12 | 13 | TARGET = BillDownloader 14 | TEMPLATE = app 15 | 16 | # The following define makes your compiler emit warnings if you use 17 | # any feature of Qt which as been marked as deprecated (the exact warnings 18 | # depend on your compiler). Please consult the documentation of the 19 | # deprecated API in order to know how to port your code away from it. 20 | DEFINES += QT_DEPRECATED_WARNINGS 21 | 22 | # You can also make your code fail to compile if you use deprecated APIs. 23 | # In order to do so, uncomment the following line. 24 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 25 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 26 | 27 | 28 | SOURCES += main.cpp\ 29 | mainwindow.cpp \ 30 | cwimage.cpp \ 31 | dialogscanreceipt.cpp \ 32 | dialogcopytext.cpp 33 | 34 | HEADERS += mainwindow.h \ 35 | cwimage.h \ 36 | dialogscanreceipt.h \ 37 | dialogcopytext.h 38 | 39 | FORMS += mainwindow.ui \ 40 | dialogscanreceipt.ui \ 41 | dialogcopytext.ui 42 | -------------------------------------------------------------------------------- /src/cnetclient.h: -------------------------------------------------------------------------------- 1 | #ifndef CNETCLIENT_H 2 | #define CNETCLIENT_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | enum eNetWorkError{ 9 | NE_ENCRYPTED_FAIL, 10 | NE_SSL_ERROR, 11 | NE_CONNECTION_LOST, 12 | NE_RESPONSE_INCORRECT_HTTP_HEADER, 13 | NE_RESPONSE_NOT_OK, 14 | NE_RESPONSE_NO_CONTENT, 15 | NE_RESPONSE_CONTENT_EMPTY, 16 | NE_RESPONSE_NO_DATA, 17 | NE_RESPONSE_INCORRECT_BODY 18 | }; 19 | 20 | class cNetClient : public QObject 21 | { 22 | Q_OBJECT 23 | protected: 24 | QSslSocket m_Socket; 25 | QString m_Data; 26 | public: 27 | explicit cNetClient(QObject *parent = 0); 28 | 29 | signals: 30 | void error(QString error, int errorCode); 31 | void processResponse(const QString& json); 32 | private slots: 33 | void processSslErrors( const QList & errors ); 34 | void processDisconnected(); 35 | void processEncrypted(); 36 | void processReadyRead(); 37 | void processModeChanged(QSslSocket::SslMode); 38 | void processAboutClose(); 39 | void processStateChanged(QAbstractSocket::SocketState); 40 | public slots: 41 | void sendMessage(const QString& host, int port, const QString& URL, const QString& userPhone, const QString& userPassword);\ 42 | }; 43 | 44 | #endif // CNETCLIENT_H 45 | -------------------------------------------------------------------------------- /src/cwimage.cpp: -------------------------------------------------------------------------------- 1 | #include "cwimage.h" 2 | #include 3 | 4 | cwImage::cwImage(QWidget* parent):QWidget(parent) 5 | { 6 | 7 | } 8 | 9 | void cwImage::paintEvent(QPaintEvent *) 10 | { 11 | QPainter p(this); 12 | p.drawImage(QRect(0,0,width(),height()),m_Image.scaled(width(),height(),Qt::KeepAspectRatio)); 13 | } 14 | -------------------------------------------------------------------------------- /src/cwimage.h: -------------------------------------------------------------------------------- 1 | #ifndef CWIMAGE_H 2 | #define CWIMAGE_H 3 | 4 | #include 5 | #include 6 | 7 | class cwImage: public QWidget 8 | { 9 | Q_OBJECT 10 | 11 | protected: 12 | QImage m_Image; 13 | public: 14 | cwImage(QWidget *parent); 15 | 16 | virtual void paintEvent(QPaintEvent *) override; 17 | void setImage(QImage& image){ 18 | m_Image = image; 19 | update(); 20 | } 21 | }; 22 | 23 | #endif // CWIMAGE_H 24 | -------------------------------------------------------------------------------- /src/dialogcopytext.cpp: -------------------------------------------------------------------------------- 1 | #include "dialogcopytext.h" 2 | #include "ui_dialogcopytext.h" 3 | #include 4 | #include 5 | 6 | DialogCopyText::DialogCopyText(QWidget *parent) : 7 | QDialog(parent), 8 | ui(new Ui::DialogCopyText) 9 | { 10 | ui->setupUi(this); 11 | } 12 | 13 | DialogCopyText::~DialogCopyText() 14 | { 15 | delete ui; 16 | } 17 | 18 | void DialogCopyText::exec(QStringList text) 19 | { 20 | QString textToCopy = text.join("\n"); 21 | ui->plainTextEdit->setPlainText(textToCopy); 22 | 23 | QApplication::clipboard()->setText(textToCopy); 24 | 25 | QDialog::exec(); 26 | } 27 | 28 | void DialogCopyText::on_pushButton_clicked() 29 | { 30 | QApplication::clipboard()->setText(ui->plainTextEdit->toPlainText()); 31 | } 32 | -------------------------------------------------------------------------------- /src/dialogcopytext.h: -------------------------------------------------------------------------------- 1 | #ifndef DIALOGCOPYTEXT_H 2 | #define DIALOGCOPYTEXT_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class DialogCopyText; 8 | } 9 | 10 | class DialogCopyText : public QDialog 11 | { 12 | Q_OBJECT 13 | public: 14 | explicit DialogCopyText(QWidget *parent = 0); 15 | ~DialogCopyText(); 16 | 17 | void exec(QStringList text); 18 | 19 | private slots: 20 | void on_pushButton_clicked(); 21 | 22 | private: 23 | Ui::DialogCopyText *ui; 24 | }; 25 | 26 | #endif // DIALOGCOPYTEXT_H 27 | -------------------------------------------------------------------------------- /src/dialogcopytext.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DialogCopyText 4 | 5 | 6 | 7 | 0 8 | 0 9 | 872 10 | 645 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 20 | QPlainTextEdit::NoWrap 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | Qt::Horizontal 30 | 31 | 32 | 33 | 40 34 | 20 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | Copy to Clipboard 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/dialogscanreceipt.h: -------------------------------------------------------------------------------- 1 | #ifndef DIALOGSCANRECEIPT_H 2 | #define DIALOGSCANRECEIPT_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace Ui { 12 | class DialogScanReceipt; 13 | } 14 | 15 | class DialogScanReceipt : public QDialog 16 | { 17 | Q_OBJECT 18 | private: 19 | QZXing m_Decoder; 20 | 21 | QCamera* m_Camera; 22 | QCameraImageCapture*m_CaptureImage; 23 | void fillCamerasList(); 24 | public: 25 | explicit DialogScanReceipt(QWidget *parent = 0); 26 | ~DialogScanReceipt(); 27 | 28 | virtual int exec() override; 29 | 30 | QString getFN(); 31 | QString getFD(); 32 | QString getFPD(); 33 | 34 | private slots: 35 | void on_comboBox_currentIndexChanged(int index); 36 | 37 | void on_imageAvailable(int, const QVideoFrame &buffer); 38 | 39 | void on_readyForCaptureChanged(bool); 40 | 41 | void on_pushButtonManualInput_clicked(); 42 | 43 | private: 44 | Ui::DialogScanReceipt *ui; 45 | }; 46 | 47 | #endif // DIALOGSCANRECEIPT_H 48 | -------------------------------------------------------------------------------- /src/dialogscanreceipt.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DialogScanReceipt 4 | 5 | 6 | 7 | 0 8 | 0 9 | 853 10 | 670 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 0 24 | 25 | 26 | 27 | 28 | ФН 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | ФД 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | ФПД 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | Manual 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 0 69 | 0 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | cwImage 79 | QWidget 80 |
cwimage.h
81 | 1 82 |
83 |
84 | 85 | 86 |
87 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MainWindow w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /src/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 838 10 | 627 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | User phone: 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | User password: 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | Request bill 44 | 45 | 46 | 47 | 48 | 49 | 50 | Generate result 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | dd.MM.yyyy hh:mm 60 | 61 | 62 | true 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | --------------------------------------------------------------------------------