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
impl StructuralPartialEq for Header
Auto Trait Implementations
impl Freeze for Header
impl RefUnwindSafe for Header
impl Send for Header
impl Sync for Header
impl Unpin for Header
impl UnsafeUnpin for Header
impl UnwindSafe for Header
Blanket Implementations
impl<T> Any for Header
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Header
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Header
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Header
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Header
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Header
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for Header
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Header
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Header
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>