MCPcopy Create free account
hub / github.com/creatale/node-dv / readVersion

Method readVersion

deps/zxing/core/src/zxing/qrcode/decoder/3BitMatrixParser.cpp:77–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77Version *BitMatrixParser::readVersion() {
78 if (parsedVersion_ != 0) {
79 return parsedVersion_;
80 }
81
82 int dimension = bitMatrix_->getHeight();
83
84 int provisionalVersion = (dimension - 17) >> 2;
85 if (provisionalVersion <= 6) {
86 return Version::getVersionForNumber(provisionalVersion);
87 }
88
89 // Read top-right version info: 3 wide by 6 tall
90 int versionBits = 0;
91 for (int y = 5; y >= 0; y--) {
92 int xMin = dimension - 11;
93 for (int x = dimension - 9; x >= xMin; x--) {
94 versionBits = copyBit(x, y, versionBits);
95 }
96 }
97
98 parsedVersion_ = Version::decodeVersionInformation(versionBits);
99 if (parsedVersion_ != 0 && parsedVersion_->getDimensionForVersion() == dimension) {
100 return parsedVersion_;
101 }
102
103 // Hmm, failed. Try bottom left: 6 wide by 3 tall
104 versionBits = 0;
105 for (int x = 5; x >= 0; x--) {
106 int yMin = dimension - 11;
107 for (int y = dimension - 9; y >= yMin; y--) {
108 versionBits = copyBit(x, y, versionBits);
109 }
110 }
111
112 parsedVersion_ = Version::decodeVersionInformation(versionBits);
113 if (parsedVersion_ != 0 && parsedVersion_->getDimensionForVersion() == dimension) {
114 return parsedVersion_;
115 }
116 throw ReaderException("Could not decode version");
117}
118
119ArrayRef<char> BitMatrixParser::readCodewords() {
120 Ref<FormatInformation> formatInfo = readFormatInformation();

Callers 1

decodeMethod · 0.45

Calls 3

ReaderExceptionClass · 0.85
getHeightMethod · 0.45

Tested by

no test coverage detected