#[non_exhaustive]pub struct PixelFormat { /* private fields */ }Expand description
Complete, validated description of an interleaved pixel: physical SampleLayout + algebraic ColorSpace.
Implementations§
Source§impl PixelFormat
impl PixelFormat
Sourcepub const RGB8_SRGB: PixelFormat
pub const RGB8_SRGB: PixelFormat
8-bit sRGB RGB (RGB8).
For a 'static borrowed reference (&'static PixelFormat) in PixelView::new,
borrow &formats::RGB8_SRGB.
Sourcepub const RGBA8_SRGB: PixelFormat
pub const RGBA8_SRGB: PixelFormat
8-bit sRGB RGBA straight alpha (RGBA8). Borrow &formats::RGBA8_SRGB for views.
Sourcepub const BGR8_SRGB: PixelFormat
pub const BGR8_SRGB: PixelFormat
8-bit sRGB BGR (BGR8). Borrow &formats::BGR8_SRGB for views.
Sourcepub const BGRA8_SRGB: PixelFormat
pub const BGRA8_SRGB: PixelFormat
8-bit sRGB BGRA straight alpha (BGRA8). Borrow &formats::BGRA8_SRGB for views.
Sourcepub const RGBX8_SRGB: PixelFormat
pub const RGBX8_SRGB: PixelFormat
8-bit sRGB RGBx (4th byte undefined padding). Borrow &formats::RGBX8_SRGB for views.
Sourcepub const BGRX8_SRGB: PixelFormat
pub const BGRX8_SRGB: PixelFormat
8-bit sRGB BGRx (4th byte undefined padding). Borrow &formats::BGRX8_SRGB for views.
Sourcepub const RGB16_SRGB: PixelFormat
pub const RGB16_SRGB: PixelFormat
16-bit sRGB RGB (RGB16). Borrow &formats::RGB16_SRGB for views.
Sourcepub const RGBA16_SRGB: PixelFormat
pub const RGBA16_SRGB: PixelFormat
16-bit sRGB RGBA straight alpha (RGBA16). Borrow &formats::RGBA16_SRGB for views.
Sourcepub const RGB8_DISPLAY_P3: PixelFormat
pub const RGB8_DISPLAY_P3: PixelFormat
8-bit full-range Display P3 RGB with the sRGB transfer curve. Borrow &formats::RGB8_DISPLAY_P3 for views.
Sourcepub const RGB16_DISPLAY_P3: PixelFormat
pub const RGB16_DISPLAY_P3: PixelFormat
16-bit full-range Display P3 RGB with the sRGB transfer curve. Borrow &formats::RGB16_DISPLAY_P3 for views.
Sourcepub const RGBA8_DISPLAY_P3: PixelFormat
pub const RGBA8_DISPLAY_P3: PixelFormat
8-bit full-range Display P3 RGBA with straight alpha and the sRGB transfer curve.
Borrow &formats::RGBA8_DISPLAY_P3 for views.
Sourcepub const RGBA16_DISPLAY_P3: PixelFormat
pub const RGBA16_DISPLAY_P3: PixelFormat
16-bit full-range Display P3 RGBA with straight alpha and the sRGB transfer curve.
Borrow &formats::RGBA16_DISPLAY_P3 for views.
Sourcepub const RGBF32_LINEAR: PixelFormat
pub const RGBF32_LINEAR: PixelFormat
32-bit float linear RGB (RGBF32). Borrow &formats::RGBF32_LINEAR for views.
Sourcepub const RGBAF32_LINEAR: PixelFormat
pub const RGBAF32_LINEAR: PixelFormat
32-bit float linear RGBA straight alpha (RGBAF32). Borrow &formats::RGBAF32_LINEAR for views.
Sourcepub const RGBF16_LINEAR: PixelFormat
pub const RGBF16_LINEAR: PixelFormat
16-bit half-float linear RGB (RGBF16). Borrow &formats::RGBF16_LINEAR for views.
Sourcepub const RGBAF16_LINEAR: PixelFormat
pub const RGBAF16_LINEAR: PixelFormat
16-bit half-float linear RGBA straight alpha (RGBAF16). Borrow &formats::RGBAF16_LINEAR for views.
Sourcepub const GRAY8_SRGB: PixelFormat
pub const GRAY8_SRGB: PixelFormat
8-bit sRGB grayscale (GRAY8). Borrow &formats::GRAY8_SRGB for views.
Sourcepub const GRAYA8_SRGB: PixelFormat
pub const GRAYA8_SRGB: PixelFormat
8-bit sRGB grayscale + straight alpha (GRAYA8). Borrow &formats::GRAYA8_SRGB for views.
Sourcepub const GRAY16_SRGB: PixelFormat
pub const GRAY16_SRGB: PixelFormat
16-bit sRGB grayscale (GRAY16). Borrow &formats::GRAY16_SRGB for views.
Sourcepub const GRAYF32_LINEAR: PixelFormat
pub const GRAYF32_LINEAR: PixelFormat
32-bit float linear grayscale (GRAYF32). Borrow &formats::GRAYF32_LINEAR for views.
Sourcepub const RGB16_BT2100_PQ: PixelFormat
pub const RGB16_BT2100_PQ: PixelFormat
16-bit BT.2100 PQ HDR RGB (RGB16, BT.2020, ST 2084). Borrow &formats::RGB16_BT2100_PQ for views.
Sourcepub const RGB16_BT2100_HLG_SCENE: PixelFormat
pub const RGB16_BT2100_HLG_SCENE: PixelFormat
16-bit BT.2100 HLG HDR RGB, scene-referred. Borrow &formats::RGB16_BT2100_HLG_SCENE for views.
Sourcepub const RGB16_BT2100_HLG_1000: PixelFormat
pub const RGB16_BT2100_HLG_1000: PixelFormat
16-bit BT.2100 HLG HDR RGB with explicit 1000-nit reference rendering. Borrow &formats::RGB16_BT2100_HLG_1000 for views.
Sourcepub const OKLAB_F32: PixelFormat
pub const OKLAB_F32: PixelFormat
32-bit float Oklab (no alpha). Borrow &formats::OKLAB_F32 for views.
Sourcepub const OKLABA_F32: PixelFormat
pub const OKLABA_F32: PixelFormat
32-bit float Oklab + straight alpha. Borrow &formats::OKLABA_F32 for views.
Sourcepub const fn layout(&self) -> SampleLayout
pub const fn layout(&self) -> SampleLayout
Physical storage and channel layout.
Sourcepub const fn color(&self) -> &ColorSpace
pub const fn color(&self) -> &ColorSpace
Authoritative interpretation of the samples.
Sourcepub fn as_static_ref(&self) -> Option<&'static PixelFormat>
pub fn as_static_ref(&self) -> Option<&'static PixelFormat>
Return a 'static preset reference if self equals one of the built-in common specs.
Used by FormatCow::from_owned and interop bridges (from_pixels_with_color, from_imgref,
from_image_buffer) to avoid heap allocation for sRGB, Display P3, linear, HDR, and Oklab presets.
Sourcepub fn new(
layout: SampleLayout,
color: ColorSpace,
) -> Result<PixelFormat, At<ColorError>>
pub fn new( layout: SampleLayout, color: ColorSpace, ) -> Result<PixelFormat, At<ColorError>>
Construct a format after checking layout and color compatibility.
An attached active ICC profile is checked for structure and compatible channels.
Use ColorOrigin to retain raw container declarations independently of this format.
Sourcepub const fn new_const(layout: SampleLayout, color: ColorSpace) -> PixelFormat
pub const fn new_const(layout: SampleLayout, color: ColorSpace) -> PixelFormat
Construct a checked format in a constant.
Use Self::new for runtime input, ICC profiles, and owned custom RGB primaries.
For encoder capability tables, declare a const slice or borrow an array
in an inline const block.
§Panics
Panics if the layout and color are incompatible, or if the color contains an ICC profile or owned custom RGB primaries.
use zenpixels::{ColorSpace, PixelFormat, SampleLayout};
const CAPS: &[PixelFormat] = &[
PixelFormat::RGB8_DISPLAY_P3,
PixelFormat::new_const(SampleLayout::RGB16, ColorSpace::LINEAR_SRGB),
];
assert_eq!(CAPS[1].layout(), SampleLayout::RGB16);An incompatible layout and color fail constant evaluation.
use zenpixels::{ColorSpace, PixelFormat, SampleLayout};
const INVALID: PixelFormat =
PixelFormat::new_const(SampleLayout::RGBX8, ColorSpace::SRGB_ALPHA);Sourcepub fn cmyk8(icc: Option<Arc<[u8]>>) -> Result<PixelFormat, At<ColorError>>
pub fn cmyk8(icc: Option<Arc<[u8]>>) -> Result<PixelFormat, At<ColorError>>
8-bit CMYK (0 = no ink), checking any supplied CMYK ICC profile.
Sourcepub fn with_primaries(
self,
primaries: Primaries,
) -> Result<PixelFormat, At<ColorError>>
pub fn with_primaries( self, primaries: Primaries, ) -> Result<PixelFormat, At<ColorError>>
Replace RGB primaries, checking compatibility with the format. Other color models are unchanged.
Sourcepub fn try_with_primaries(self, primaries: Primaries) -> Option<PixelFormat>
pub fn try_with_primaries(self, primaries: Primaries) -> Option<PixelFormat>
Replace RGB primaries. Returns None for other models or incompatible primaries.
Sourcepub fn with_custom_primaries(
self,
primaries: CustomPrimaries,
) -> Result<PixelFormat, At<ColorError>>
pub fn with_custom_primaries( self, primaries: CustomPrimaries, ) -> Result<PixelFormat, At<ColorError>>
Replace RGB primaries with CustomPrimaries, checking format compatibility.
Sourcepub fn try_with_custom_primaries(
self,
primaries: CustomPrimaries,
) -> Option<PixelFormat>
pub fn try_with_custom_primaries( self, primaries: CustomPrimaries, ) -> Option<PixelFormat>
Replace RGB primaries with CustomPrimaries. Returns None for other models or incompatible primaries.
Sourcepub fn with_transfer(
self,
transfer: Transfer,
) -> Result<PixelFormat, At<ColorError>>
pub fn with_transfer( self, transfer: Transfer, ) -> Result<PixelFormat, At<ColorError>>
Replace the RGB or Gray transfer, checking compatibility with the format.
Sourcepub fn try_with_transfer(self, transfer: Transfer) -> Option<PixelFormat>
pub fn try_with_transfer(self, transfer: Transfer) -> Option<PixelFormat>
Replace the RGB or Gray transfer. Returns None for other models or an incompatible transfer.
Sourcepub fn with_range(
self,
range: SignalRange,
) -> Result<PixelFormat, At<ColorError>>
pub fn with_range( self, range: SignalRange, ) -> Result<PixelFormat, At<ColorError>>
Replace the RGB or Gray signal range, checking compatibility with the format.
Sourcepub fn try_with_range(self, range: SignalRange) -> Option<PixelFormat>
pub fn try_with_range(self, range: SignalRange) -> Option<PixelFormat>
Replace the RGB or Gray range. Returns None for other models or an incompatible range.
Sourcepub fn with_alpha(self, alpha: AlphaMode) -> Result<PixelFormat, At<ColorError>>
pub fn with_alpha(self, alpha: AlphaMode) -> Result<PixelFormat, At<ColorError>>
Replace alpha mode, returning an error if it disagrees with the layout.
Sourcepub fn with_diffuse_white(self, diffuse_white: DiffuseWhite) -> PixelFormat
pub fn with_diffuse_white(self, diffuse_white: DiffuseWhite) -> PixelFormat
Attach a DiffuseWhite anchor (no-op on non-RGB/Gray/XYZ variants).
Sourcepub fn try_with_diffuse_white(
self,
diffuse_white: DiffuseWhite,
) -> Option<PixelFormat>
pub fn try_with_diffuse_white( self, diffuse_white: DiffuseWhite, ) -> Option<PixelFormat>
Attach a DiffuseWhite anchor, returning None on non-RGB/Gray/XYZ variants.
Sourcepub fn can_represent_hdr(&self) -> bool
pub fn can_represent_hdr(&self) -> bool
Whether this spec can represent HDR light levels above SDR diffuse white (> 1.0).
Returns true for PQ and HLG transfers (any sample type), linear floating-point
RGB/Gray (F16/F32/F64), floating-point CIE XYZ, and ICC profiles backed by
floating-point storage or carrying an HDR (PQ/HLG) cicp tag.
Sourcepub fn from_layout_assuming_color(
layout: SampleLayout,
) -> Result<PixelFormat, At<ColorError>>
pub fn from_layout_assuming_color( layout: SampleLayout, ) -> Result<PixelFormat, At<ColorError>>
Construct a validated PixelFormat by assuming a conventional default color space for layout.
Assumption, not signal detection: chooses full-range sRGB for integer RGB/Gray layouts, linear sRGB/Gray for floating-point layouts, D65 for XYZ, straight/undefined alpha matching the layout’s alpha/padding slot, and untagged otherwise. Prefer explicit color spaces whenever container metadata is available.
Sourcepub fn validate(&self) -> Result<(), At<ColorError>>
pub fn validate(&self) -> Result<(), At<ColorError>>
Validate that layout and color agree on channels, alpha/padding, range, and sample types.
Sourcepub fn supports_interop(&self, target: InteropTarget) -> bool
pub fn supports_interop(&self, target: InteropTarget) -> bool
Check whether this spec satisfies an InteropTarget’s zero-copy contract.
Trait Implementations§
Source§impl AsRef<PixelFormat> for FormatCow<'_>
impl AsRef<PixelFormat> for FormatCow<'_>
Source§fn as_ref(&self) -> &PixelFormat
fn as_ref(&self) -> &PixelFormat
Source§impl AsRef<PixelFormat> for PixelFormat
impl AsRef<PixelFormat> for PixelFormat
Source§fn as_ref(&self) -> &PixelFormat
fn as_ref(&self) -> &PixelFormat
Source§impl Clone for PixelFormat
impl Clone for PixelFormat
Source§fn clone(&self) -> PixelFormat
fn clone(&self) -> PixelFormat
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more