Skip to main content

SourceColor

Struct SourceColor 

Source
#[non_exhaustive]
pub struct SourceColor { pub cicp: Option<Cicp>, pub icc_profile: Option<Arc<[u8]>>, pub bit_depth: Option<u8>, pub channel_count: Option<u8>, pub content_light_level: Option<ContentLightLevel>, pub mastering_display: Option<MasteringDisplay>, }
Expand description

Source color description from the image file.

Groups color-related metadata from the original source: CICP tags, ICC profile, bit depth, channel count, and HDR descriptors (content light level, mastering display).

These describe the source color space — not the current pixel data’s color space (which is tracked by zenpixels::PixelDescriptor).

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.
§cicp: Option<Cicp>

CICP color description (ITU-T H.273).

When present, describes the color space without requiring an ICC profile. Both CICP and ICC may be present — CICP takes precedence per AVIF/HEIF specs, but callers should use ICC when CICP is absent.

§icc_profile: Option<Arc<[u8]>>

Embedded ICC color profile.

Stored as Arc<[u8]> for cheap sharing across pipeline stages and pixel slices. Accepts Vec<u8> via with_icc_profile().

§bit_depth: Option<u8>

Bits per channel (e.g. 8, 10, 12, 16, 32).

None if unknown (e.g. from a header-only probe that doesn’t report bit depth).

§channel_count: Option<u8>

Number of channels (1=gray, 2=gray+alpha, 3=RGB, 4=RGBA).

None if unknown.

§content_light_level: Option<ContentLightLevel>

Content Light Level Info (CEA-861.3) for HDR content.

§mastering_display: Option<MasteringDisplay>

Mastering Display Color Volume (SMPTE ST 2086) for HDR content.

Implementations§

Source§

impl SourceColor

Source

pub fn with_cicp(self, cicp: Cicp) -> Self

Set the CICP color description.

Source

pub fn with_icc_profile(self, icc: impl Into<Arc<[u8]>>) -> Self

Set the ICC color profile.

Source

pub fn with_bit_depth(self, bit_depth: u8) -> Self

Set the bit depth.

Source

pub fn with_channel_count(self, channel_count: u8) -> Self

Set the channel count.

Source

pub fn with_content_light_level(self, clli: ContentLightLevel) -> Self

Set the Content Light Level Info.

Source

pub fn with_mastering_display(self, mdcv: MasteringDisplay) -> Self

Set the Mastering Display Color Volume.

Source

pub fn transfer_function(&self) -> TransferFunction

Derive the transfer function from CICP metadata.

Source

pub fn color_primaries(&self) -> ColorPrimaries

Derive the color primaries from CICP metadata.

Trait Implementations§

Source§

impl Clone for SourceColor

Source§

fn clone(&self) -> SourceColor

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 SourceColor

Source§

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

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

impl Default for SourceColor

Source§

fn default() -> SourceColor

Returns the “default value” for a type. Read more
Source§

impl PartialEq for SourceColor

Source§

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

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.