mirror of
https://github.com/status-im/qzxing.git
synced 2025-02-21 15:18:14 +00:00
Merge branch 'master' of github.com:ftylitak/qzxing
This commit is contained in:
commit
c6e1a9def0
4
.lgtm.yml
Normal file
4
.lgtm.yml
Normal file
@ -0,0 +1,4 @@
|
||||
extraction:
|
||||
cpp:
|
||||
configure:
|
||||
command: "qmake -o Makefile CONFIG+=Release src/QZXing.pro"
|
@ -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}"
|
||||
|
@ -1,4 +1,4 @@
|
||||
# qzxing [](https://travis-ci.com/ftylitak/qzxing) [](https://ci.appveyor.com/project/ftylitak/qzxing)
|
||||
# qzxing [](https://travis-ci.com/ftylitak/qzxing) [](https://ci.appveyor.com/project/ftylitak/qzxing) [](https://lgtm.com/projects/g/ftylitak/qzxing/alerts/) [](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:
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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_
|
||||
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user