Skip to main content

ImagePlan

Struct ImagePlan 

Source
pub struct ImagePlan { /* private fields */ }
Expand description

Whole-image conversion plan supporting streaming HDR peak measurement (PeakSource::Measured), container metadata peaks (PeakSource::Declared), and uniform execution across PixelView, PixelBuf, and BandedBuf.

Implementations§

Source§

impl ImagePlan

Source

pub fn build( src: impl AsRef<PixelFormat>, dst: impl AsRef<PixelFormat>, policy: &ConvertPolicy, peak: PeakSource, ) -> Result<Self, At<ConvertError>>

Validate and construct an image-level conversion plan.

Accepts either borrowed &PixelFormat or owned PixelFormat at the call site and borrows &ConvertPolicy (retaining internal clones inside the built plan).

When the route does not require per-image HDR peak resolution or runtime buffer facts (DiscardIfOpaque / Forbid on U16→U8, RGB→Gray, or float→int), the compiled RowPlan is built once and reused across every execute call.

Source

pub fn build_with_pulse( src: impl AsRef<PixelFormat>, dst: impl AsRef<PixelFormat>, policy: &ConvertPolicy, peak: PeakSource, pulse: Option<&dyn Pulse>, ) -> Result<Self, At<ConvertError>>

Build a reusable ImagePlan with optional cooperative cancellation and progress via pulse (forwarded to CmsBackend::build_transform and ToneMapper::prepare when eagerly compiling the row plan; pass None when not needed).

Source

pub fn execute_into<S: PixelSource + ?Sized, D: PixelSink + ?Sized>( &self, src: &S, dst: &mut D, ) -> Result<(), At<ConvertError>>

Execute into an existing PixelSink (PixelViewMut, PixelBuf, BandedBuf) with O(1) row scratch memory (never allocates a full-image F32 temporary!).

Source

pub fn execute_into_with_pulse<S: PixelSource + ?Sized, D: PixelSink + ?Sized>( &self, src: &S, dst: &mut D, pulse: Option<&dyn Pulse>, ) -> Result<(), At<ConvertError>>

Execute into an existing PixelSink with optional cooperative cancellation and row progress via pulse (pass None when not needed).

Source

pub fn execute<S: PixelSource + ?Sized>( &self, src: &S, ) -> Result<PixelBuf, At<ConvertError>>

Execute into a freshly allocated tightly packed PixelBuf.

Source

pub fn execute_with_pulse<S: PixelSource + ?Sized>( &self, src: &S, pulse: Option<&dyn Pulse>, ) -> Result<PixelBuf, At<ConvertError>>

Execute into a freshly allocated tightly packed PixelBuf with optional cooperative cancellation and row progress via pulse (pass None when not needed).

Source

pub fn convert<S: PixelSource + ?Sized>( src: &S, destination_format: impl AsRef<PixelFormat>, policy: &ConvertPolicy, ) -> Result<PixelBuf, At<ConvertError>>

One-shot conversion from any PixelSource (PixelBuf, PixelView, BandedBuf, or dyn PixelSource) into a newly allocated tightly packed PixelBuf.

Resolves HDR source peak via PeakSource::Measured only when HDR→SDR tone mapping actually requires it; for explicit peak control (Declared / Fixed), use ImagePlan::convert_with_peak.

Source

pub fn convert_with_peak<S: PixelSource + ?Sized>( src: &S, destination_format: impl AsRef<PixelFormat>, policy: &ConvertPolicy, peak: PeakSource, ) -> Result<PixelBuf, At<ConvertError>>

One-shot conversion from any PixelSource into a newly allocated PixelBuf with an explicit PeakSource (Measured, Declared, or Fixed).

Source

pub fn convert_with_pulse<S: PixelSource + ?Sized>( src: &S, destination_format: impl AsRef<PixelFormat>, policy: &ConvertPolicy, peak: PeakSource, pulse: Option<&dyn Pulse>, ) -> Result<PixelBuf, At<ConvertError>>

One-shot conversion from any PixelSource into a newly allocated PixelBuf with an explicit PeakSource and optional cooperative cancellation/progress via pulse (pass None when not needed).

Source

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

One-shot conversion from any PixelSource into any existing PixelSink (PixelBuf, PixelViewMut, or BandedBuf) with O(1) row scratch memory.

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

Source

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

One-shot conversion from any PixelSource into any PixelSink with an explicit PeakSource.

Source

pub fn convert_into_with_pulse<S: PixelSource + ?Sized, D: PixelSink + ?Sized>( src: &S, dst: &mut D, policy: &ConvertPolicy, peak: PeakSource, pulse: Option<&dyn Pulse>, ) -> Result<(), At<ConvertError>>

One-shot conversion from any PixelSource into any PixelSink with an explicit PeakSource and optional cooperative cancellation/progress via pulse (pass None when not needed).

Source

pub fn to_rgb8_if_opaque<S: PixelSource + ?Sized>( src: &S, ) -> Result<PixelBuf, At<ConvertError>>

One-shot conversion from any PixelSource to full-range sRGB RGB8 under ConvertPolicy::permissive().with_alpha(AlphaPolicy::DiscardIfOpaque).

DiscardIfOpaque is a metadata-only check (AlphaMode::None, AlphaMode::Opaque, AlphaMode::Undefined, or src.source_claims().all_opaque == true) — it does not scan pixels. For straight-alpha buffers whose pixels happen to be opaque, run PixelScanExt::measure_claims first (or pass AlphaPolicy::CompositeOnto / AlphaPolicy::DiscardUnchecked to ImagePlan::convert).

Source

pub fn to_rgba8<S: PixelSource + ?Sized>( src: &S, ) -> Result<PixelBuf, At<ConvertError>>

One-shot conversion from any PixelSource to full-range sRGB straight-alpha RGBA8 under ConvertPolicy::permissive.

Source

pub fn to_gray8_if_opaque<S: PixelSource + ?Sized>( src: &S, ) -> Result<PixelBuf, At<ConvertError>>

One-shot conversion from any PixelSource to full-range sRGB GRAY8 (encoded Y’ luma by default) under ConvertPolicy::permissive().with_alpha(AlphaPolicy::DiscardIfOpaque).

DiscardIfOpaque is a metadata-only check (AlphaMode::None, AlphaMode::Opaque, AlphaMode::Undefined, or src.source_claims().all_opaque == true) — it does not scan pixels. For straight-alpha buffers whose pixels happen to be opaque, run PixelScanExt::measure_claims first (or pass AlphaPolicy::CompositeOnto / AlphaPolicy::DiscardUnchecked to ImagePlan::convert).

Source

pub fn to_bgra8<S: PixelSource + ?Sized>( src: &S, ) -> Result<PixelBuf, At<ConvertError>>

One-shot conversion from any PixelSource to full-range sRGB straight-alpha BGRA8 under ConvertPolicy::permissive.

Trait Implementations§

Source§

impl Clone for ImagePlan

Source§

fn clone(&self) -> ImagePlan

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ImagePlan

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.