IccNamedColorTransform Class
The conversion of the colors of an ICC named color profile to the device values of another profile, through a sequence of profiles. Instances are immutable and thread-safe: create a transform once and reuse it.
public sealed class IccNamedColorTransformRemarks
The first profile of the sequence is the named color profile; its colors enter the sequence in the profile connection space, from their media-relative colorimetry (IccNamedColor.ConnectionSpaceColor). The other profiles follow the rules of IccColorTransform.Create: abstract profiles in the connection space, then a device profile that converts the colors to its device values, optionally followed by device link profiles or by other pairs of device profiles.
The rendering intent selects the conversion of the destination profiles; with IccRenderingIntent.AbsoluteColorimetric, the colors are first rescaled from the media white point of the named color profile. Named colors are measured colors, not the range of a device: IccColorTransformOptions.BlackPointCompensation does not apply to them, as in LittleCMS.
To print a named color on the device the named color profile was made for, use its IccNamedColor.DeviceValues, when the profile gives them, instead of converting its colorimetry.
Example
public static (byte[] Rgb, IReadOnlyList<double> Inks) SpotColor(string swatchBookPath, string name)
{
var swatchBook = new IccProfile(new MetadataBlob(File.ReadAllBytes(swatchBookPath)));
var colors = IccNamedColorCollection.Create(swatchBook);
if (!colors.TryGetValue(name, out var color))
throw new ArgumentException($"The swatch book has no color named '{name}'.", nameof(name));
// The colorimetry of the color, converted to the device values of the display (relative colorimetric intent)
var transform = IccNamedColorTransform.Create(swatchBook, IccProfile.Srgb);
var rgb = new byte[transform.DestinationChannelCount];
transform.Convert(color, rgb);
// On the press the profile was made for, its device values (here CMYK inks) reproduce the color exactly
return (rgb, color.DeviceValues);
}Properties
| Name | Description |
|---|---|
| Colors | Gets the colors of the named color profile. |
| DestinationChannelCount | Gets the number of samples per converted color: 1 (grayscale), 3 (RGB) or 4 (CMYK). |
Gets the colors of the named color profile.
public IccNamedColorCollection Colors { get; }Property value
DestinationChannelCount
IccNamedColorTransform.csMethods
| Name | Description |
|---|---|
| Convert(IccNamedColor, Span<byte>) | Converts a named color to 8-bit samples. |
| Convert(IccNamedColor, Span<float>) | Converts a named color to floating-point samples, in [0, 1] unless the transform does not clip them. |
| Convert(IccNamedColor, Span<ushort>) | Converts a named color to 16-bit samples. |
| Create(IccProfile, IccProfile, IccColorTransformOptions?) | Creates the conversion of the colors of a named color profile to the device values of a profile. |
| Create(IReadOnlyList<IccProfile>, IccColorTransformOptions?) | Creates the conversion of the colors of a named color profile through a sequence of profiles: the named color profile first, then the profiles in the order the colors go through them. |
Convert overloads
Convert(IccNamedColor, Span<byte>)
IccNamedColorTransform.csConverts a named color to 8-bit samples.
public void Convert(IccNamedColor color, Span<byte> destination)Parameters
colorIccNamedColor- The color, usually one of
IccNamedColorTransform.Colors. destinationSpan<byte>- The converted samples: exactly
IccNamedColorTransform.DestinationChannelCountsamples.
Exceptions
ArgumentNullExceptioncolorisnull.ArgumentException- The length of
destinationis notIccNamedColorTransform.DestinationChannelCount.
Convert(IccNamedColor, Span<float>)
IccNamedColorTransform.csConverts a named color to floating-point samples, in [0, 1] unless the transform does not clip them.
public void Convert(IccNamedColor color, Span<float> destination)Parameters
colorIccNamedColor- The color, usually one of
IccNamedColorTransform.Colors. destinationSpan<float>- The converted samples: exactly
IccNamedColorTransform.DestinationChannelCountsamples.
Exceptions
ArgumentNullExceptioncolorisnull.ArgumentException- The length of
destinationis notIccNamedColorTransform.DestinationChannelCount.
Convert(IccNamedColor, Span<ushort>)
IccNamedColorTransform.csConverts a named color to 16-bit samples.
public void Convert(IccNamedColor color, Span<ushort> destination)Parameters
colorIccNamedColor- The color, usually one of
IccNamedColorTransform.Colors. destinationSpan<ushort>- The converted samples: exactly
IccNamedColorTransform.DestinationChannelCountsamples.
Exceptions
ArgumentNullExceptioncolorisnull.ArgumentException- The length of
destinationis notIccNamedColorTransform.DestinationChannelCount.
Create overloads
Create(IccProfile, IccProfile, IccColorTransformOptions?)
IccNamedColorTransform.csCreates the conversion of the colors of a named color profile to the device values of a profile.
public static IccNamedColorTransform Create(IccProfile namedColorProfile, IccProfile destination, IccColorTransformOptions? options = null)Parameters
namedColorProfileIccProfile- The named color profile.
destinationIccProfile- The profile describing the converted samples.
optionsIccColorTransformOptions?- The options, or
nullforIccColorTransformOptions.Default.
Returns
IccNamedColorTransform The transform.
Exceptions
ArgumentNullExceptionnamedColorProfileordestinationisnull.ArgumentExceptionnamedColorProfileis not a named color profile.InvalidImageContentException- A profile is malformed.
UnsupportedImageFeatureException- A profile is valid but not supported, or cannot be used as a destination.
Create(IReadOnlyList<IccProfile>, IccColorTransformOptions?)
IccNamedColorTransform.csCreates the conversion of the colors of a named color profile through a sequence of profiles: the named color profile first, then the profiles in the order the colors go through them.
public static IccNamedColorTransform Create(IReadOnlyList<IccProfile> profiles, IccColorTransformOptions? options = null)Parameters
profilesIReadOnlyList<IccProfile>- The named color profile, then at least one profile; the last one describes the converted samples.
optionsIccColorTransformOptions?- The options, or
nullforIccColorTransformOptions.Default.
Returns
IccNamedColorTransform The transform.
Exceptions
ArgumentNullExceptionprofilesor one of its profiles isnull.ArgumentExceptionprofileshas fewer than two profiles, or its first profile is not a named color profile.InvalidImageContentException- A profile is malformed.
UnsupportedImageFeatureException- A profile is valid but not supported, or the sequence does not connect; or
IccColorTransformOptions.ClipFloatingPointSamplesisfalseand the conversion goes through a lookup table or a gamut mapping.