pub struct GrayImage { /* private fields */ }scan only.Expand description
An 8-bit greyscale image: what a scanner actually works on.
Colour carries no information a barcode reader wants, so every input is
reduced to luminance on the way in. Transparent pixels are composited over
white first, because a barcode rendered with
Color::TRANSPARENT as its background is
black ink on nothing, and “nothing” prints as paper.
Implementations§
Source§impl GrayImage
impl GrayImage
Sourcepub fn from_luma(width: u32, height: u32, luma: Vec<u8>) -> Result<Self>
pub fn from_luma(width: u32, height: u32, luma: Vec<u8>) -> Result<Self>
Wrap an existing 8-bit luminance buffer, one byte per pixel.
§Errors
Returns Error::InvalidImage if either dimension is zero, if the
buffer length is not exactly width * height, or if the image is
larger than the crate’s pixel-count limit.
Sourcepub fn from_png(bytes: &[u8]) -> Result<Self>
Available on crate feature png only.
pub fn from_png(bytes: &[u8]) -> Result<Self>
png only.Decode a PNG image.
Handles every colour type and bit depth the png crate can normalise
to 8 bits, including palettes and greyscale.
§Errors
Returns Error::InvalidImage if the bytes are not a PNG this crate
can read, or if the image exceeds the pixel-count limit.
Sourcepub fn from_png_file(path: impl AsRef<Path>) -> Result<Self>
Available on crate features png and std only.
pub fn from_png_file(path: impl AsRef<Path>) -> Result<Self>
png and std only.