Struct image_canvas::layout::SampleParts
source · [−]pub struct SampleParts { /* private fields */ }
Expand description
Describes which values are present in a texel.
This is some set of channels that describe the color point precisely, given a color space.
Depending on the chosen color there may be multiple ways in which case this names which of the
canonical encodings to use. For example, CIELAB
may be represented as Lab
(Lightness,
red/green, blue/yellow) or LCh
(Lightness, Chroma, Hue; the polar cooordinate form of the
previous).
FIXME(color): describe YUV, ASTC and BC block formats? Other? We surely can handle planar data properly?
Implementations
sourceimpl SampleParts
impl SampleParts
sourcepub const A: SampleParts = SampleParts{parts: [Some(Cc::Alpha), None, None, None],
color_index: Cc::Alpha.canonical_index_in_surely(ColorChannelModel::Rgb),}
pub const A: SampleParts = SampleParts{parts: [Some(Cc::Alpha), None, None, None], color_index: Cc::Alpha.canonical_index_in_surely(ColorChannelModel::Rgb),}
A pure alpha part.
sourcepub const R: SampleParts = SampleParts{parts: [Some(Cc::R), None, None, None],
color_index: Cc::R.canonical_index_in_surely(ColorChannelModel::Rgb),}
pub const R: SampleParts = SampleParts{parts: [Some(Cc::R), None, None, None], color_index: Cc::R.canonical_index_in_surely(ColorChannelModel::Rgb),}
A pure red part.
pub const G: SampleParts = SampleParts{parts: [Some(Cc::G), None, None, None], color_index: Cc::G.canonical_index_in_surely(ColorChannelModel::Rgb),}
pub const B: SampleParts = SampleParts{parts: [Some(Cc::B), None, None, None], color_index: Cc::B.canonical_index_in_surely(ColorChannelModel::Rgb),}
pub const Luma: SampleParts = SampleParts{parts: [Some(Cc::Luma), None, None, None], color_index: Cc::Luma.canonical_index_in_surely(ColorChannelModel::Yuv),}
pub const LumaA: SampleParts = SampleParts{parts: [Some(Cc::Luma), Some(Cc::Alpha), None, None], color_index: Cc::Luma.canonical_index_in_surely(ColorChannelModel::Yuv) | Cc::Alpha.canonical_index_in_surely(ColorChannelModel::Yuv) << 2,}
pub const Rgb: SampleParts = SampleParts{parts: [Some(Cc::R), Some(Cc::G), Some(Cc::B), None], color_index: Cc::R.canonical_index_in_surely(ColorChannelModel::Rgb) | Cc::G.canonical_index_in_surely(ColorChannelModel::Rgb) << 2 | Cc::B.canonical_index_in_surely(ColorChannelModel::Rgb) << 4,}
pub const RgbA: SampleParts = SampleParts{parts: [Some(Cc::R), Some(Cc::G), Some(Cc::B), Some(Cc::Alpha)], color_index: Cc::R.canonical_index_in_surely(ColorChannelModel::Rgb) | Cc::G.canonical_index_in_surely(ColorChannelModel::Rgb) << 2 | Cc::B.canonical_index_in_surely(ColorChannelModel::Rgb) << 4 | Cc::Alpha.canonical_index_in_surely(ColorChannelModel::Rgb) << 6,}
pub const ARgb: SampleParts = SampleParts{parts: [Some(Cc::Alpha), Some(Cc::R), Some(Cc::G), Some(Cc::B)], color_index: Cc::Alpha.canonical_index_in_surely(ColorChannelModel::Rgb) | Cc::R.canonical_index_in_surely(ColorChannelModel::Rgb) << 2 | Cc::G.canonical_index_in_surely(ColorChannelModel::Rgb) << 4 | Cc::B.canonical_index_in_surely(ColorChannelModel::Rgb) << 6,}
pub const Bgr: SampleParts = SampleParts{parts: [Some(Cc::B), Some(Cc::G), Some(Cc::R), None], color_index: Cc::B.canonical_index_in_surely(ColorChannelModel::Rgb) | Cc::G.canonical_index_in_surely(ColorChannelModel::Rgb) << 2 | Cc::R.canonical_index_in_surely(ColorChannelModel::Rgb) << 4,}
pub const BgrA: SampleParts = SampleParts{parts: [Some(Cc::B), Some(Cc::G), Some(Cc::R), Some(Cc::Alpha)], color_index: Cc::B.canonical_index_in_surely(ColorChannelModel::Rgb) | Cc::G.canonical_index_in_surely(ColorChannelModel::Rgb) << 2 | Cc::R.canonical_index_in_surely(ColorChannelModel::Rgb) << 4 | Cc::Alpha.canonical_index_in_surely(ColorChannelModel::Rgb) << 6,}
pub const ABgr: SampleParts = SampleParts{parts: [Some(Cc::Alpha), Some(Cc::B), Some(Cc::G), Some(Cc::R)], color_index: Cc::Alpha.canonical_index_in_surely(ColorChannelModel::Rgb) | Cc::B.canonical_index_in_surely(ColorChannelModel::Rgb) << 2 | Cc::G.canonical_index_in_surely(ColorChannelModel::Rgb) << 4 | Cc::R.canonical_index_in_surely(ColorChannelModel::Rgb) << 6,}
pub const Yuv: SampleParts = SampleParts{parts: [Some(Cc::Luma), Some(Cc::Cb), Some(Cc::Cr), None], color_index: Cc::Luma.canonical_index_in_surely(ColorChannelModel::Yuv) | Cc::Cb.canonical_index_in_surely(ColorChannelModel::Yuv) << 2 | Cc::Cr.canonical_index_in_surely(ColorChannelModel::Yuv) << 4,}
pub const YuvA: SampleParts = SampleParts{parts: [Some(Cc::Luma), Some(Cc::Cb), Some(Cc::Cr), Some(Cc::Alpha)], color_index: Cc::Luma.canonical_index_in_surely(ColorChannelModel::Yuv) | Cc::Cb.canonical_index_in_surely(ColorChannelModel::Yuv) << 2 | Cc::Cr.canonical_index_in_surely(ColorChannelModel::Yuv) << 4 | Cc::Alpha.canonical_index_in_surely(ColorChannelModel::Yuv) << 6,}
pub const Lab: SampleParts = SampleParts{parts: [Some(Cc::L), Some(Cc::LABa), Some(Cc::LABb), None], color_index: Cc::L.canonical_index_in_surely(ColorChannelModel::Lab) | Cc::LABa.canonical_index_in_surely(ColorChannelModel::Lab) << 2 | Cc::LABb.canonical_index_in_surely(ColorChannelModel::Lab) << 4,}
pub const LabA: SampleParts = SampleParts{parts: [Some(Cc::L), Some(Cc::LABa), Some(Cc::LABb), Some(Cc::Alpha)], color_index: Cc::L.canonical_index_in_surely(ColorChannelModel::Lab) | Cc::LABa.canonical_index_in_surely(ColorChannelModel::Lab) << 2 | Cc::LABb.canonical_index_in_surely(ColorChannelModel::Lab) << 4 | Cc::Alpha.canonical_index_in_surely(ColorChannelModel::Lab) << 6,}
pub const Lch: SampleParts = SampleParts{parts: [Some(Cc::L), Some(Cc::C), Some(Cc::LABh), None], color_index: Cc::L.canonical_index_in_surely(ColorChannelModel::Lab) | Cc::C.canonical_index_in_surely(ColorChannelModel::Lab) << 2 | Cc::LABh.canonical_index_in_surely(ColorChannelModel::Lab) << 4,}
pub const LchA: SampleParts = SampleParts{parts: [Some(Cc::L), Some(Cc::C), Some(Cc::LABh), Some(Cc::Alpha)], color_index: Cc::L.canonical_index_in_surely(ColorChannelModel::Lab) | Cc::C.canonical_index_in_surely(ColorChannelModel::Lab) << 2 | Cc::LABh.canonical_index_in_surely(ColorChannelModel::Lab) << 4 | Cc::Alpha.canonical_index_in_surely(ColorChannelModel::Lab) << 6,}
sourceimpl SampleParts
impl SampleParts
sourcepub fn new(
parts: [Option<ColorChannel>; 4],
model: ColorChannelModel
) -> Option<Self>
pub fn new(
parts: [Option<ColorChannel>; 4],
model: ColorChannelModel
) -> Option<Self>
Create from up to four color channels.
This is suitable for describing the channels of a single pixel, and relating it to the bit parts in the corresponding texel.
The order of parts will be remembered. All color channels must belong to a common color representation.
sourcepub fn with_channel(&self, ch: ColorChannel) -> Option<Self>
pub fn with_channel(&self, ch: ColorChannel) -> Option<Self>
Extract a single channel.
The channel is extract as if part of the ColorChannelModel used in the construction of these sample parts.
sourcepub fn contains(&self, ch: ColorChannel) -> bool
pub fn contains(&self, ch: ColorChannel) -> bool
Test if these parts contain the provided channel.
sourcepub fn color_channels(&self) -> [Option<ColorChannel>; 4]
pub fn color_channels(&self) -> [Option<ColorChannel>; 4]
Get an array of up to four color channel present.
sourcepub fn with_yuv_422(
parts: [Option<ColorChannel>; 3],
model: ColorChannelModel
) -> Option<Self>
pub fn with_yuv_422(
parts: [Option<ColorChannel>; 3],
model: ColorChannelModel
) -> Option<Self>
Create parts that describe 4:2:2 subsampled color channels.
These parts represent a 1x2 block, with 4 channels total.
sourcepub fn with_yuv_411(
parts: [Option<ColorChannel>; 3],
model: ColorChannelModel
) -> Option<Self>
pub fn with_yuv_411(
parts: [Option<ColorChannel>; 3],
model: ColorChannelModel
) -> Option<Self>
Create parts that describe 4:1:1 subsampled color channels.
These parts represent a 1x4 block, with 6 channels total.
pub fn num_components(self) -> u8
pub fn has_alpha(self) -> bool
Trait Implementations
sourceimpl Clone for SampleParts
impl Clone for SampleParts
sourcefn clone(&self) -> SampleParts
fn clone(&self) -> SampleParts
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for SampleParts
impl Debug for SampleParts
sourceimpl PartialEq<SampleParts> for SampleParts
impl PartialEq<SampleParts> for SampleParts
sourcefn eq(&self, other: &SampleParts) -> bool
fn eq(&self, other: &SampleParts) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &SampleParts) -> bool
fn ne(&self, other: &SampleParts) -> bool
This method tests for !=
.
impl Copy for SampleParts
impl Eq for SampleParts
impl StructuralEq for SampleParts
impl StructuralPartialEq for SampleParts
Auto Trait Implementations
impl RefUnwindSafe for SampleParts
impl Send for SampleParts
impl Sync for SampleParts
impl Unpin for SampleParts
impl UnwindSafe for SampleParts
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more