Skip to main content

Transform

Struct Transform 

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

A colour transform from one profile’s device space to another’s.

Build once (it precomputes lookup tables) and apply to any number of buffers from any thread. Buffers are interleaved; colour channels come first in each pixel and any further channels (alpha, spot) are copied or left alone.

Implementations§

Source§

impl Transform

Source

pub fn new( src: &Profile, dst: &Profile, intent: Intent, bpc: bool, ) -> Result<Transform, CmsError>

Transform from src to dst with intent, optionally with black point compensation.

Source

pub fn with_options( src: &Profile, dst: &Profile, opts: TransformOptions, ) -> Result<Transform, CmsError>

Source

pub fn proof( src: &Profile, proof: &Profile, dst: &Profile, intent: Intent, bpc: bool, simulate_paper: bool, ) -> Result<Transform, CmsError>

Soft-proof transform src → proof → dst (Photoshop View › Proof Setup): intent/bpc apply to the document → proof step; the proof → display step is relative colorimetric with BPC, or absolute colorimetric without BPC when simulate_paper is set (paper colour and black ink simulated).

Source

pub fn from_pipeline(pipeline: Pipeline, opts: TransformOptions) -> Transform

Builds a transform from an arbitrary pipeline over normalised values.

Source

pub fn inputs(&self) -> usize

Source

pub fn outputs(&self) -> usize

Source

pub fn options(&self) -> TransformOptions

Source

pub fn pipeline(&self) -> &Pipeline

The exact evaluation pipeline.

Source

pub fn eval(&self, input: &[f32], out: &mut [f32])

Exact evaluation of one colour (inputs → outputs normalised values).

Source

pub fn eval_fast(&self, input: &[f32], out: &mut [f32])

Lookup-table evaluation of one colour (what integer buffers use).

Source

pub fn convert_f32( &self, src: &[f32], src_stride: usize, dst: &mut [f32], dst_stride: usize, copy_extra: bool, )

Converts float pixels. src/dst hold whole pixels of src_stride/dst_stride values; colour channels come first. Trailing channels are copied when copy_extra.

Source

pub fn apply(&self, buf: &mut [f32], stride: usize)

In-place float conversion; stride ≥ max(inputs, outputs).

Source

pub fn convert_u8( &self, src: &[u8], src_stride: usize, dst: &mut [u8], dst_stride: usize, copy_extra: bool, )

Converts 8-bit pixels (see Transform::convert_f32 for the layout).

Source

pub fn convert_u16( &self, src: &[u16], src_stride: usize, dst: &mut [u16], dst_stride: usize, copy_extra: bool, )

Converts 16-bit pixels (see Transform::convert_f32 for the layout).

Source

pub fn convert_bytes_many( &self, sample: SampleKind, jobs: Vec<(&[u8], &mut [u8])>, src_stride: usize, dst_stride: usize, copy_extra: bool, )

Converts many independent buffers of native-endian samples in one parallel pass (e.g. all tiles of a surface): far cheaper than one parallel call per small buffer. Each job is (src bytes, dst bytes) holding whole pixels of src_stride/dst_stride samples.

Trait Implementations§

Source§

impl Debug for Transform

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.