Merge branch 'master' of github.com:ftylitak/qzxing

This commit is contained in:
Stefan Dunca 2019-07-07 22:45:07 +02:00
commit c6e1a9def0
12 changed files with 48 additions and 7 deletions

4
.lgtm.yml Normal file
View File

@ -0,0 +1,4 @@
extraction:
cpp:
configure:
command: "qmake -o Makefile CONFIG+=Release src/QZXing.pro"

View File

@ -25,11 +25,11 @@ addons:
env:
matrix:
- BUILD_TARGERT="linux" QT_VERSION_DIR=5.13 QT_VERSION=5.13.0
- BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.13 QT_VERSION=5.13.0
# - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.13 QT_VERSION=5.13.0
- BUILD_TARGERT="linux" QT_VERSION_DIR=5.12 QT_VERSION=5.12.4
- BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.12 QT_VERSION=5.12.4
# - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.12 QT_VERSION=5.12.4
- BUILD_TARGERT="linux" QT_VERSION_DIR=5.9 QT_VERSION=5.9.8
- BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.9 QT_VERSION=5.9.8
# - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.9 QT_VERSION=5.9.8
before_install:
- echo "TRAVIS_OS_NAME=${TRAVIS_OS_NAME}"

View File

@ -1,4 +1,4 @@
# qzxing [![Build Status](https://travis-ci.com/ftylitak/qzxing.svg?branch=master)](https://travis-ci.com/ftylitak/qzxing) [![Build Status](https://ci.appveyor.com/api/projects/status/0033p4dyo49iy5jq?svg=true)](https://ci.appveyor.com/project/ftylitak/qzxing)
# qzxing [![Build Status](https://travis-ci.com/ftylitak/qzxing.svg?branch=master)](https://travis-ci.com/ftylitak/qzxing) [![Build Status](https://ci.appveyor.com/api/projects/status/0033p4dyo49iy5jq?svg=true)](https://ci.appveyor.com/project/ftylitak/qzxing) [![Total alerts](https://img.shields.io/lgtm/alerts/g/ftylitak/qzxing.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/ftylitak/qzxing/alerts/) [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/ftylitak/qzxing.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/ftylitak/qzxing/context:cpp)
Qt/QML wrapper library for the [ZXing](https://github.com/zxing/zxing) barcode image processing library.
Supports barcode decoding for the following types:

View File

@ -105,6 +105,7 @@ std::string ResultMetadata::keyToString(Key key) const
case STRUCTURED_APPEND_CODE_COUNT: return "STRUCTURED_APPEND_CODE_COUNT";
case STRUCTURED_APPEND_PARITY: return "STRUCTURED_APPEND_PARITY";
}
return "UNKNOWN";
}
} // zxing

View File

@ -85,11 +85,11 @@ private:
/**
* See ISO 16022:2006, Annex B, B.2
*/
char unrandomize255State(int randomizedBase256Codeword,
zxing::byte unrandomize255State(int randomizedBase256Codeword,
int base256CodewordPosition) {
int pseudoRandomNumber = ((149 * base256CodewordPosition) % 255) + 1;
int tempVariable = randomizedBase256Codeword - pseudoRandomNumber;
return (zxing::byte) (tempVariable >= 0 ? tempVariable : (tempVariable + 256));
return static_cast<zxing::byte>(tempVariable >= 0 ? tempVariable : (tempVariable + 256));
}
void append(std::ostream &ost, const char *bufIn, size_t nIn, const char *src);

View File

@ -206,6 +206,7 @@ void LinesSampler::codewordsToBitMatrix(vector<vector<int> > &codewords, Ref<Bit
for (int j = 0; j < (int)codewords[i].size(); j++) {
int moduleOffset = j * MODULES_IN_SYMBOL;
for (int k = 0; k < MODULES_IN_SYMBOL; k++) {
//TODO: Potential unsafe sign check of a bitwise operation.
if ((codewords[i][j] & (1 << (MODULES_IN_SYMBOL - k - 1))) > 0) {
matrix->set(moduleOffset + k, i);
}
@ -226,6 +227,7 @@ int LinesSampler::calculateClusterNumber(int codeword) {
int barNumber = 0;
bool blackBar = true;
int clusterNumber = 0;
//TODO: Potential unsafe sign check of a bitwise operation.
for (int i = 0; i < MODULES_IN_SYMBOL; i++) {
if ((codeword & (1 << i)) > 0) {
if (!blackBar) {

View File

@ -31,6 +31,7 @@ private:
int ordinal_;
int bits_;
std::string name_;
ErrorCorrectionLevel(int inOrdinal, int bits, char const* name);
static ErrorCorrectionLevel *FOR_BITS[];
static int N_LEVELS;
@ -41,6 +42,7 @@ public:
static ErrorCorrectionLevel H;
ErrorCorrectionLevel(const ErrorCorrectionLevel& other);
ErrorCorrectionLevel& operator=(const ErrorCorrectionLevel &other);
int ordinal() const;
int bits() const;

View File

@ -52,6 +52,15 @@ ErrorCorrectionLevel::operator string const& () const {
return name_;
}
ErrorCorrectionLevel& ErrorCorrectionLevel::operator=(const ErrorCorrectionLevel &other)
{
ordinal_ = other.ordinal();
bits_ = other.bits();
name_ = other.name();
return *this;
}
ErrorCorrectionLevel& ErrorCorrectionLevel::forBits(int bits) {
if (bits < 0 || bits >= N_LEVELS) {
throw ReaderException("Ellegal error correction level bits");

View File

@ -58,6 +58,7 @@ public:
int getCharacterCountBits(const Version *version) const;
int getBits() const { return bits_; }
Mode& operator=(const Mode& other);
bool operator==(const Mode& other);
bool operator!=(const Mode& other);

View File

@ -108,6 +108,17 @@ int Mode::getCharacterCountBits(const Version *version) const
}
}
Mode& Mode::operator=(const Mode& other)
{
characterCountBitsForVersions0To9_ = other.characterCountBitsForVersions0To9_;
characterCountBitsForVersions10To26_ = other.characterCountBitsForVersions10To26_;
characterCountBitsForVersions27AndHigher_ = other.characterCountBitsForVersions27AndHigher_;
bits_ = other.bits_;
name_ = other.name_;
return *this;
}
bool Mode::operator==(const Mode& other)
{
return ( characterCountBitsForVersions0To9_ == other.characterCountBitsForVersions0To9_

View File

@ -3,6 +3,7 @@
#include <vector>
#include <zxing/common/Array.h>
#include <zxing/common/Types.h>
using namespace std;
@ -24,6 +25,16 @@ public:
ArrayRef<zxing::byte> getDataBytes() { return data_; }
ArrayRef<zxing::byte> getErrorCorrectionBytes() { return errorCorrection_; }
BlockPair& operator=(const BlockPair &other) {
data_->release();
errorCorrection_->release();
data_ = other.data_;
errorCorrection_ = other.errorCorrection_;
return *this;
}
};
}

View File

@ -79,7 +79,7 @@ Ref<QRCode> Encoder::encode(const std::string& content, ErrorCorrectionLevel &ec
version = Version::getVersionForNumber(1);
int bitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, version);
if (!willFit(bitsNeeded, version, ecLevel)) {
throw new WriterException("Data too big for requested version");
throw WriterException("Data too big for requested version");
}
} else {
version = recommendVersion(ecLevel, mode, headerBits, dataBits);