RgbColorSpace Class

The meaning of red, green and blue values: how the color value types (CieXyz, CieLab, Oklab, ...) read an Rgba32 or Rgba64 color and write one. Instances are immutable and thread-safe: create one once and reuse it.

public sealed class RgbColorSpace

Remarks

RgbColorSpace.Srgb, the default of every conversion, follows the sample code of CSS Color Module Level 4: the sRGB transfer function, the rational sRGB matrix to CIEXYZ relative to D65, and the linear Bradford adaptation to D50 that CSS publishes. A space created from an ICC profile converts with the profile (the relative colorimetric intent), to the CIEXYZ of the profile connection space, whose white (D50 as ICC.1 rounds it: 0.9642, 1, 0.8249) is then adapted to CieXyz.D50 with the linear Bradford transform. A space created from a CICP color description converts with the functions of Rec. ITU-T H.273 and the matrix of its primaries, adapted to D50 with the linear Bradford transform.

Alpha is not a color coordinate: conversions from RGB ignore it, and conversions to RGB give opaque colors. A color outside the gamut of the space is clipped component by component, after the transfer function.

Properties

NameDescription
CanConvertFromXyzGets a value indicating whether the space can convert CIEXYZ to RGB values: false only for an ICC profile that describes one direction.
DescriptionGets a short description of the space, for diagnostics.
SrgbGets the sRGB color space of IEC 61966-2-1, as CSS Color 4 converts it. It is the default of every conversion.

CanConvertFromXyz

RgbColorSpace.cs

Gets a value indicating whether the space can convert CIEXYZ to RGB values: false only for an ICC profile that describes one direction.

public bool CanConvertFromXyz { get; }

Property value

bool

Description

RgbColorSpace.cs

Gets a short description of the space, for diagnostics.

public string Description { get; }

Property value

string

Gets the sRGB color space of IEC 61966-2-1, as CSS Color 4 converts it. It is the default of every conversion.

public static RgbColorSpace Srgb { get; }

Property value

RgbColorSpace

Methods

NameDescription
FromCicp(CicpColorDescription)Creates the color space a CICP color description (Rec. ITU-T H.273) gives to RGB samples.
FromIccProfile(IccProfile)Creates the color space an RGB ICC profile describes.
ToString()Returns a string that represents the current object.

FromCicp(CicpColorDescription)

RgbColorSpace.cs

Creates the color space a CICP color description (Rec. ITU-T H.273) gives to RGB samples.

public static RgbColorSpace FromCicp(CicpColorDescription description)

Parameters

description CicpColorDescription
The description. Its matrix coefficients and its range describe how a file stored the samples and play no part.

Returns

RgbColorSpace The color space; RgbColorSpace.Srgb for the sRGB primaries with the sRGB transfer characteristics.

Exceptions

ArgumentNullException
description is null.
UnsupportedImageFeatureException
The primaries or the transfer characteristics are reserved, or the transfer characteristics are PQ or HLG.

Remarks

Unspecified primaries (2) are those of sRGB and unspecified transfer characteristics (2) are the sRGB function, as for an image. The high dynamic range functions (PQ and HLG) are not supported: their light exceeds the white of the color values, so their colors need tone mapping, which ImageProcessingExtensions.ConvertColorProfile does.

FromIccProfile(IccProfile)

RgbColorSpace.cs

Creates the color space an RGB ICC profile describes.

public static RgbColorSpace FromIccProfile(IccProfile profile)

Parameters

profile IccProfile
An RGB profile.

Returns

RgbColorSpace The color space.

Exceptions

ArgumentNullException
profile is null.
InvalidImageContentException
The profile is malformed.
UnsupportedImageFeatureException
The profile is valid but does not describe RGB colors, or is not supported.

Remarks

The conversions use the relative colorimetric intent of the profile. A profile that cannot convert colors to its RGB values (an input profile with lookup tables only, a constant tone curve) gives a space that reads colors but cannot write them: RgbColorSpace.CanConvertFromXyz is false.

Returns a string that represents the current object.

public override string ToString()

Returns

string A string that represents the current object.