CieXyz Struct

A color in the CIE 1931 XYZ color space: the tristimulus values X, Y (the luminance) and Z.

public readonly struct CieXyz : IEquatable<CieXyz>

Remarks

The values are relative: the white of a color space has a luminance CieXyz.Y of 1. The conversions of the library give and take CIEXYZ relative to CieXyz.D50, the white of CIELAB in CSS and of the ICC profile connection space: colors given relative to another white are first brought to D50 with CieXyz.Adapt.

The values are not validated: negative values (imaginary colors) and values that are not numbers are kept as they are.

Implements

Constructors

NameDescription
CieXyz(double, double, double)Initializes a new instance of the CieXyz struct.

CieXyz(double, double, double)

CieXyz.cs

Initializes a new instance of the CieXyz struct.

public CieXyz(double x, double y, double z)

Parameters

x double
The X tristimulus value.
y double
The Y tristimulus value, the luminance.
z double
The Z tristimulus value.

Properties

NameDescription
D50Gets the CIE illuminant D50, from its chromaticity (0.3457, 0.3585), with a luminance of 1, as CSS Color 4 defines it.
D65Gets the CIE illuminant D65, the white of sRGB, from its chromaticity (0.3127, 0.3290), with a luminance of 1, as CSS Color 4 defines it.
XGets the X tristimulus value.
YGets the Y tristimulus value, the luminance.
ZGets the Z tristimulus value.

Gets the CIE illuminant D50, from its chromaticity (0.3457, 0.3585), with a luminance of 1, as CSS Color 4 defines it.

public static CieXyz D50 { get; }

Property value

CieXyz

Gets the CIE illuminant D65, the white of sRGB, from its chromaticity (0.3127, 0.3290), with a luminance of 1, as CSS Color 4 defines it.

public static CieXyz D65 { get; }

Property value

CieXyz

Gets the X tristimulus value.

public double X { get; }

Property value

double

Gets the Y tristimulus value, the luminance.

public double Y { get; }

Property value

double

Gets the Z tristimulus value.

public double Z { get; }

Property value

double

Methods

NameDescription
Adapt(CieXyz, CieXyz)Adapts this color from a white to another with the linear Bradford transform: the color that looks, under the destination white, as this color looks under the source white.
Equals(CieXyz)Indicates whether the current object is equal to another object of the same type.
Equals(object?)Indicates whether this instance and a specified object are equal.
FromRgb(Rgba32, RgbColorSpace?)Converts an 8-bit RGB color to CIEXYZ relative to CieXyz.D50. Alpha is ignored.
FromRgb(Rgba64, RgbColorSpace?)Converts a 16-bit RGB color to CIEXYZ relative to CieXyz.D50. Alpha is ignored.
GetHashCode()Returns the hash code for this instance.
ToRgba32(RgbColorSpace?)Converts this color, relative to CieXyz.D50, to an opaque 8-bit RGB color, clipped to the gamut of the space component by component.
ToRgba64(RgbColorSpace?)Converts this color, relative to CieXyz.D50, to an opaque 16-bit RGB color, clipped to the gamut of the space component by component.
ToString()Returns the fully qualified type name of this instance.

Adapt(CieXyz, CieXyz)

CieXyz.cs

Adapts this color from a white to another with the linear Bradford transform: the color that looks, under the destination white, as this color looks under the source white.

public CieXyz Adapt(CieXyz sourceWhite, CieXyz destinationWhite)

Parameters

sourceWhite CieXyz
The white this color is relative to, such as CieXyz.D65.
destinationWhite CieXyz
The white of the result, such as CieXyz.D50.

Returns

CieXyz The adapted color; the source white becomes the destination white.

Equals overloads

Equals(CieXyz)

CieXyz.cs

Indicates whether the current object is equal to another object of the same type.

public bool Equals(CieXyz other)
Parameters
other CieXyz
An object to compare with this object.
Returns

bool true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

CieXyz.cs

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)
Parameters
obj object?
The object to compare with the current instance.
Returns

bool true if obj and this instance are the same type and represent the same value; otherwise, false.

FromRgb overloads

FromRgb(Rgba32, RgbColorSpace?)

CieXyz.cs

Converts an 8-bit RGB color to CIEXYZ relative to CieXyz.D50. Alpha is ignored.

public static CieXyz FromRgb(Rgba32 color, RgbColorSpace? colorSpace = null)
Parameters
color Rgba32
The color.
colorSpace RgbColorSpace?
The meaning of the red, green and blue values, or null for RgbColorSpace.Srgb.
Returns

CieXyz The color.

FromRgb(Rgba64, RgbColorSpace?)

CieXyz.cs

Converts a 16-bit RGB color to CIEXYZ relative to CieXyz.D50. Alpha is ignored.

public static CieXyz FromRgb(Rgba64 color, RgbColorSpace? colorSpace = null)
Parameters
color Rgba64
The color.
colorSpace RgbColorSpace?
The meaning of the red, green and blue values, or null for RgbColorSpace.Srgb.
Returns

CieXyz The color.

GetHashCode()

CieXyz.cs

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int A 32-bit signed integer that is the hash code for this instance.

ToRgba32(RgbColorSpace?)

CieXyz.cs

Converts this color, relative to CieXyz.D50, to an opaque 8-bit RGB color, clipped to the gamut of the space component by component.

public Rgba32 ToRgba32(RgbColorSpace? colorSpace = null)

Parameters

colorSpace RgbColorSpace?
The meaning of the red, green and blue values, or null for RgbColorSpace.Srgb.

Returns

Rgba32 The color.

Exceptions

UnsupportedImageFeatureException
The space cannot convert colors to RGB values (RgbColorSpace.CanConvertFromXyz).

ToRgba64(RgbColorSpace?)

CieXyz.cs

Converts this color, relative to CieXyz.D50, to an opaque 16-bit RGB color, clipped to the gamut of the space component by component.

public Rgba64 ToRgba64(RgbColorSpace? colorSpace = null)

Parameters

colorSpace RgbColorSpace?
The meaning of the red, green and blue values, or null for RgbColorSpace.Srgb.

Returns

Rgba64 The color.

Exceptions

UnsupportedImageFeatureException
The space cannot convert colors to RGB values (RgbColorSpace.CanConvertFromXyz).

ToString()

CieXyz.cs

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string The fully qualified type name.

Operators

NameDescription
operator ==(CieXyz, CieXyz)Compares two colors for equality, component by component.
operator !=(CieXyz, CieXyz)Compares two colors for inequality, component by component.

operator ==(CieXyz, CieXyz)

CieXyz.cs

Compares two colors for equality, component by component.

public static bool operator ==(CieXyz left, CieXyz right)

Parameters

left CieXyz
The first color.
right CieXyz
The second color.

Returns

bool true if all the components are equal; otherwise false.

operator !=(CieXyz, CieXyz)

CieXyz.cs

Compares two colors for inequality, component by component.

public static bool operator !=(CieXyz left, CieXyz right)

Parameters

left CieXyz
The first color.
right CieXyz
The second color.

Returns

bool true if a component differs; otherwise false.