pub struct DecodedImage { /* private fields */ }Expand description
A decoded PNG image.
data holds the pixels in PNG’s own layout, de-interlaced:
rows top to bottom, each row_bytes long; samples of
fewer than 8 bits packed most significant bits first; 16-bit samples as
big-endian byte pairs; indexed images as palette indices. Use
to_rgba8 or to_rgba16 for
uniform RGBA pixels with palette and transparency applied.
Implementations§
Source§impl DecodedImage
impl DecodedImage
Sourcepub const fn color_type(&self) -> ColorType
pub const fn color_type(&self) -> ColorType
Colour type as stored in the file.
Sourcepub const fn is_interlaced(&self) -> bool
pub const fn is_interlaced(&self) -> bool
Whether the file was Adam7-interlaced.
Sourcepub fn palette(&self) -> Option<&[[u8; 4]]>
pub fn palette(&self) -> Option<&[[u8; 4]]>
The palette of an indexed image as RGBA entries, with alpha from
tRNS (255 where it gives none).
Sourcepub const fn color_key(&self) -> Option<ColorKey>
pub const fn color_key(&self) -> Option<ColorKey>
The transparent colour of a greyscale or RGB image, if any.
Sourcepub fn to_rgba8(&self) -> Vec<u8> ⓘ
pub fn to_rgba8(&self) -> Vec<u8> ⓘ
The pixels as 8-bit RGBA, 4 bytes per pixel.
Grey is replicated into R, G and B; samples below 8 bits are scaled up exactly (e.g. 4-bit 15 becomes 255); 16-bit samples are rounded to the nearest 8-bit value. Alpha comes from the alpha channel, from the colour key (0 for matching pixels) or from the palette, and is 255 otherwise. Palette indices beyond the palette yield opaque black.