MCPcopy Create free account
hub / github.com/devilsen/CZXing / EmbedVersionInfo

Function EmbedVersionInfo

czxing/src/main/cpp/zxing/src/qrcode/QRMatrixUtil.cpp:231–251  ·  view source on GitHub ↗

Embed version information if need be. On success, modify the matrix and return true. See 8.10 of JISX0510:2004 (p.47) for how to embed version information.

Source from the content-addressed store, hash-verified

229// Embed version information if need be. On success, modify the matrix and return true.
230// See 8.10 of JISX0510:2004 (p.47) for how to embed version information.
231static void EmbedVersionInfo(const Version& version, TritMatrix& matrix)
232{
233 if (version.versionNumber() < 7) { // Version info is necessary if version >= 7.
234 return; // Don't need version info.
235 }
236
237 BitArray versionInfoBits = MakeVersionInfoBits(version);
238
239 int bitIndex = 6 * 3 - 1; // It will decrease from 17 to 0.
240 for (int i = 0; i < 6; ++i) {
241 for (int j = 0; j < 3; ++j) {
242 // Place bits in LSB (least significant bit) to MSB order.
243 bool bit = versionInfoBits.get(bitIndex);
244 bitIndex--;
245 // Left bottom corner.
246 matrix.set(i, matrix.height() - 11 + j, bit);
247 // Right bottom corner.
248 matrix.set(matrix.height() - 11 + j, i, bit);
249 }
250 }
251}
252
253// Embed "dataBits" using "getMaskPattern". On success, modify the matrix and return true.
254// For debugging purposes, it skips masking process if "getMaskPattern" is -1.

Callers 1

BuildMatrixFunction · 0.85

Calls 5

MakeVersionInfoBitsFunction · 0.85
versionNumberMethod · 0.80
getMethod · 0.45
setMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected