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.
| 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. |
| 231 | static 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. |
no test coverage detected