Skip to main content

PixelConvertExt

Trait PixelConvertExt 

Source
pub trait PixelConvertExt: PixelSource {
    // Provided methods
    fn convert_to(
        &self,
        destination_format: impl AsRef<PixelFormat>,
        policy: &ConvertPolicy,
    ) -> Result<PixelBuf, At<ConvertError>> { ... }
    fn convert_to_with_peak(
        &self,
        destination_format: impl AsRef<PixelFormat>,
        policy: &ConvertPolicy,
        peak: PeakSource,
    ) -> Result<PixelBuf, At<ConvertError>> { ... }
    fn convert_into<D: PixelSink + ?Sized>(
        &self,
        dst: &mut D,
        policy: &ConvertPolicy,
    ) -> Result<(), At<ConvertError>> { ... }
    fn convert_into_with_peak<D: PixelSink + ?Sized>(
        &self,
        dst: &mut D,
        policy: &ConvertPolicy,
        peak: PeakSource,
    ) -> Result<(), At<ConvertError>> { ... }
    fn to_rgb8_if_opaque(&self) -> Result<PixelBuf, At<ConvertError>> { ... }
    fn to_rgba8(&self) -> Result<PixelBuf, At<ConvertError>> { ... }
    fn to_gray8_if_opaque(&self) -> Result<PixelBuf, At<ConvertError>> { ... }
    fn to_bgra8(&self) -> Result<PixelBuf, At<ConvertError>> { ... }
}
Expand description

Ergonomic one-shot conversion methods directly on any PixelSource (PixelBuf, PixelView, BandedBuf, or dyn PixelSource).

Every method is a 1-line #[inline] shim over ImagePlan’s type-erased execution core, so calling src.convert_to(...) or src.convert_into(&mut dst, ...) across any combination of carriers compiles to a single non-generic implementation with zero monomorphization bloat.

Provided Methods§

Source

fn convert_to( &self, destination_format: impl AsRef<PixelFormat>, policy: &ConvertPolicy, ) -> Result<PixelBuf, At<ConvertError>>

Convert self into a newly allocated tightly packed PixelBuf.

Resolves HDR source peak via PeakSource::Measured only when HDR→SDR tone mapping requires it; use convert_to_with_peak for explicit control.

Source

fn convert_to_with_peak( &self, destination_format: impl AsRef<PixelFormat>, policy: &ConvertPolicy, peak: PeakSource, ) -> Result<PixelBuf, At<ConvertError>>

Convert self into a newly allocated PixelBuf with an explicit PeakSource.

Source

fn convert_into<D: PixelSink + ?Sized>( &self, dst: &mut D, policy: &ConvertPolicy, ) -> Result<(), At<ConvertError>>

Convert self directly into any existing PixelSink (PixelBuf, PixelViewMut, or BandedBuf).

Source

fn convert_into_with_peak<D: PixelSink + ?Sized>( &self, dst: &mut D, policy: &ConvertPolicy, peak: PeakSource, ) -> Result<(), At<ConvertError>>

Convert self directly into any existing PixelSink with an explicit PeakSource.

Source

fn to_rgb8_if_opaque(&self) -> Result<PixelBuf, At<ConvertError>>

Convert self to full-range sRGB RGB8, refusing unproven alpha discard (AlphaPolicy::DiscardIfOpaque).

The alpha-discard decision trusts the source format and attached facts. To prove opacity from the bytes of an owned buffer, use PixelBuf::into_opaque_verified before conversion.

Source

fn to_rgba8(&self) -> Result<PixelBuf, At<ConvertError>>

Convert self to full-range sRGB straight-alpha RGBA8 under ConvertPolicy::permissive.

Source

fn to_gray8_if_opaque(&self) -> Result<PixelBuf, At<ConvertError>>

Convert self to full-range sRGB GRAY8, refusing unproven alpha discard (AlphaPolicy::DiscardIfOpaque).

The alpha-discard decision trusts the source format and attached facts. To prove opacity from the bytes of an owned buffer, use PixelBuf::into_opaque_verified before conversion.

Source

fn to_bgra8(&self) -> Result<PixelBuf, At<ConvertError>>

Convert self to full-range sRGB straight-alpha BGRA8 under ConvertPolicy::permissive.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§