(matrix: BitMatrix)
| 325 | } |
| 326 | |
| 327 | export function decode(matrix: BitMatrix): DecodedQR { |
| 328 | if (matrix == null) { |
| 329 | return null; |
| 330 | } |
| 331 | const result = decodeMatrix(matrix); |
| 332 | if (result) { |
| 333 | return result; |
| 334 | } |
| 335 | // Decoding didn't work, try mirroring the QR across the topLeft -> bottomRight line. |
| 336 | for (let x = 0; x < matrix.width; x++) { |
| 337 | for (let y = x + 1; y < matrix.height; y++) { |
| 338 | if (matrix.get(x, y) !== matrix.get(y, x)) { |
| 339 | matrix.set(x, y, !matrix.get(x, y)); |
| 340 | matrix.set(y, x, !matrix.get(y, x)); |
| 341 | } |
| 342 | } |
| 343 | } |
| 344 | return decodeMatrix(matrix); |
| 345 | } |
no test coverage detected
searching dependent graphs…