Struct lcms2::Profile

source ·
#[repr(transparent)]
pub struct Profile<Context = GlobalContext> { /* private fields */ }
Expand description

An ICC color profile

Implementations§

source§

impl Profile<GlobalContext>

These are the basic functions on opening profiles. For simpler operation, you must open two profiles using new_file, and then create a transform with these open profiles with Transform. Using this transform you can color correct your bitmaps.

source

pub fn new_icc(data: &[u8]) -> LCMSResult<Self>

Parse ICC profile from the in-memory array

source

pub fn new_file<P: AsRef<Path>>(path: P) -> Result<Self>

Load ICC profile file from disk

source

pub fn new_srgb() -> Self

Create an ICC virtual profile for sRGB space. sRGB is a standard RGB color space created cooperatively by HP and Microsoft in 1996 for use on monitors, printers, and the Internet.

source

pub fn new_rgb( white_point: &CIExyY, primaries: &CIExyYTRIPLE, transfer_function: &[&ToneCurve] ) -> LCMSResult<Self>

This function creates a display RGB profile based on White point, primaries and transfer functions. It populates following tags; this conform a standard RGB Display Profile, and then I add (As per addendum II) chromaticity tag.

  1. ProfileDescriptionTag
  2. MediaWhitePointTag
  3. RedColorantTag
  4. GreenColorantTag
  5. BlueColorantTag
  6. RedTRCTag
  7. GreenTRCTag
  8. BlueTRCTag
  9. Chromatic adaptation Tag
  10. ChromaticityTag
source

pub fn new_gray(white_point: &CIExyY, curve: &ToneCurve) -> LCMSResult<Self>

This function creates a gray profile based on White point and transfer function. It populates following tags; this conform a standard gray display profile.

  1. ProfileDescriptionTag
  2. MediaWhitePointTag
  3. GrayTRCTag
source

pub fn new_xyz() -> Self

Creates a XYZ XYZ identity, marking it as v4 ICC profile. WhitePoint used in Absolute colorimetric intent is D50.

source

pub fn new_null() -> Self

Creates a fake NULL profile. This profile return 1 channel as always 0. Is useful only for gamut checking tricks.

source

pub fn new_placeholder() -> Self

Creates an empty profile object, ready to be populated by the programmer.

WARNING: The obtained profile without adding any information is not directly useable.

source

pub fn ink_limiting( color_space: ColorSpaceSignature, limit: f64 ) -> LCMSResult<Self>

This is a devicelink operating in CMYK for ink-limiting. Currently only cmsSigCmykData is supported. Limit: Amount of ink limiting in % (0..400%)

Generates a device-link profile from a given color transform. This profile can then be used by any other function accepting profile handle. Depending on the specified version number, the implementation of the devicelink may vary. Accepted versions are in range 1.0…4.3

source§

impl<Ctx: Context> Profile<Ctx>

source

pub fn icc(&self) -> LCMSResult<Vec<u8>>

Create ICC file in memory buffer

source

pub fn device_class(&self) -> ProfileClassSignature

Gets the device class signature from profile header.

source

pub fn set_device_class(&mut self, cls: ProfileClassSignature)

Sets the device class signature in profile header.

source

pub fn encoded_icc_version(&self) -> u32

Returns the profile ICC version in the same format as it is stored in the header.

source

pub fn set_encoded_icc_version(&self, v: u32)

source

pub fn header_attributes(&self) -> u64

Gets the attribute flags. Currently defined values correspond to the low 4 bytes of the 8 byte attribute quantity.

  • Reflective
  • Transparency
  • Glossy
  • Matte
source

pub fn set_header_attributes(&mut self, flags: u64)

Sets the attribute flags in the profile header.

source

pub fn header_creator(&self) -> u32

source

pub fn header_flags(&self) -> u32

Get header flags of given ICC profile object.

The profile flags field does contain flags to indicate various hints for the CMM such as distributed processing and caching options. The least-significant 16 bits are reserved for the ICC. Flags in bit positions 0 and 1 shall be used as indicated in Table 7 of LCMS PDF.

source

pub fn set_header_flags(&mut self, flags: u32)

Sets header flags of given ICC profile object. Valid flags are defined in Table 7 of LCMS PDF.

source

pub fn header_manufacturer(&self) -> u32

Returns the manufacturer signature as described in the header.

This funcionality is widely superseded by the manufaturer tag. Of use only in elder profiles.

source

pub fn set_header_manufacturer(&mut self, m: u32)

👎Deprecated: This funcionality is widely superseded by the manufaturer tag

Sets the manufacturer signature in the header.

This funcionality is widely superseded by the manufaturer tag. Of use only in elder profiles.

source

pub fn header_model(&self) -> u32

Returns the model signature as described in the header.

This funcionality is widely superseded by the model tag. Of use only in elder profiles.

source

pub fn set_header_model(&mut self, model: u32)

👎Deprecated: This funcionality is widely superseded by the model tag

Sets the model signature in the profile header.

This funcionality is widely superseded by the model tag. Of use only in elder profiles.

source

pub fn header_rendering_intent(&self) -> Intent

Gets the profile header rendering intent.

From the ICC spec: “The rendering intent field shall specify the rendering intent which should be used (or, in the case of a Devicelink profile, was used) when this profile is (was) combined with another profile. In a sequence of more than two profiles, it applies to the combination of this profile and the next profile in the sequence and not to the entire sequence. Typically, the user or application will set the rendering intent dynamically at runtime or embedding time. Therefore, this flag may not have any meaning until the profile is used in some context, e.g. in a Devicelink or an embedded source profile.”

source

pub fn set_header_rendering_intent(&mut self, intent: Intent)

source

pub fn pcs(&self) -> ColorSpaceSignature

Gets the profile connection space used by the given profile, using the ICC convention.

source

pub fn set_pcs(&mut self, pcs: ColorSpaceSignature)

Sets the profile connection space signature in profile header, using ICC convention.

source

pub fn info(&self, info: InfoType, locale: Locale) -> Option<String>

source

pub fn version(&self) -> f64

Returns the profile ICC version. The version is decoded to readable floating point format.

source

pub fn set_version(&mut self, ver: f64)

Sets the ICC version in profile header. The version is given to this function as a float n.m

source

pub fn tag_signatures(&self) -> Vec<TagSignature>

source

pub fn detect_black_point(&self, intent: Intent) -> Option<CIEXYZ>

source

pub fn detect_destination_black_point(&self, intent: Intent) -> Option<CIEXYZ>

source

pub fn detect_tac(&self) -> f64

source

pub fn color_space(&self) -> ColorSpaceSignature

Gets the color space used by the given profile, using the ICC convention.

source

pub fn set_color_space(&mut self, sig: ColorSpaceSignature)

Sets the profile connection space signature in profile header, using ICC convention.

source

pub fn is_clut(&self, intent: Intent, used_direction: u32) -> bool

source

pub fn is_intent_supported(&self, intent: Intent, used_direction: u32) -> bool

source

pub fn is_matrix_shaper(&self) -> bool

source

pub fn has_tag(&self, sig: TagSignature) -> bool

source

pub fn read_tag(&self, sig: TagSignature) -> Tag<'_>

source

pub fn write_tag(&mut self, sig: TagSignature, tag: Tag<'_>) -> bool

source

pub fn remove_tag(&mut self, sig: TagSignature) -> bool

source

pub fn profile_id(&self) -> ProfileID

Retrieves the Profile ID stored in the profile header.

source

pub fn set_default_profile_id(&mut self)

Computes a MD5 checksum and stores it as Profile ID in the profile header.

source

pub fn set_profile_id(&mut self, id: ProfileID)

source

pub fn save_profile_to_file(&mut self, path: &Path) -> Result<()>

source§

impl<Ctx: Context> Profile<Ctx>

Per-context functions that can be used with a ThreadContext

source

pub fn new_icc_context( context: impl AsRef<Ctx>, data: &[u8] ) -> LCMSResult<Self>

source

pub fn new_file_context<P: AsRef<Path>>( context: impl AsRef<Ctx>, path: P ) -> Result<Self>

source

pub fn new_srgb_context(context: impl AsRef<Ctx>) -> Self

source

pub fn new_rgb_context( context: impl AsRef<Ctx>, white_point: &CIExyY, primaries: &CIExyYTRIPLE, transfer_function: &[&ToneCurve] ) -> LCMSResult<Self>

source

pub fn new_gray_context( context: impl AsRef<Ctx>, white_point: &CIExyY, curve: &ToneCurve ) -> LCMSResult<Self>

This is a devicelink operating in the target colorspace with as many transfer functions as components. Number of tone curves must be sufficient for the color space.

source

pub fn new_bchsw_abstract_context( context: impl AsRef<Ctx>, lut_points: usize, bright: f64, contrast: f64, hue: f64, saturation: f64, temp_src_dst: Option<(u32, u32)> ) -> LCMSResult<Self>

Creates an abstract devicelink operating in Lab for Bright/Contrast/Hue/Saturation and white point translation. White points are specified as temperatures ºK

nLUTPoints : Resulting color map resolution Bright: Bright increment. May be negative Contrast : Contrast increment. May be negative. Hue : Hue displacement in degree. Saturation: Saturation increment. May be negative TempSrc: Source white point temperature TempDest: Destination white point temperature. To prevent white point adjustment, set Temp to None

source

pub fn ink_limiting_context( context: impl AsRef<Ctx>, color_space: ColorSpaceSignature, limit: f64 ) -> LCMSResult<Self>

This is a devicelink operating in CMYK for ink-limiting. Currently only cmsSigCmykData is supported. Limit: Amount of ink limiting in % (0..400%)

source

pub fn new_xyz_context(context: impl AsRef<Ctx>) -> Self

Creates a XYZ XYZ identity, marking it as v4 ICC profile. WhitePoint used in Absolute colorimetric intent is D50.

source

pub fn new_null_context(context: impl AsRef<Ctx>) -> Self

Creates a fake NULL profile. This profile return 1 channel as always 0. Is useful only for gamut checking tricks.

source

pub fn new_lab2_context( context: impl AsRef<Ctx>, white_point: &CIExyY ) -> LCMSResult<Self>

Creates a Lab Lab identity, marking it as v2 ICC profile.

Adjustments for accomodating PCS endoing shall be done by Little CMS when using this profile.

source

pub fn new_lab4_context( context: impl AsRef<Ctx>, white_point: &CIExyY ) -> LCMSResult<Self>

Creates a Lab Lab identity, marking it as v4 ICC profile.

Trait Implementations§

source§

impl Debug for Profile

source§

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

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

impl<Context> Drop for Profile<Context>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<'a, C: Send> Send for Profile<C>

Auto Trait Implementations§

§

impl<Context> RefUnwindSafe for Profile<Context>where Context: RefUnwindSafe,

§

impl<Context = GlobalContext> !Sync for Profile<Context>

§

impl<Context> Unpin for Profile<Context>where Context: Unpin,

§

impl<Context> UnwindSafe for Profile<Context>where Context: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.