* This method detects a code in a "pure" image -- that is, pure monochrome image * which contains only an unrotated, unskewed, image of a code, with some white border * around it. This is a specialized method that works exceptionally fast in this special * case. */
| 23 | * case. |
| 24 | */ |
| 25 | static BitMatrix ExtractPureBits(const BitMatrix& image) |
| 26 | { |
| 27 | int left, top, width, height; |
| 28 | if (!image.findBoundingBox(left, top, width, height, BitMatrixParser::MATRIX_WIDTH)) |
| 29 | return {}; |
| 30 | |
| 31 | // Now just read off the bits |
| 32 | BitMatrix result(BitMatrixParser::MATRIX_WIDTH, BitMatrixParser::MATRIX_HEIGHT); |
| 33 | for (int y = 0; y < BitMatrixParser::MATRIX_HEIGHT; y++) { |
| 34 | int iy = top + (y * height + height / 2) / BitMatrixParser::MATRIX_HEIGHT; |
| 35 | for (int x = 0; x < BitMatrixParser::MATRIX_WIDTH; x++) { |
| 36 | int ix = left + (x * width + width / 2 + (y & 0x01) * width / 2) / BitMatrixParser::MATRIX_WIDTH; |
| 37 | if (image.get(ix, iy)) { |
| 38 | result.set(x, y); |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | //TODO: need to return position info |
| 44 | return result; |
| 45 | } |
| 46 | |
| 47 | Result |
| 48 | Reader::decode(const BinaryBitmap& image) const |
no test coverage detected