Ported functions

@ qrcode/decoder/QRBitMatrixParser.cpp
 - remask
 - setMirror
 - mirror
This commit is contained in:
favoritas37 2016-06-14 02:43:53 +03:00
parent b0e3661c44
commit 53c80b3313
3 changed files with 36 additions and 1 deletions

View File

@ -35,6 +35,7 @@ private:
Ref<BitMatrix> bitMatrix_; Ref<BitMatrix> bitMatrix_;
Version *parsedVersion_; Version *parsedVersion_;
Ref<FormatInformation> parsedFormatInfo_; Ref<FormatInformation> parsedFormatInfo_;
bool mirror_;
int copyBit(size_t x, size_t y, int versionBits); int copyBit(size_t x, size_t y, int versionBits);
@ -43,6 +44,9 @@ public:
Ref<FormatInformation> readFormatInformation(); Ref<FormatInformation> readFormatInformation();
Version *readVersion(); Version *readVersion();
ArrayRef<char> readCodewords(); ArrayRef<char> readCodewords();
void remask();
void setMirror(boolean mirror);
void mirror();
private: private:
BitMatrixParser(const BitMatrixParser&); BitMatrixParser(const BitMatrixParser&);

View File

@ -179,5 +179,32 @@ ArrayRef<char> BitMatrixParser::readCodewords() {
return result; return result;
} }
void BitMatrixParser::remask() {
if (parsedFormatInfo_ == 0) {
return; // We have no format information, and have no data mask
}
DataMask &dataMask = DataMask::forReference((int)parsedFormatInfo_->getDataMask());
int dimension = bitMatrix_->getHeight();
dataMask.unmaskBitMatrix(*bitMatrix_, dimension);
}
void BitMatrixParser::setMirror(boolean mirror) {
parsedVersion_ = 0;
parsedFormatInfo_ = 0;
mirror_ = mirror;
}
void BitMatrixParser::mirror() {
for (int x = 0; x < bitMatrix_->getWidth(); x++) {
for (int y = x + 1; y < bitMatrix_->getHeight(); y++) {
if (bitMatrix_->get(x, y) != bitMatrix_->get(y, x)) {
bitMatrix_->flip(y, x);
bitMatrix_->flip(x, y);
}
}
}
}
} }
} }

View File

@ -29,7 +29,6 @@
#include <zxing/ChecksumException.h> #include <zxing/ChecksumException.h>
#include <zxing/common/reedsolomon/ReedSolomonException.h> #include <zxing/common/reedsolomon/ReedSolomonException.h>
using zxing::qrcode::Decoder;
using zxing::DecoderResult; using zxing::DecoderResult;
using zxing::Ref; using zxing::Ref;
@ -37,6 +36,9 @@ using zxing::Ref;
using zxing::ArrayRef; using zxing::ArrayRef;
using zxing::BitMatrix; using zxing::BitMatrix;
namespace zxing {
namespace qrcode {
Decoder::Decoder() : Decoder::Decoder() :
rsDecoder_(GenericGF::QR_CODE_FIELD_256) { rsDecoder_(GenericGF::QR_CODE_FIELD_256) {
} }
@ -105,3 +107,5 @@ Ref<DecoderResult> Decoder::decode(Ref<BitMatrix> bits) {
DecodedBitStreamParser::Hashtable()); DecodedBitStreamParser::Hashtable());
} }
}
}