Skip to main content

PixelFormat

Enum PixelFormat 

Source
#[non_exhaustive]
pub enum PixelFormat {
Show 31 variants Yuv420P, Yuv422P, Yuv444P, Rgb24, Rgba, Gray8, Pal8, Bgr24, Bgra, Argb, Abgr, Rgb48Le, Rgba64Le, Gray16Le, Gray10Le, Gray12Le, Yuv420P10Le, Yuv422P10Le, Yuv444P10Le, Yuv420P12Le, YuvJ420P, YuvJ422P, YuvJ444P, Nv12, Nv21, Ya8, Yuva420P, MonoBlack, MonoWhite, Yuyv422, Uyvy422,
}
Expand description

Video pixel format.

The first six variants (Yuv420P through Gray8) are the original formats produced by the early codec crates. Everything beyond that is additional surface handled by oxideav-pixfmt and the still-image codecs (PNG, GIF, still-JPEG). The enum is #[non_exhaustive] so new variants can land without breaking downstream crates — consumers that match must include a wildcard arm.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Yuv420P

8-bit YUV 4:2:0, planar (Y, U, V).

§

Yuv422P

8-bit YUV 4:2:2, planar.

§

Yuv444P

8-bit YUV 4:4:4, planar.

§

Rgb24

Packed 8-bit RGB, 3 bytes/pixel.

§

Rgba

Packed 8-bit RGBA, 4 bytes/pixel.

§

Gray8

Packed 8-bit grayscale.

§

Pal8

8-bit palette indices — companion palette carried out of band.

§

Bgr24

Packed 8-bit BGR, 3 bytes/pixel.

§

Bgra

Packed 8-bit BGRA, 4 bytes/pixel.

§

Argb

Packed 8-bit ARGB, 4 bytes/pixel (alpha first).

§

Abgr

Packed 8-bit ABGR, 4 bytes/pixel.

§

Rgb48Le

Packed 16-bit-per-channel RGB, little-endian, 6 bytes/pixel.

§

Rgba64Le

Packed 16-bit-per-channel RGBA, little-endian, 8 bytes/pixel.

§

Gray16Le

16-bit little-endian grayscale.

§

Gray10Le

10-bit grayscale in a 16-bit little-endian word.

§

Gray12Le

12-bit grayscale in a 16-bit little-endian word.

§

Yuv420P10Le

10-bit YUV 4:2:0 planar, little-endian 16-bit storage.

§

Yuv422P10Le

10-bit YUV 4:2:2 planar, little-endian 16-bit storage.

§

Yuv444P10Le

10-bit YUV 4:4:4 planar, little-endian 16-bit storage.

§

Yuv420P12Le

12-bit YUV 4:2:0 planar, little-endian 16-bit storage.

§

YuvJ420P

JPEG/full-range YUV 4:2:0 planar.

§

YuvJ422P

JPEG/full-range YUV 4:2:2 planar.

§

YuvJ444P

JPEG/full-range YUV 4:4:4 planar.

§

Nv12

YUV 4:2:0, planar Y + interleaved UV (NV12).

§

Nv21

YUV 4:2:0, planar Y + interleaved VU (NV21).

§

Ya8

Packed grayscale + alpha, 2 bytes/pixel (Y, A).

§

Yuva420P

Yuv420P with an additional full-resolution alpha plane.

§

MonoBlack

1 bit per pixel, packed MSB-first, 0 = black.

§

MonoWhite

1 bit per pixel, packed MSB-first, 0 = white.

§

Yuyv422

Packed 4:2:2, byte order Y0 U0 Y1 V0.

§

Uyvy422

Packed 4:2:2, byte order U0 Y0 V0 Y1.

Implementations§

Source§

impl PixelFormat

Source

pub fn is_planar(&self) -> bool

True if this format stores its components in separate planes.

Source

pub fn is_palette(&self) -> bool

True if the format is a palette index format (Pal8).

Source

pub fn has_alpha(&self) -> bool

True if this format carries an alpha channel.

Source

pub fn plane_count(&self) -> usize

Number of planes in the stored layout. Packed and palette formats return 1; NV12/NV21 return 2; planar YUV without alpha returns 3; YuvA variants return 4.

Source

pub fn bits_per_pixel_approx(&self) -> u32

Rough bits-per-pixel estimate, useful for buffer sizing. Not exact for chroma-subsampled YUV — intended for worst-case preallocation rather than wire-accurate accounting.

Trait Implementations§

Source§

impl Clone for PixelFormat

Source§

fn clone(&self) -> PixelFormat

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PixelFormat

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for PixelFormat

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for PixelFormat

Source§

fn eq(&self, other: &PixelFormat) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for PixelFormat

Source§

impl Eq for PixelFormat

Source§

impl StructuralPartialEq for PixelFormat

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.