Table of Contents

Class IccData

Namespace
Egami.Colors
Assembly
Egami.dll

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

ColorCodePoints?

ConnectionSpace

Gets the profile connection space signature without trailing spaces: "XYZ" or "Lab".

public string ConnectionSpace { get; }

Property Value

string

Gets the copyright text (the cprt tag), or null.

public string? Copyright { get; }

Property Value

string

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

DateTime?

DataSpace

Gets the data color space signature without trailing spaces, such as "RGB", "GRAY", "CMYK" or "Lab".

public string DataSpace { get; }

Property Value

string

Description

Gets the description (the desc tag, English when it has several languages), or null.

public string? Description { get; }

Property Value

string

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

bool

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

ColorModel?

ProfileClass

Gets the profile class.

public IccProfileClass ProfileClass { get; }

Property Value

IccProfileClass

RenderingIntent

Gets the rendering intent the header suggests.

public RenderingIntent RenderingIntent { get; }

Property Value

RenderingIntent

Tags

Gets every tag, in the order of the tag table.

public IReadOnlyList<IccTag> Tags { get; }

Property Value

IReadOnlyList<IccTag>

Version

Gets the profile version, such as 2.1 or 4.3.

public Version Version { get; }

Property Value

Version

Warnings

Gets what was wrong with a damaged profile, as sentences.

public IReadOnlyList<string> Warnings { get; }

Property Value

IReadOnlyList<string>

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

profile ReadOnlySpan<byte>

The profile, as stored in a PNG iCCP chunk, JPEG APP2 segments or a TIFF tag.

limits SafetyLimits

The limits whose MaxMetadataBytes caps the profile size. Defaults to Default.

Returns

IccData

The parsed profile; IsDamaged says whether it was all readable.

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

signature string

The tag signature, such as "rTRC"; trailing spaces are optional.

tag IccTag

The tag, or the default value.

Returns

bool

Whether the profile has the tag.