pub struct LinearToDisplay;Expand description
Apply sRGB gamma encoding to linear pixels for display.
This strategy accepts linear-light pixel types (like Rgb8, RgbF32,
Mono8, f32) and applies the sRGB transfer function before display.
Without this, linear images appear washed out on sRGB monitors.
§Performance note
This strategy does float conversion for every pixel. For debug display this is acceptable. For production rendering, users should pre-convert to sRGB or use GPU shaders.
§Examples
use fovea::pixel::{Rgb8, Srgba8};
use fovea_display::{DisplayStrategy, LinearToDisplay};
// Black stays black
let px = Rgb8::new(0, 0, 0);
assert_eq!(LinearToDisplay.to_display(&px), Srgba8::new(0, 0, 0, 255));
// White stays white
let px = Rgb8::new(255, 255, 255);
assert_eq!(LinearToDisplay.to_display(&px), Srgba8::new(255, 255, 255, 255));Trait Implementations§
Source§impl DisplayStrategy<Bgr8> for LinearToDisplay
impl DisplayStrategy<Bgr8> for LinearToDisplay
Source§impl DisplayStrategy<Bgra8> for LinearToDisplay
impl DisplayStrategy<Bgra8> for LinearToDisplay
Source§impl DisplayStrategy<Mono8> for LinearToDisplay
impl DisplayStrategy<Mono8> for LinearToDisplay
Source§impl DisplayStrategy<MonoF32> for LinearToDisplay
impl DisplayStrategy<MonoF32> for LinearToDisplay
Source§impl DisplayStrategy<MonoF64> for LinearToDisplay
impl DisplayStrategy<MonoF64> for LinearToDisplay
Source§impl DisplayStrategy<Rgb8> for LinearToDisplay
impl DisplayStrategy<Rgb8> for LinearToDisplay
Source§impl DisplayStrategy<RgbF32> for LinearToDisplay
impl DisplayStrategy<RgbF32> for LinearToDisplay
Source§impl DisplayStrategy<Rgba8> for LinearToDisplay
impl DisplayStrategy<Rgba8> for LinearToDisplay
Source§impl DisplayStrategy<RgbaF32> for LinearToDisplay
impl DisplayStrategy<RgbaF32> for LinearToDisplay
Source§impl DisplayStrategy<f32> for LinearToDisplay
impl DisplayStrategy<f32> for LinearToDisplay
Auto Trait Implementations§
impl Freeze for LinearToDisplay
impl RefUnwindSafe for LinearToDisplay
impl Send for LinearToDisplay
impl Sync for LinearToDisplay
impl Unpin for LinearToDisplay
impl UnsafeUnpin for LinearToDisplay
impl UnwindSafe for LinearToDisplay
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