pub struct Identity;Expand description
Display sRGB pixels as-is. Only available for sRGB types.
Attempting to use Identity with a linear type like Rgb8 is a
compile error — use LinearToDisplay instead.
§Examples
use fovea::pixel::{Srgba8, Srgb8, SrgbMono8, SrgbMonoA8};
use fovea_display::{DisplayStrategy, Identity};
// Srgba8 pass-through
let px = Srgba8::new(100, 150, 200, 255);
assert_eq!(Identity.to_display(&px), px);
// Srgb8 → Srgba8 (alpha = 255)
let px = Srgb8::new(128, 64, 200);
assert_eq!(Identity.to_display(&px), Srgba8::new(128, 64, 200, 255));
// SrgbMono8 → broadcast to Srgba8
let px = SrgbMono8::new(128);
assert_eq!(Identity.to_display(&px), Srgba8::new(128, 128, 128, 255));
// SrgbMonoA8 → broadcast value, keep alpha
let px = SrgbMonoA8::new(128, 64);
assert_eq!(Identity.to_display(&px), Srgba8::new(128, 128, 128, 64));ⓘ
use fovea::pixel::Rgb8;
use fovea_display::{DisplayStrategy, Identity};
// ERROR: Rgb8 is linear, not sRGB — no Identity impl.
let px = Rgb8::new(128, 64, 200);
let _ = Identity.to_display(&px);ⓘ
use fovea::pixel::Mono16;
use fovea_display::{DisplayStrategy, Identity};
// ERROR: Mono16 is not an sRGB type — use AutoContrast or FixedRange.
let px = Mono16::new(1000);
let _ = Identity.to_display(&px);Trait Implementations§
Source§impl DisplayStrategy<Srgb8> for Identity
impl DisplayStrategy<Srgb8> for Identity
Source§impl DisplayStrategy<SrgbMono8> for Identity
impl DisplayStrategy<SrgbMono8> for Identity
Source§impl DisplayStrategy<SrgbMonoA8> for Identity
impl DisplayStrategy<SrgbMonoA8> for Identity
Source§fn to_display(&self, pixel: &SrgbMonoA8) -> Srgba8
fn to_display(&self, pixel: &SrgbMonoA8) -> Srgba8
Convert a single pixel to display-ready
Srgba8.Auto Trait Implementations§
impl Freeze for Identity
impl RefUnwindSafe for Identity
impl Send for Identity
impl Sync for Identity
impl Unpin for Identity
impl UnsafeUnpin for Identity
impl UnwindSafe for Identity
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> ConvertPixelExt for T
impl<T> ConvertPixelExt for T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> FromLinear<T> for T
impl<T> FromLinear<T> for T
Source§fn from_linear(acc: T) -> T
fn from_linear(acc: T) -> T
Converts a linear-space accumulator value back to this pixel type, applying rounding and clamping. Read more