Skip to main content

PixelFormat

Enum PixelFormat 

Source
#[non_exhaustive]
#[repr(u16)]
pub enum PixelFormat {
Show 35 variants Yuv420P = 0, Yuv422P = 1, Yuv444P = 2, Rgb24 = 3, Rgba = 4, Gray8 = 5, Pal8 = 6, Bgr24 = 7, Bgra = 8, Argb = 9, Abgr = 10, Rgb48Le = 11, Rgba64Le = 12, Gray16Le = 13, Gray10Le = 14, Gray12Le = 15, Yuv420P10Le = 16, Yuv422P10Le = 17, Yuv444P10Le = 18, Yuv420P12Le = 19, Yuv422P12Le = 20, Yuv444P12Le = 21, YuvJ420P = 22, YuvJ422P = 23, YuvJ444P = 24, Nv12 = 25, Nv21 = 26, Ya8 = 27, Yuva420P = 28, MonoBlack = 29, MonoWhite = 30, Yuyv422 = 31, Uyvy422 = 32, Cmyk = 33, Yuv411P = 34,
}
Expand description

Video pixel format.

Variants carry stable explicit discriminants — the integer value of PixelFormat::Yuv420P as u16 is part of the public ABI. Add new variants only at the end with a fresh number; never reorder, renumber, or remove. #[non_exhaustive] lets the enum grow without breaking downstream match statements; pinned discriminants additionally let the format round-trip through any byte-stable serialization (config files, capability blobs, IPC, on-disk caches) without losing meaning across crate versions, and prevent inserts in the middle of the enum from shifting every later variant’s number (which cargo-semver-checks rightly flags as a breaking change).

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).

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 = 0

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

§

Yuv422P = 1

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

§

Yuv444P = 2

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

§

Rgb24 = 3

Packed 8-bit RGB, 3 bytes/pixel.

§

Rgba = 4

Packed 8-bit RGBA, 4 bytes/pixel.

§

Gray8 = 5

Packed 8-bit grayscale.

§

Pal8 = 6

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

§

Bgr24 = 7

Packed 8-bit BGR, 3 bytes/pixel.

§

Bgra = 8

Packed 8-bit BGRA, 4 bytes/pixel.

§

Argb = 9

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

§

Abgr = 10

Packed 8-bit ABGR, 4 bytes/pixel.

§

Rgb48Le = 11

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

§

Rgba64Le = 12

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

§

Gray16Le = 13

16-bit little-endian grayscale.

§

Gray10Le = 14

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

§

Gray12Le = 15

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

§

Yuv420P10Le = 16

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

§

Yuv422P10Le = 17

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

§

Yuv444P10Le = 18

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

§

Yuv420P12Le = 19

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

§

Yuv422P12Le = 20

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

§

Yuv444P12Le = 21

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

§

YuvJ420P = 22

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

§

YuvJ422P = 23

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

§

YuvJ444P = 24

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

§

Nv12 = 25

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

§

Nv21 = 26

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

§

Ya8 = 27

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

§

Yuva420P = 28

Yuv420P with an additional full-resolution alpha plane.

§

MonoBlack = 29

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

§

MonoWhite = 30

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

§

Yuyv422 = 31

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

§

Uyvy422 = 32

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

§

Cmyk = 33

Packed 8-bit CMYK, 4 bytes/pixel in byte order C, M, Y, K. “Regular” convention: C=0 means no cyan ink (white), C=255 means full cyan. Used by JPEG 4-component scans from non-Adobe encoders and by many print-side image toolchains. Adobe Photoshop’s inverted CMYK (where 0 = full ink) is a separate variant reserved for a future CmykInverted.

§

Yuv411P = 34

8-bit YUV 4:1:1, planar (Y, U, V). Luma at full resolution; chroma horizontally subsampled by 4 (each chroma sample covers a 4×1 luma block), no vertical subsampling. Native sampling of NTSC DV-25 and a legal JPEG sampling layout (luma H=4, V=1; chroma H=V=1) emitted by some real-world JPEG corpora.

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.