Struct Header
pub struct Header { pub width: u32, pub height: u32, pub channels: Channels, pub colorspace: ColorSpace }
Image header: dimensions, channels, color space.
Notes
A valid image header must satisfy the following conditions:
- Both width and height must be non-zero.
- Maximum number of pixels is 400Mp (=4e8 pixels).
Fields
width: u32Image width in pixels
height: u32Image height in pixels
channels: ChannelsNumber of 8-bit channels per pixel
colorspace: ColorSpaceColor space (informative field, doesn't affect encoding)
Implementations
impl Header
const fn try_new(width: u32, height: u32, channels: Channels, colorspace: ColorSpace) -> Result<Self>Creates a new header and validates image dimensions.
const fn with_channels(self, channels: Channels) -> SelfCreates a new header with modified channels.
const fn with_colorspace(self, colorspace: ColorSpace) -> SelfCreates a new header with modified color space.
const fn n_pixels(&self) -> usizeReturns a number of pixels in the image.
const fn n_bytes(&self) -> usizeReturns the total number of bytes in the raw pixel array.
This may come useful when pre-allocating a buffer to decode the image into.
fn encode_max_len(&self) -> usizeThe maximum number of bytes the encoded image will take.
Can be used to pre-allocate the buffer to encode the image into.
Trait Implementations
impl Clone for Header
fn clone(&self) -> Self
impl Copy for Header
impl Debug for Header
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Default for Header
fn default() -> Self
impl Eq for Header
impl Hash for Header
fn hash<__H: Hasher>(&self, state: &mut __H)
impl PartialEq for Header
fn eq(&self, other: &Self) -> bool