* Encode the given symbol info to a bit matrix. * * @param placement The DataMatrix placement. * @param symbolInfo The symbol info to encode. * @return The bit matrix generated. */
| 28 | * @return The bit matrix generated. |
| 29 | */ |
| 30 | static BitMatrix EncodeLowLevel(const BitMatrix& placement, const SymbolInfo& symbolInfo) { |
| 31 | int symbolWidth = symbolInfo.symbolDataWidth(); |
| 32 | int symbolHeight = symbolInfo.symbolDataHeight(); |
| 33 | |
| 34 | BitMatrix matrix(symbolInfo.symbolWidth(), symbolInfo.symbolHeight()); |
| 35 | int matrixY = 0; |
| 36 | for (int y = 0; y < symbolHeight; y++) { |
| 37 | // Fill the top edge with alternate 0 / 1 |
| 38 | int matrixX; |
| 39 | if ((y % symbolInfo.matrixHeight()) == 0) { |
| 40 | matrixX = 0; |
| 41 | for (int x = 0; x < matrix.width(); x++) { |
| 42 | matrix.set(matrixX, matrixY, (x % 2) == 0); |
| 43 | matrixX++; |
| 44 | } |
| 45 | matrixY++; |
| 46 | } |
| 47 | matrixX = 0; |
| 48 | for (int x = 0; x < symbolWidth; x++) { |
| 49 | // Fill the right edge with full 1 |
| 50 | if ((x % symbolInfo.matrixWidth()) == 0) { |
| 51 | matrix.set(matrixX, matrixY, true); |
| 52 | matrixX++; |
| 53 | } |
| 54 | matrix.set(matrixX, matrixY, placement.get(x, y) == 1); |
| 55 | matrixX++; |
| 56 | // Fill the right edge with alternate 0 / 1 |
| 57 | if ((x % symbolInfo.matrixWidth()) == symbolInfo.matrixWidth() - 1) { |
| 58 | matrix.set(matrixX, matrixY, (y % 2) == 0); |
| 59 | matrixX++; |
| 60 | } |
| 61 | } |
| 62 | matrixY++; |
| 63 | // Fill the bottom edge with full 1 |
| 64 | if ((y % symbolInfo.matrixHeight()) == symbolInfo.matrixHeight() - 1) { |
| 65 | matrixX = 0; |
| 66 | for (int x = 0; x < matrix.width(); x++) { |
| 67 | matrix.set(matrixX, matrixY, true); |
| 68 | matrixX++; |
| 69 | } |
| 70 | matrixY++; |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | return matrix; |
| 75 | } |
| 76 | |
| 77 | Writer::Writer() : |
| 78 | _shapeHint(SymbolShape::NONE) |
no test coverage detected