mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 12:22:34 +00:00
basic functions for rxing-cli
This commit is contained in:
@@ -662,3 +662,24 @@ impl fmt::Display for BitMatrix {
|
||||
write!(f, "{}", self.toString("X ", " "))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "image")]
|
||||
impl From<BitMatrix> for image::DynamicImage {
|
||||
fn from(value: BitMatrix) -> Self {
|
||||
(&value).into()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "image")]
|
||||
impl From<&BitMatrix> for image::DynamicImage {
|
||||
fn from(value: &BitMatrix) -> Self {
|
||||
let mut pixels = image::ImageBuffer::new(value.width, value.height);
|
||||
|
||||
for y in 0..value.height {
|
||||
for x in 0..value.width {
|
||||
pixels.put_pixel(x, y, image::Luma([if value.get(x, y) {u8::MIN} else {u8::MAX} ]));
|
||||
}
|
||||
}
|
||||
pixels.into()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user