MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / getNumRawDataModules

Function getNumRawDataModules

modules/data/qrcode/qrcodegen.c:249–259  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

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.
249testable 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

Callers 3

appendErrorCorrectionFunction · 0.85
getNumDataCodewordsFunction · 0.85

Calls 1

assertFunction · 0.50

Tested by

no test coverage detected