Sets the module at the given coordinates, which must be in bounds.
| 666 | |
| 667 | // Sets the module at the given coordinates, which must be in bounds. |
| 668 | testable 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. |
no test coverage detected