use datamatrix::{DataMatrix, SymbolList};
use image::{GrayImage, Luma};
fn main() {
const N: usize = 5;
let bitmap = DataMatrix::encode(b"Hello, World!", SymbolList::default().enforce_square())
.unwrap()
.bitmap();
let width = ((bitmap.width() + 2) * N) as u32;
let height = ((bitmap.height() + 2) * N) as u32;
let mut image = GrayImage::from_pixel(width, height, Luma([255]));
for (x, y) in bitmap.pixels() {
for i in 0..N {
for j in 0..N {
let x_i = (x + 1) * N + j;
let y_j = (y + 1) * N + i;
image.put_pixel(x_i as u32, y_j as u32, Luma([0]));
}
}
}
image.save("data_matrix.png").unwrap();
}