diff --git a/core/src/DecoderResult.h b/core/src/DecoderResult.h index c1e328d7f9..cf3492ebe4 100644 --- a/core/src/DecoderResult.h +++ b/core/src/DecoderResult.h @@ -25,6 +25,7 @@ class DecoderResult Content _content; std::string _ecLevel; int _lineCount = 0; + int _versionNumber = 0; StructuredAppendInfo _structuredAppend; bool _isMirrored = false; bool _readerInit = false; @@ -71,6 +72,7 @@ class DecoderResult ZX_PROPERTY(std::string, ecLevel, setEcLevel) ZX_PROPERTY(int, lineCount, setLineCount) + ZX_PROPERTY(int, versionNumber, setVersionNumber) ZX_PROPERTY(StructuredAppendInfo, structuredAppend, setStructuredAppend) ZX_PROPERTY(Error, error, setError) ZX_PROPERTY(bool, isMirrored, setIsMirrored) diff --git a/core/src/Result.cpp b/core/src/Result.cpp index 0f66743220..509d824209 100644 --- a/core/src/Result.cpp +++ b/core/src/Result.cpp @@ -23,6 +23,7 @@ Result::Result(const std::string& text, int y, int xStart, int xStop, BarcodeFor _position(Line(y, xStart, xStop)), _format(format), _lineCount(0), + _versionNumber(0), _readerInit(readerInit) {} @@ -34,6 +35,7 @@ Result::Result(DecoderResult&& decodeResult, Position&& position, BarcodeFormat _sai(decodeResult.structuredAppend()), _format(format), _lineCount(decodeResult.lineCount()), + _versionNumber(decodeResult.versionNumber()), _isMirrored(decodeResult.isMirrored()), _readerInit(decodeResult.readerInit()) { @@ -116,7 +118,7 @@ Result& Result::setDecodeHints(DecodeHints hints) bool Result::operator==(const Result& o) const { - // two symbols may be considered the same if at least one of them has an error + // two symbols may not be considered the same if at least one of them has an error if (!(format() == o.format() && (bytes() == o.bytes() || error() || o.error()))) return false; diff --git a/core/src/Result.h b/core/src/Result.h index 4112c86e3c..702a6abc6f 100644 --- a/core/src/Result.h +++ b/core/src/Result.h @@ -144,10 +144,15 @@ class Result bool readerInit() const { return _readerInit; } /** - * @brief How many lines have been detected with this code (applies only to linear symbologies) + * @brief lineCount How many lines have been detected with this code (applies only to linear symbologies) */ int lineCount() const { return _lineCount; } + /** + * @brief versionNumber QR Code or DataMatrix version number. + */ + int versionNumber() const { return _versionNumber; } + // only for internal use void incrementLineCount() { ++_lineCount; } void setIsInverted(bool v) { _isInverted = v; } @@ -166,6 +171,7 @@ class Result StructuredAppendInfo _sai; BarcodeFormat _format = BarcodeFormat::None; int _lineCount = 0; + int _versionNumber = 0; bool _isMirrored = false; bool _isInverted = false; bool _readerInit = false; diff --git a/core/src/datamatrix/DMDecoder.cpp b/core/src/datamatrix/DMDecoder.cpp index e12a9122f5..c79515e0f5 100644 --- a/core/src/datamatrix/DMDecoder.cpp +++ b/core/src/datamatrix/DMDecoder.cpp @@ -421,7 +421,8 @@ static DecoderResult DoDecode(const BitMatrix& bits) } // Decode the contents of that stream of bytes - return DecodedBitStreamParser::Decode(std::move(resultBytes), version->isDMRE()); + return DecodedBitStreamParser::Decode(std::move(resultBytes), version->isDMRE()) + .setVersionNumber(version->versionNumber); } static BitMatrix FlippedL(const BitMatrix& bits) diff --git a/core/src/qrcode/QRDecoder.cpp b/core/src/qrcode/QRDecoder.cpp index c4a42addbc..0c255d4811 100644 --- a/core/src/qrcode/QRDecoder.cpp +++ b/core/src/qrcode/QRDecoder.cpp @@ -308,6 +308,7 @@ DecoderResult DecodeBitStream(ByteArray&& bytes, const Version& version, ErrorCo return DecoderResult(std::move(result)) .setError(std::move(error)) .setEcLevel(ToString(ecLevel)) + .setVersionNumber(version.versionNumber()) .setStructuredAppend(structuredAppend); }
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: