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

Method handleConstructorMasking

Libraries/QRCode/tests/QrCode.cpp:394–413  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

392
393
394int qrcodegen::QrCode::handleConstructorMasking(int mask) {
395 if (mask == -1) { // Automatically choose best mask
396 int32_t minPenalty = INT32_MAX;
397 for (int i = 0; i < 8; i++) {
398 drawFormatBits(i);
399 applyMask(i);
400 int penalty = getPenaltyScore();
401 if (penalty < minPenalty) {
402 mask = i;
403 minPenalty = penalty;
404 }
405 applyMask(i); // Undoes the mask due to XOR
406 }
407 }
408 if (mask < 0 || mask > 7)
409 throw "Assertion error";
410 drawFormatBits(mask); // Overwrite old format bits
411 applyMask(mask); // Apply the final choice of mask
412 return mask; // The caller shall assign this value to the final-declared field
413}
414
415
416int qrcodegen::QrCode::getPenaltyScore() const {

Callers

nothing calls this directly

Calls 3

drawFormatBitsFunction · 0.85
applyMaskFunction · 0.85
getPenaltyScoreFunction · 0.85

Tested by

no test coverage detected