[][src]Struct prisma::ycbcr::YCbCr

#[repr(C)]pub struct YCbCr<T, M = JpegModel> { /* fields omitted */ }

A color in the YCbCr family of color spaces.

See the parent module description for a discussion on the properties of the color space. The YCbCr type is represented with a set of channel values, plus a model. The model is stored with the color, and comes in two forms:

  • A unit struct, defining the model at compile time. These do not store any value and thus do not increase the size of a color instance. JpegModel, Bt709Model and YiqModel and of this type. These types implement the UnitModel trait, and do not need to be passed to most functions.
  • A type which stores its transformations in memory at runtime. For these models, it is usually preferable to store a reference to the model in the color to minimize the size impact. However, this will still increase the size of the type by one pointer size. Only CustomYCbCrModel is of this type.

Implementations

impl<T, M> YCbCr<T, M> where
    T: NormalChannelScalar + PosNormalChannelScalar,
    M: YCbCrModel<T> + UnitModel<T>, 
[src]

pub fn new(y: T, cb: T, cr: T) -> Self[src]

Construct a YCbCr from channel values.

This method does not take a model parameter, and is only usable for colors where the model is a stateless type implementing UnitModel. For such types, it sets the model to M::unit_value(). For colors that have a stateful model, the new_and_model method should be used instead.

impl<T, M> YCbCr<T, M> where
    T: NormalChannelScalar + PosNormalChannelScalar,
    M: YCbCrModel<T>, 
[src]

pub fn from_color_and_model(ycbcr: BareYCbCr<T>, model: M) -> Self[src]

Construct a YCbCr from a BareYCbCr and model.

pub fn new_and_model(y: T, cb: T, cr: T, model: M) -> Self[src]

Construct a YCbCr from channel values and a model.

pub fn color_cast<TOut>(&self) -> YCbCr<TOut, M> where
    T: ChannelFormatCast<TOut>,
    TOut: NormalChannelScalar + PosNormalChannelScalar
[src]

Cast between different channel scalar representation.

pub fn model(&self) -> &M[src]

Get a reference to the model of the given YCbCr.

pub fn bare_ycbcr(&self) -> &BareYCbCr<T>[src]

Get a reference to the "bare" color.

pub fn luma(&self) -> T[src]

Get the luma (Y') channel.

pub fn cb(&self) -> T[src]

Get the Cb channel.

pub fn cr(&self) -> T[src]

Get the Cr channel.

pub fn luma_mut(&mut self) -> &mut T[src]

Get a mutable reference to the luma (Y') channel.

pub fn cb_mut(&mut self) -> &mut T[src]

Get a mutable reference to the Cb channel.

pub fn cr_mut(&mut self) -> &mut T[src]

Get a mutable reference to the Cr channel.

pub fn set_luma(&mut self, val: T)[src]

Set the luma (Y') channel to a value.

pub fn set_cb(&mut self, val: T)[src]

Set the Cb channel to a value.

pub fn set_cr(&mut self, val: T)[src]

Set the Cr channel to a value.

pub fn strip_model(self) -> BareYCbCr<T>[src]

Remove the model information from the given YCbCr.

This returns a BareYCbCr with all the same channel values. No conversion is necessary, the model information is simply dropped.

impl<T, M> YCbCr<T, M> where
    T: NormalChannelScalar + PosNormalChannelScalar + NumCast,
    M: YCbCrModel<T> + Canonicalize<T>, 
[src]

pub fn to_canonical_representation(&self) -> (T, T, T)[src]

Return the channels rescaled to their canonical range for the given YCbCr's model.

Most YUV and YIQ standards define the channel range to be different than the [-1, 1] used by this library. This function returns the values for the same color rescaled to the defined range.

impl<T> YCbCr<T, YiqModel> where
    T: NormalChannelScalar + PosNormalChannelScalar + NumCast,
    YiqModel: YCbCrModel<T>, 
[src]

pub fn i(&self) -> T[src]

The I channel of a YIQ color.

Because YIQ is implemented as a model on top of YCbCr, this is equivalent to self.cb().

pub fn q(&self) -> T[src]

The Q channel of a YIQ color.

Because YIQ is implemented as a model on top of YCbCr, this is equivalent to self.cr().

pub fn i_mut(&mut self) -> &mut T[src]

Return a mutable reference to the I channel.

pub fn q_mut(&mut self) -> &mut T[src]

Return a mutable reference to the Q channel.

pub fn set_i(&mut self, val: T)[src]

Set the I channel to a value.

pub fn set_q(&mut self, val: T)[src]

Set the Q channel to a value.

impl<T, M> YCbCr<T, M> where
    T: NormalChannelScalar + PosNormalChannelScalar + NumCast,
    M: YCbCrModel<T> + UnitModel<T>, 
[src]

pub fn from_rgb(from: &Rgb<T>) -> Self[src]

Convert from RGB to YCbCr for UnitModels.

impl<T, M> YCbCr<T, M> where
    T: NormalChannelScalar + PosNormalChannelScalar + NumCast,
    M: YCbCrModel<T>, 
[src]

pub fn from_rgb_and_model(from: &Rgb<T>, model: M) -> Self[src]

Convert from RGB to YCbCr, using model.

The returned value stores the passed model.

pub fn to_rgb(&self, out_of_gamut_mode: YCbCrOutOfGamutMode) -> Rgb<T>[src]

Convert from YCbCr to RGB.

Params

  • out_of_gamut_mode - How to handle out of gamut colors. See YCbCrOutOfGamutMode for a description of the options.

Trait Implementations

impl<T, M> AbsDiffEq<YCbCr<T, M>> for YCbCr<T, M> where
    T: NormalChannelScalar + PosNormalChannelScalar + AbsDiffEq,
    T::Epsilon: Clone,
    M: YCbCrModel<T>, 
[src]

type Epsilon = <BareYCbCr<T> as AbsDiffEq>::Epsilon

Used for specifying relative comparisons.

impl<T, M> Bounded for YCbCr<T, M> where
    T: NormalChannelScalar + PosNormalChannelScalar,
    M: YCbCrModel<T>, 
[src]

impl<T, M> Broadcast for YCbCr<T, M> where
    T: NormalChannelScalar + PosNormalChannelScalar,
    M: YCbCrModel<T> + UnitModel<T>, 
[src]

impl<T: Clone, M: Clone> Clone for YCbCr<T, M>[src]

impl<T, M> Color for YCbCr<T, M> where
    T: NormalChannelScalar + PosNormalChannelScalar,
    M: YCbCrModel<T>, 
[src]

type Tag = YCbCrTag

The unique tag unit struct identifying the color type

type ChannelsTuple = (T, T, T)

A tuple of types for each channel in the color

impl<T: Copy, M: Copy> Copy for YCbCr<T, M>[src]

impl<T: Debug, M: Debug> Debug for YCbCr<T, M>[src]

impl<T, M> Default for YCbCr<T, M> where
    T: NormalChannelScalar + PosNormalChannelScalar + Zero + Default,
    M: YCbCrModel<T> + UnitModel<T>, 
[src]

impl<T, M> Display for YCbCr<T, M> where
    T: NormalChannelScalar + PosNormalChannelScalar + Display,
    M: YCbCrModel<T>, 
[src]

impl<T, M> EncodableColor for YCbCr<T, M> where
    T: NormalChannelScalar + PosNormalChannelScalar,
    M: YCbCrModel<T>, 
[src]

impl<T: Eq, M: Eq> Eq for YCbCr<T, M>[src]

impl<T, M> Flatten for YCbCr<T, M> where
    T: NormalChannelScalar + PosNormalChannelScalar,
    M: YCbCrModel<T> + UnitModel<T>, 
[src]

impl<T, M> From<Rgb<T>> for YCbCr<T, M> where
    T: NormalChannelScalar + PosNormalChannelScalar + NumCast,
    M: YCbCrModel<T> + UnitModel<T>, 
[src]

impl<T, M> FromColor<Rgb<T>> for YCbCr<T, M> where
    T: NormalChannelScalar + PosNormalChannelScalar + NumCast,
    M: YCbCrModel<T> + UnitModel<T>, 
[src]

impl<T, M> FromTuple for YCbCr<T, M> where
    T: NormalChannelScalar + PosNormalChannelScalar,
    M: YCbCrModel<T> + UnitModel<T>, 
[src]

impl<T, M> FromYCbCr<YCbCr<T, M>> for Rgb<T> where
    T: NormalChannelScalar + PosNormalChannelScalar + NumCast,
    M: YCbCrModel<T>, 
[src]

impl<T: Hash, M: Hash> Hash for YCbCr<T, M>[src]

impl<T, M> HomogeneousColor for YCbCr<T, M> where
    T: NormalChannelScalar + PosNormalChannelScalar,
    M: YCbCrModel<T>, 
[src]

type ChannelFormat = T

The scalar type of each channel

impl<T, M> Invert for YCbCr<T, M> where
    T: NormalChannelScalar + PosNormalChannelScalar,
    M: YCbCrModel<T>, 
[src]

impl<T, M> Lerp for YCbCr<T, M> where
    T: NormalChannelScalar + Lerp + PosNormalChannelScalar,
    M: YCbCrModel<T>, 
[src]

type Position = <T as Lerp>::Position

The type of the pos argument

impl<T: Ord, M: Ord> Ord for YCbCr<T, M>[src]

impl<T: PartialEq, M: PartialEq> PartialEq<YCbCr<T, M>> for YCbCr<T, M>[src]

impl<T: PartialOrd, M: PartialOrd> PartialOrd<YCbCr<T, M>> for YCbCr<T, M>[src]

impl<T, M> RelativeEq<YCbCr<T, M>> for YCbCr<T, M> where
    T: NormalChannelScalar + PosNormalChannelScalar + RelativeEq,
    T::Epsilon: Clone,
    M: YCbCrModel<T>, 
[src]

impl<T, M> StructuralEq for YCbCr<T, M>[src]

impl<T, M> StructuralPartialEq for YCbCr<T, M>[src]

impl<T, M> UlpsEq<YCbCr<T, M>> for YCbCr<T, M> where
    T: NormalChannelScalar + PosNormalChannelScalar + UlpsEq,
    T::Epsilon: Clone,
    M: YCbCrModel<T>, 
[src]

Auto Trait Implementations

impl<T, M> RefUnwindSafe for YCbCr<T, M> where
    M: RefUnwindSafe,
    T: RefUnwindSafe

impl<T, M> Send for YCbCr<T, M> where
    M: Send,
    T: Send

impl<T, M> Sync for YCbCr<T, M> where
    M: Sync,
    T: Sync

impl<T, M> Unpin for YCbCr<T, M> where
    M: Unpin,
    T: Unpin

impl<T, M> UnwindSafe for YCbCr<T, M> where
    M: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.