Skip to main content

Profile

Struct Profile 

Source
pub struct Profile {
Show 15 fields pub version: (u8, u8), pub class: ProfileClass, pub color_space: ColorSpace, pub pcs: Pcs, pub rendering_intent: Intent, pub description: String, pub copyright: String, pub white_point: [f64; 3], pub black_point: Option<[f64; 3]>, pub chad: Option<Mat3>, pub matrix: Option<Mat3>, pub trc: Option<[Curve; 3]>, pub gray_trc: Option<Curve>, pub a2b: [Option<Lut>; 3], pub b2a: [Option<Lut>; 3], /* private fields */
}
Expand description

A parsed ICC profile.

Fields§

§version: (u8, u8)

Major version and minor.bugfix byte (e.g. (4, 0x30) for 4.3, (2, 0x10) for 2.1).

§class: ProfileClass§color_space: ColorSpace§pcs: Pcs§rendering_intent: Intent§description: String§copyright: String§white_point: [f64; 3]

wtpt as stored (XYZ; D50 when absent).

§black_point: Option<[f64; 3]>

bkpt when present.

§chad: Option<Mat3>

chad chromatic adaptation matrix when present.

§matrix: Option<Mat3>

Colorant matrix (columns rXYZ, gXYZ, bXYZ), D50-adapted.

§trc: Option<[Curve; 3]>§gray_trc: Option<Curve>§a2b: [Option<Lut>; 3]

A2B0/A2B1/A2B2 (perceptual, colorimetric, saturation).

§b2a: [Option<Lut>; 3]

Implementations§

Source§

impl Profile

Source

pub fn parse(bytes: &[u8]) -> Result<Profile, CmsError>

Parses ICC profile bytes.

Source

pub fn to_bytes(&self) -> Arc<Vec<u8>> ⓘ

The ICC bytes of this profile: the original bytes when it was parsed, otherwise a fresh ICC v4 encoding.

Source

pub fn with_encoded_bytes(self) -> Profile

Re-encodes the model as ICC v4 bytes and caches them (used for built-in profiles).

Source

pub fn channels(&self) -> usize

Source

pub fn content_hash(&self) -> u64

Hash of the profile’s ICC bytes (stable within a process; used as a cache key).

Source

pub fn same_colors(&self, other: &Profile) -> bool

Whether self and other describe the same colours: same colour space, and every sample of a device-value grid has the same colour through both (relative colorimetric, within SAME_COLORS_MAX_DELTA_E). Different encodings of one space are the same colours: the sRGB IEC61966-2.1 Photoshop embeds (v2, 1024-entry tables) and the built-in sRGB (v4, parametric curves) differ in every byte. Colours are compared rather than round-tripped because CMYK → PCS → CMYK is not an identity even through a single profile.

Source

pub fn media_white(&self) -> [f64; 3]

Media white point used for ICC-absolute colorimetry: wtpt, except for v2 display profiles whose wtpt records the (unadapted) display white; those are treated as D50.

Source

pub fn gray_as_rgb(&self) -> Option<Profile>

An RGB view of a gray TRC profile: each of R, G, B carries the gray curve and maps to a third of the white, so (v, v, v) has exactly the colour of gray v. Used for composites of gray documents, which are stored as replicated RGB.

Source

pub fn is_matrix_shaper(&self) -> bool

true for matrix/TRC RGB or gray TRC profiles without LUTs.

Source

pub fn can_be_destination(&self) -> bool

Whether colours can be converted into this profile for every intent. Input profiles with only AToB tables (Apple’s Wide Color Sharing Profile on iPhone photos) can’t: they describe a source but have no PCS → device path.

Source

pub fn supports_intent(&self, intent: Intent, input: bool) -> bool

Whether the profile has a dedicated table for intent (matrix profiles support every intent colorimetrically).

Source

pub fn device_to_pcs( &self, intent: Intent, ) -> Result<(Vec<Stage>, Pcs), CmsError>

Stages mapping normalised device values to the float PCS.

Source

pub fn pcs_to_device( &self, intent: Intent, ) -> Result<(Vec<Stage>, Pcs), CmsError>

Stages mapping the float PCS (of the returned kind) to normalised device values.

Trait Implementations§

Source§

impl Clone for Profile

Source§

fn clone(&self) -> Self

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 Profile

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Profile

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Profile

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> 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> 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 = !

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.