Gets the module at the given coordinates, which must be in bounds.
| 655 | |
| 656 | // Gets the module at the given coordinates, which must be in bounds. |
| 657 | testable bool getModule(const uint8_t qrcode[], int x, int y) { |
| 658 | int qrsize = qrcode[0]; |
| 659 | assert(21 <= qrsize && qrsize <= 177 && 0 <= x && x < qrsize && 0 <= y && y < qrsize); |
| 660 | int index = y * qrsize + x; |
| 661 | int bitIndex = index & 7; |
| 662 | int byteIndex = (index >> 3) + 1; |
| 663 | return ((qrcode[byteIndex] >> bitIndex) & 1) != 0; |
| 664 | } |
| 665 | |
| 666 | |
| 667 | // Sets the module at the given coordinates, which must be in bounds. |
no test coverage detected