#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.format: PixelFormatPhysical pixel format (channel type + layout as a flat enum).
transfer: TransferFunctionElectro-optical transfer function.
alpha: Option<AlphaMode>Alpha interpretation. None = no alpha channel.
primaries: ColorPrimariesColor primaries (gamut). Defaults to BT.709/sRGB.
signal_range: SignalRangeSignal range (full vs narrow/limited).
Implementations§
Source§impl PixelDescriptor
impl PixelDescriptor
Sourcepub const RGB8_SRGB: PixelDescriptor
pub const RGB8_SRGB: PixelDescriptor
8-bit sRGB RGB.
Sourcepub const RGBA8_SRGB: PixelDescriptor
pub const RGBA8_SRGB: PixelDescriptor
8-bit sRGB RGBA with straight alpha.
Sourcepub const RGB16_SRGB: PixelDescriptor
pub const RGB16_SRGB: PixelDescriptor
16-bit sRGB RGB.
Sourcepub const RGBA16_SRGB: PixelDescriptor
pub const RGBA16_SRGB: PixelDescriptor
16-bit sRGB RGBA with straight alpha.
Sourcepub const RGBF32_LINEAR: PixelDescriptor
pub const RGBF32_LINEAR: PixelDescriptor
Linear-light f32 RGB.
Sourcepub const RGBAF32_LINEAR: PixelDescriptor
pub const RGBAF32_LINEAR: PixelDescriptor
Linear-light f32 RGBA with straight alpha.
Sourcepub const GRAY8_SRGB: PixelDescriptor
pub const GRAY8_SRGB: PixelDescriptor
8-bit sRGB grayscale.
Sourcepub const GRAY16_SRGB: PixelDescriptor
pub const GRAY16_SRGB: PixelDescriptor
16-bit sRGB grayscale.
Sourcepub const GRAYF32_LINEAR: PixelDescriptor
pub const GRAYF32_LINEAR: PixelDescriptor
Linear-light f32 grayscale.
Sourcepub const GRAYA8_SRGB: PixelDescriptor
pub const GRAYA8_SRGB: PixelDescriptor
8-bit sRGB grayscale with straight alpha.
Sourcepub const GRAYA16_SRGB: PixelDescriptor
pub const GRAYA16_SRGB: PixelDescriptor
16-bit sRGB grayscale with straight alpha.
Sourcepub const GRAYAF32_LINEAR: PixelDescriptor
pub const GRAYAF32_LINEAR: PixelDescriptor
Linear-light f32 grayscale with straight alpha.
Sourcepub const BGRA8_SRGB: PixelDescriptor
pub const BGRA8_SRGB: PixelDescriptor
8-bit sRGB BGRA with straight alpha.
Sourcepub const RGBX8_SRGB: PixelDescriptor
pub const RGBX8_SRGB: PixelDescriptor
8-bit sRGB RGBX (padding byte, not alpha).
Sourcepub const BGRX8_SRGB: PixelDescriptor
pub const BGRX8_SRGB: PixelDescriptor
8-bit sRGB BGRX (padding byte, not alpha).
Sourcepub const RGB8: PixelDescriptor
pub const RGB8: PixelDescriptor
8-bit RGB, transfer unknown.
Sourcepub const RGBA8: PixelDescriptor
pub const RGBA8: PixelDescriptor
8-bit RGBA, transfer unknown.
Sourcepub const RGB16: PixelDescriptor
pub const RGB16: PixelDescriptor
16-bit RGB, transfer unknown.
Sourcepub const RGBA16: PixelDescriptor
pub const RGBA16: PixelDescriptor
16-bit RGBA, transfer unknown.
Sourcepub const RGBF32: PixelDescriptor
pub const RGBF32: PixelDescriptor
f32 RGB, transfer unknown.
Sourcepub const RGBAF32: PixelDescriptor
pub const RGBAF32: PixelDescriptor
f32 RGBA, transfer unknown.
Sourcepub const GRAY8: PixelDescriptor
pub const GRAY8: PixelDescriptor
8-bit grayscale, transfer unknown.
Sourcepub const GRAY16: PixelDescriptor
pub const GRAY16: PixelDescriptor
16-bit grayscale, transfer unknown.
Sourcepub const GRAYF32: PixelDescriptor
pub const GRAYF32: PixelDescriptor
f32 grayscale, transfer unknown.
Sourcepub const GRAYA8: PixelDescriptor
pub const GRAYA8: PixelDescriptor
8-bit grayscale with alpha, transfer unknown.
Sourcepub const GRAYA16: PixelDescriptor
pub const GRAYA16: PixelDescriptor
16-bit grayscale with alpha, transfer unknown.
Sourcepub const GRAYAF32: PixelDescriptor
pub const GRAYAF32: PixelDescriptor
f32 grayscale with alpha, transfer unknown.
Sourcepub const BGRA8: PixelDescriptor
pub const BGRA8: PixelDescriptor
8-bit BGRA, transfer unknown.
Sourcepub const RGBX8: PixelDescriptor
pub const RGBX8: PixelDescriptor
8-bit RGBX, transfer unknown.
Sourcepub const BGRX8: PixelDescriptor
pub const BGRX8: PixelDescriptor
8-bit BGRX, transfer unknown.
Sourcepub const OKLABF32: PixelDescriptor
pub const OKLABF32: PixelDescriptor
Oklab f32 (L, a, b), transfer unknown.
Sourcepub const OKLABAF32: PixelDescriptor
pub const OKLABAF32: PixelDescriptor
Oklab+alpha f32 (L, a, b, alpha), transfer unknown.
Sourcepub const fn pixel_format(&self) -> PixelFormat
pub const fn pixel_format(&self) -> PixelFormat
The pixel format variant (layout + depth, no transfer or alpha semantics).
Sourcepub const fn channel_type(&self) -> ChannelType
pub const fn channel_type(&self) -> ChannelType
Channel storage type.
Sourcepub const fn transfer(&self) -> TransferFunction
pub const fn transfer(&self) -> TransferFunction
Transfer function.
Sourcepub const fn byte_order(&self) -> ByteOrder
pub const fn byte_order(&self) -> ByteOrder
Byte order.
Sourcepub const fn color_model(&self) -> ColorModel
pub const fn color_model(&self) -> ColorModel
Color model.
Sourcepub const fn layout(&self) -> ChannelLayout
pub const fn layout(&self) -> ChannelLayout
Channel layout (derived from the PixelFormat variant).
Sourcepub const fn new(
channel_type: ChannelType,
layout: ChannelLayout,
alpha: Option<AlphaMode>,
transfer: TransferFunction,
) -> PixelDescriptor
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, _)).
Sourcepub const fn new_full(
channel_type: ChannelType,
layout: ChannelLayout,
alpha: Option<AlphaMode>,
transfer: TransferFunction,
primaries: ColorPrimaries,
) -> PixelDescriptor
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.
Sourcepub const fn from_pixel_format(format: PixelFormat) -> PixelDescriptor
pub const fn from_pixel_format(format: PixelFormat) -> PixelDescriptor
Create from a PixelFormat with default alpha, unknown transfer,
BT.709 primaries, and full range.
Sourcepub const fn bytes_per_pixel(self) -> usize
pub const fn bytes_per_pixel(self) -> usize
Bytes per pixel.
Sourcepub const fn is_grayscale(self) -> bool
pub const fn is_grayscale(self) -> bool
Whether this descriptor is grayscale.
Sourcepub const fn with_transfer(self, transfer: TransferFunction) -> PixelDescriptor
pub const fn with_transfer(self, transfer: TransferFunction) -> PixelDescriptor
Return a copy with a different transfer function.
Sourcepub const fn with_primaries(self, primaries: ColorPrimaries) -> PixelDescriptor
pub const fn with_primaries(self, primaries: ColorPrimaries) -> PixelDescriptor
Return a copy with different primaries.
Sourcepub const fn with_alpha(self, alpha: Option<AlphaMode>) -> PixelDescriptor
pub const fn with_alpha(self, alpha: Option<AlphaMode>) -> PixelDescriptor
Return a copy with a different alpha mode.
Sourcepub const fn with_alpha_mode(self, alpha: Option<AlphaMode>) -> PixelDescriptor
pub const fn with_alpha_mode(self, alpha: Option<AlphaMode>) -> PixelDescriptor
Alias for with_alpha.
Sourcepub const fn with_signal_range(
self,
signal_range: SignalRange,
) -> PixelDescriptor
pub const fn with_signal_range( self, signal_range: SignalRange, ) -> PixelDescriptor
Return a copy with a different signal range.
Sourcepub const fn is_opaque(self) -> bool
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).
Sourcepub const fn may_have_transparency(self) -> bool
pub const fn may_have_transparency(self) -> bool
Whether this format may contain transparent pixels.
Returns true for Straight and
Premultiplied.
Sourcepub const fn is_unknown_transfer(self) -> bool
pub const fn is_unknown_transfer(self) -> bool
Whether the transfer function is Unknown.
Sourcepub const fn min_alignment(self) -> usize
pub const fn min_alignment(self) -> usize
Minimum byte alignment required for the channel type (1, 2, or 4).
Sourcepub const fn aligned_stride(self, width: u32) -> usize
pub const fn aligned_stride(self, width: u32) -> usize
Tightly-packed byte stride for a given width.
Sourcepub const fn simd_aligned_stride(self, width: u32, simd_align: usize) -> usize
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.
Sourcepub const fn layout_compatible(self, other: PixelDescriptor) -> bool
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
impl Clone for PixelDescriptor
Source§fn clone(&self) -> PixelDescriptor
fn clone(&self) -> PixelDescriptor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more