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

Function setModule

modules/data/qrcode/qrcodegen.c:668–678  ·  view source on GitHub ↗

Sets the module at the given coordinates, which must be in bounds.

Source from the content-addressed store, hash-verified

666
667// Sets the module at the given coordinates, which must be in bounds.
668testable void setModule(uint8_t qrcode[], int x, int y, bool isBlack) {
669 int qrsize = qrcode[0];
670 assert(21 <= qrsize && qrsize <= 177 && 0 <= x && x < qrsize && 0 <= y && y < qrsize);
671 int index = y * qrsize + x;
672 int bitIndex = index & 7;
673 int byteIndex = (index >> 3) + 1;
674 if (isBlack)
675 qrcode[byteIndex] |= 1 << bitIndex;
676 else
677 qrcode[byteIndex] &= (1 << bitIndex) ^ 0xFF;
678}
679
680
681// Sets the module at the given coordinates, doing nothing if out of bounds.

Callers 6

drawWhiteFunctionModulesFunction · 0.85
drawFormatBitsFunction · 0.85
fillRectangleFunction · 0.85
drawCodewordsFunction · 0.85
applyMaskFunction · 0.85
setModuleBoundedFunction · 0.85

Calls 1

assertFunction · 0.50

Tested by

no test coverage detected