pub struct ImageData { /* private fields */ }Expand description
A decoded or passthrough image ready to embed as an image XObject.
Implementations§
Source§impl ImageData
impl ImageData
Sourcepub fn png(bytes: &[u8]) -> Result<ImageData>
pub fn png(bytes: &[u8]) -> Result<ImageData>
Imports a PNG. A non-interlaced image without alpha or tRNS, at
most 8 bits deep, keeps its compressed pixel data untouched. Anything
else is decoded: truecolor and grayscale (16-bit reduced to 8),
palette (expanded), and alpha (split to /SMask).
Sourcepub fn jpeg(bytes: &[u8]) -> Result<ImageData>
pub fn jpeg(bytes: &[u8]) -> Result<ImageData>
Imports a baseline or progressive JPEG by passthrough. Dimensions and component count are read from the SOF marker; grayscale and three-component (YCbCr/RGB) images are supported, anything else is an error.
Sourcepub fn decode(bytes: &[u8]) -> Result<ImageData>
pub fn decode(bytes: &[u8]) -> Result<ImageData>
Imports a PNG or JPEG, dispatched by content rather than by file
extension: a PNG signature selects ImageData::png, a JPEG SOI
marker selects ImageData::jpeg, anything else is an error.
Sourcepub fn gray8(width: u32, height: u32, data: Vec<u8>) -> Result<ImageData>
pub fn gray8(width: u32, height: u32, data: Vec<u8>) -> Result<ImageData>
Wraps an 8-bit grayscale raster; data is width * height bytes.
Sourcepub fn rgb8(width: u32, height: u32, data: Vec<u8>) -> Result<ImageData>
pub fn rgb8(width: u32, height: u32, data: Vec<u8>) -> Result<ImageData>
Wraps an 8-bit RGB raster; data is width * height * 3 bytes.