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:

Fields

width: u32

Image width in pixels

height: u32

Image height in pixels

channels: Channels

Number of 8-bit channels per pixel

colorspace: ColorSpace

Color 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) -> Self

Creates a new header with modified channels.

const fn with_colorspace(self, colorspace: ColorSpace) -> Self

Creates a new header with modified color space.

const fn n_pixels(&self) -> usize

Returns a number of pixels in the image.

const fn n_bytes(&self) -> usize

Returns 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) -> usize

The 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) -> T

Returns the argument unchanged.

impl<T> ToOwned for Header where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for Header where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses 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>