MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / drawFormatBits

Method drawFormatBits

Libraries/QRCode/tests/QrCode.cpp:224–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222
223
224void qrcodegen::QrCode::drawFormatBits(int mask) {
225 // Calculate error correction code and pack bits
226 int data = errorCorrectionLevel.formatBits << 3 | mask; // errCorrLvl is uint2, mask is uint3
227 int rem = data;
228 for (int i = 0; i < 10; i++)
229 rem = (rem << 1) ^ ((rem >> 9) * 0x537);
230 data = data << 10 | rem;
231 data ^= 0x5412; // uint15
232 if (data >> 15 != 0)
233 throw "Assertion error";
234
235 // Draw first copy
236 for (int i = 0; i <= 5; i++)
237 setFunctionModule(8, i, ((data >> i) & 1) != 0);
238 setFunctionModule(8, 7, ((data >> 6) & 1) != 0);
239 setFunctionModule(8, 8, ((data >> 7) & 1) != 0);
240 setFunctionModule(7, 8, ((data >> 8) & 1) != 0);
241 for (int i = 9; i < 15; i++)
242 setFunctionModule(14 - i, 8, ((data >> i) & 1) != 0);
243
244 // Draw second copy
245 for (int i = 0; i <= 7; i++)
246 setFunctionModule(size - 1 - i, 8, ((data >> i) & 1) != 0);
247 for (int i = 8; i < 15; i++)
248 setFunctionModule(8, size - 15 + i, ((data >> i) & 1) != 0);
249 setFunctionModule(8, size - 8, true);
250}
251
252
253void qrcodegen::QrCode::drawVersion() {

Callers

nothing calls this directly

Calls 1

setFunctionModuleFunction · 0.85

Tested by

no test coverage detected