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

Method drawCodewords

Libraries/QRCode/tests/QrCode.cpp:343–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

341
342
343void qrcodegen::QrCode::drawCodewords(const std::vector<uint8_t> &data) {
344 if (data.size() != static_cast<unsigned int>(getNumRawDataModules(version) / 8))
345 throw "Invalid argument";
346
347 size_t i = 0; // Bit index into the data
348 // Do the funny zigzag scan
349 for (int right = size - 1; right >= 1; right -= 2) { // Index of right column in each column pair
350 if (right == 6)
351 right = 5;
352 for (int vert = 0; vert < size; vert++) { // Vertical counter
353 for (int j = 0; j < 2; j++) {
354 int x = right - j; // Actual x coordinate
355 bool upwards = ((right & 2) == 0) ^ (x < 6);
356 int y = upwards ? size - 1 - vert : vert; // Actual y coordinate
357 if (!isFunction.at(y).at(x) && i < data.size() * 8) {
358 modules.at(y).at(x) = ((data.at(i >> 3) >> (7 - (i & 7))) & 1) != 0;
359 i++;
360 }
361 // If there are any remainder bits (0 to 7), they are already
362 // set to 0/false/white when the grid of modules was initialized
363 }
364 }
365 }
366 if (static_cast<unsigned int>(i) != data.size() * 8)
367 throw "Assertion error";
368}
369
370
371void qrcodegen::QrCode::applyMask(int mask) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected