Returns the number of data bits that can be stored in a QR Code of the given version number, after all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8. The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
| 247 | // all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8. |
| 248 | // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table. |
| 249 | testable int getNumRawDataModules(int version) { |
| 250 | assert(qrcodegen_VERSION_MIN <= version && version <= qrcodegen_VERSION_MAX); |
| 251 | int result = (16 * version + 128) * version + 64; |
| 252 | if (version >= 2) { |
| 253 | int numAlign = version / 7 + 2; |
| 254 | result -= (25 * numAlign - 10) * numAlign - 55; |
| 255 | if (version >= 7) |
| 256 | result -= 18 * 2; // Subtract version information |
| 257 | } |
| 258 | return result; |
| 259 | } |
| 260 | |
| 261 | |
| 262 |
no test coverage detected