Class IccData
A parsed ICC profile (ICC.1, versions 2 and 4): the header fields, the description and copyright text, and every tag with its bytes. Read-only; FromIcc(IccData) turns it into an encoding that conversion can use.
public sealed class IccData
- Inheritance
-
IccData
- Inherited Members
Examples
// IccData reads a profile's header and tags; it never throws, and says what was wrong with a damaged one.
IccData icc = IccData.Parse(bytes);
Console.WriteLine($"{icc.Description}: version {icc.Version}, {icc.ProfileClass}, {icc.DataSpace} to {icc.ConnectionSpace}, damaged: {icc.IsDamaged}");
foreach (IccTag tag in icc.Tags)
{
Console.WriteLine($" {tag.Signature} ({tag.Type}), {tag.Data.Length} bytes");
}
// ColorProfile.FromIcc makes an encoding from it: a matrix profile gets its primaries and curve, so an ICC profile written
// for Display P3 is equivalent to the built-in.
ColorProfile profile = ColorProfile.FromIcc(icc);
bool isP3 = profile.IsEquivalentTo(ColorProfile.DisplayP3);
Remarks
Parsing never throws. A profile with offsets or sizes outside it, a missing signature, or more bytes than MaxMetadataBytes is marked damaged; what could be read is available, and ToBytes() returns the bytes given.
Properties
CodePoints
Gets the H.273 code points of a version 4.4 cicp tag, which HDR profiles use to name PQ or HLG exactly, or
null.
public ColorCodePoints? CodePoints { get; }
Property Value
ConnectionSpace
Gets the profile connection space signature without trailing spaces: "XYZ" or "Lab".
public string ConnectionSpace { get; }
Property Value
Copyright
Gets the copyright text (the cprt tag), or null.
public string? Copyright { get; }
Property Value
Created
Gets when the profile was created, as UTC, or null when the header's date is not a valid one.
public DateTime? Created { get; }
Property Value
DataSpace
Gets the data color space signature without trailing spaces, such as "RGB", "GRAY", "CMYK" or "Lab".
public string DataSpace { get; }
Property Value
Description
Gets the description (the desc tag, English when it has several languages), or null.
public string? Description { get; }
Property Value
IsDamaged
Gets whether the profile was damaged when read: a missing acsp signature, a size or offset outside it, or more
bytes than allowed. What could be read is available.
public bool IsDamaged { get; }
Property Value
Model
Gets the color model of the data space, or null when it is not RGB, gray, CMYK or 2 to 15 colorants (2CLR to FCLR), the spaces Egami converts.
public ColorModel? Model { get; }
Property Value
ProfileClass
Gets the profile class.
public IccProfileClass ProfileClass { get; }
Property Value
RenderingIntent
Gets the rendering intent the header suggests.
public RenderingIntent RenderingIntent { get; }
Property Value
Tags
Gets every tag, in the order of the tag table.
public IReadOnlyList<IccTag> Tags { get; }
Property Value
Version
Gets the profile version, such as 2.1 or 4.3.
public Version Version { get; }
Property Value
Warnings
Gets what was wrong with a damaged profile, as sentences.
public IReadOnlyList<string> Warnings { get; }
Property Value
Methods
Parse(ReadOnlySpan<byte>, SafetyLimits?)
Reads an ICC profile. Never throws: a profile larger than MaxMetadataBytes is kept but not read, and anything outside the bytes given is skipped; either way the profile is marked damaged.
public static IccData Parse(ReadOnlySpan<byte> profile, SafetyLimits? limits = null)
Parameters
profileReadOnlySpan<byte>The profile, as stored in a PNG iCCP chunk, JPEG APP2 segments or a TIFF tag.
limitsSafetyLimitsThe limits whose MaxMetadataBytes caps the profile size. Defaults to Default.
Returns
Examples
// IccData reads a profile's header and tags; it never throws, and says what was wrong with a damaged one.
IccData icc = IccData.Parse(bytes);
Console.WriteLine($"{icc.Description}: version {icc.Version}, {icc.ProfileClass}, {icc.DataSpace} to {icc.ConnectionSpace}, damaged: {icc.IsDamaged}");
foreach (IccTag tag in icc.Tags)
{
Console.WriteLine($" {tag.Signature} ({tag.Type}), {tag.Data.Length} bytes");
}
// ColorProfile.FromIcc makes an encoding from it: a matrix profile gets its primaries and curve, so an ICC profile written
// for Display P3 is equivalent to the built-in.
ColorProfile profile = ColorProfile.FromIcc(icc);
bool isP3 = profile.IsEquivalentTo(ColorProfile.DisplayP3);
ToBytes()
Returns the profile's bytes, exactly as given to Parse(ReadOnlySpan<byte>, SafetyLimits?).
public ReadOnlyMemory<byte> ToBytes()
Returns
- ReadOnlyMemory<byte>
The bytes.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
TryGetTag(string, out IccTag)
Returns the tag with this signature, if the profile has it.
public bool TryGetTag(string signature, out IccTag tag)
Parameters
signaturestringThe tag signature, such as "rTRC"; trailing spaces are optional.
tagIccTagThe tag, or the default value.
Returns
- bool
Whether the profile has the tag.