Skip to main content

PixelDescriptor

Struct PixelDescriptor 

Source
#[non_exhaustive]
pub struct PixelDescriptor { pub format: PixelFormat, pub transfer: TransferFunction, pub alpha: Option<AlphaMode>, pub primaries: ColorPrimaries, pub signal_range: SignalRange, }
Expand description

Compact pixel format descriptor.

Combines a PixelFormat (physical pixel layout) with transfer function, alpha mode, color primaries, and signal range.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§format: PixelFormat

Physical pixel format (channel type + layout as a flat enum).

§transfer: TransferFunction

Electro-optical transfer function.

§alpha: Option<AlphaMode>

Alpha interpretation. None = no alpha channel.

§primaries: ColorPrimaries

Color primaries (gamut). Defaults to BT.709/sRGB.

§signal_range: SignalRange

Signal range (full vs narrow/limited).

Implementations§

Source§

impl PixelDescriptor

Source

pub const RGB8_SRGB: PixelDescriptor

8-bit sRGB RGB.

Source

pub const RGBA8_SRGB: PixelDescriptor

8-bit sRGB RGBA with straight alpha.

Source

pub const RGB16_SRGB: PixelDescriptor

16-bit sRGB RGB.

Source

pub const RGBA16_SRGB: PixelDescriptor

16-bit sRGB RGBA with straight alpha.

Source

pub const RGBF32_LINEAR: PixelDescriptor

Linear-light f32 RGB.

Source

pub const RGBAF32_LINEAR: PixelDescriptor

Linear-light f32 RGBA with straight alpha.

Source

pub const GRAY8_SRGB: PixelDescriptor

8-bit sRGB grayscale.

Source

pub const GRAY16_SRGB: PixelDescriptor

16-bit sRGB grayscale.

Source

pub const GRAYF32_LINEAR: PixelDescriptor

Linear-light f32 grayscale.

Source

pub const GRAYA8_SRGB: PixelDescriptor

8-bit sRGB grayscale with straight alpha.

Source

pub const GRAYA16_SRGB: PixelDescriptor

16-bit sRGB grayscale with straight alpha.

Source

pub const GRAYAF32_LINEAR: PixelDescriptor

Linear-light f32 grayscale with straight alpha.

Source

pub const BGRA8_SRGB: PixelDescriptor

8-bit sRGB BGRA with straight alpha.

Source

pub const RGBX8_SRGB: PixelDescriptor

8-bit sRGB RGBX (padding byte, not alpha).

Source

pub const BGRX8_SRGB: PixelDescriptor

8-bit sRGB BGRX (padding byte, not alpha).

Source

pub const RGB8: PixelDescriptor

8-bit RGB, transfer unknown.

Source

pub const RGBA8: PixelDescriptor

8-bit RGBA, transfer unknown.

Source

pub const RGB16: PixelDescriptor

16-bit RGB, transfer unknown.

Source

pub const RGBA16: PixelDescriptor

16-bit RGBA, transfer unknown.

Source

pub const RGBF32: PixelDescriptor

f32 RGB, transfer unknown.

Source

pub const RGBAF32: PixelDescriptor

f32 RGBA, transfer unknown.

Source

pub const GRAY8: PixelDescriptor

8-bit grayscale, transfer unknown.

Source

pub const GRAY16: PixelDescriptor

16-bit grayscale, transfer unknown.

Source

pub const GRAYF32: PixelDescriptor

f32 grayscale, transfer unknown.

Source

pub const GRAYA8: PixelDescriptor

8-bit grayscale with alpha, transfer unknown.

Source

pub const GRAYA16: PixelDescriptor

16-bit grayscale with alpha, transfer unknown.

Source

pub const GRAYAF32: PixelDescriptor

f32 grayscale with alpha, transfer unknown.

Source

pub const BGRA8: PixelDescriptor

8-bit BGRA, transfer unknown.

Source

pub const RGBX8: PixelDescriptor

8-bit RGBX, transfer unknown.

Source

pub const BGRX8: PixelDescriptor

8-bit BGRX, transfer unknown.

Source

pub const OKLABF32: PixelDescriptor

Oklab f32 (L, a, b), transfer unknown.

Source

pub const OKLABAF32: PixelDescriptor

Oklab+alpha f32 (L, a, b, alpha), transfer unknown.

Source

pub const fn pixel_format(&self) -> PixelFormat

The pixel format variant (layout + depth, no transfer or alpha semantics).

Source

pub const fn channel_type(&self) -> ChannelType

Channel storage type.

Source

pub const fn alpha(&self) -> Option<AlphaMode>

Alpha interpretation. None = no alpha channel.

Source

pub const fn transfer(&self) -> TransferFunction

Transfer function.

Source

pub const fn byte_order(&self) -> ByteOrder

Byte order.

Source

pub const fn color_model(&self) -> ColorModel

Color model.

Source

pub const fn layout(&self) -> ChannelLayout

Channel layout (derived from the PixelFormat variant).

Source

pub const fn new( channel_type: ChannelType, layout: ChannelLayout, alpha: Option<AlphaMode>, transfer: TransferFunction, ) -> PixelDescriptor

Create a descriptor with default primaries (BT.709) and full range.

§Panics

Panics if the (channel_type, layout, alpha) combination has no corresponding PixelFormat variant (e.g. (U16, Bgra, _)).

Source

pub const fn new_full( channel_type: ChannelType, layout: ChannelLayout, alpha: Option<AlphaMode>, transfer: TransferFunction, primaries: ColorPrimaries, ) -> PixelDescriptor

Create a descriptor with explicit primaries.

§Panics

Panics if the (channel_type, layout, alpha) combination has no corresponding PixelFormat variant.

Source

pub const fn from_pixel_format(format: PixelFormat) -> PixelDescriptor

Create from a PixelFormat with default alpha, unknown transfer, BT.709 primaries, and full range.

Source

pub const fn channels(self) -> usize

Number of channels.

Source

pub const fn bytes_per_pixel(self) -> usize

Bytes per pixel.

Source

pub const fn has_alpha(self) -> bool

Whether this descriptor has meaningful alpha data.

Source

pub const fn is_grayscale(self) -> bool

Whether this descriptor is grayscale.

Source

pub const fn is_bgr(self) -> bool

Whether this descriptor uses BGR byte order.

Source

pub const fn with_transfer(self, transfer: TransferFunction) -> PixelDescriptor

Return a copy with a different transfer function.

Source

pub const fn with_primaries(self, primaries: ColorPrimaries) -> PixelDescriptor

Return a copy with different primaries.

Source

pub const fn with_alpha(self, alpha: Option<AlphaMode>) -> PixelDescriptor

Return a copy with a different alpha mode.

Source

pub const fn with_alpha_mode(self, alpha: Option<AlphaMode>) -> PixelDescriptor

Alias for with_alpha.

Source

pub const fn with_signal_range( self, signal_range: SignalRange, ) -> PixelDescriptor

Return a copy with a different signal range.

Source

pub const fn is_opaque(self) -> bool

Whether this format is fully opaque (no transparency possible).

Returns true when there is no alpha channel (None), the alpha bytes are undefined padding (Undefined), or alpha is all-255 (Opaque).

Source

pub const fn may_have_transparency(self) -> bool

Whether this format may contain transparent pixels.

Returns true for Straight and Premultiplied.

Source

pub const fn is_linear(self) -> bool

Whether the transfer function is Linear.

Source

pub const fn is_unknown_transfer(self) -> bool

Whether the transfer function is Unknown.

Source

pub const fn min_alignment(self) -> usize

Minimum byte alignment required for the channel type (1, 2, or 4).

Source

pub const fn aligned_stride(self, width: u32) -> usize

Tightly-packed byte stride for a given width.

Source

pub const fn simd_aligned_stride(self, width: u32, simd_align: usize) -> usize

SIMD-friendly byte stride for a given width.

The stride is a multiple of lcm(bytes_per_pixel, simd_align), ensuring every row start is both pixel-aligned and SIMD-aligned. simd_align must be a power of 2.

Source

pub const fn layout_compatible(self, other: PixelDescriptor) -> bool

Whether this descriptor’s channel type and layout are compatible with other.

“Compatible” means the raw bytes can be reinterpreted as other without any pixel transformation — same channel type, same layout.

Trait Implementations§

Source§

impl Clone for PixelDescriptor

Source§

fn clone(&self) -> PixelDescriptor

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 PixelDescriptor

Source§

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

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

impl Display for PixelDescriptor

Source§

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

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

impl From<PixelDescriptor> for FormatOption

Source§

fn from(descriptor: PixelDescriptor) -> Self

Converts to this type from the input type.
Source§

impl Hash for PixelDescriptor

Source§

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

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 PixelDescriptor

Source§

fn eq(&self, other: &PixelDescriptor) -> 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 PixelDescriptor

Source§

impl Eq for PixelDescriptor

Source§

impl StructuralPartialEq for PixelDescriptor

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.