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
| Name | Description |
|---|---|
| CieXyz(double, double, double) | Initializes a new instance of the CieXyz struct. |
CieXyz(double, double, double)
CieXyz.csProperties
| Name | Description |
|---|---|
| D50 | Gets the CIE illuminant D50, from its chromaticity (0.3457, 0.3585), with a luminance of 1, as CSS Color 4 defines it. |
| D65 | 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. |
| X | Gets the X tristimulus value. |
| Y | Gets the Y tristimulus value, the luminance. |
| Z | Gets the Z tristimulus value. |
D50
CieXyz.csD65
CieXyz.csMethods
| Name | Description |
|---|---|
| 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.csAdapts 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.
Parameters
sourceWhiteCieXyz- The white this color is relative to, such as
CieXyz.D65. destinationWhiteCieXyz- The white of the result, such as
CieXyz.D50.
Returns
CieXyz The adapted color; the source white becomes the destination white.
FromRgb overloads
FromRgb(Rgba32, RgbColorSpace?)
CieXyz.csConverts an 8-bit RGB color to CIEXYZ relative to CieXyz.D50. Alpha is ignored.
public static CieXyz FromRgb(Rgba32 color, RgbColorSpace? colorSpace = null)Parameters
colorRgba32- The color.
colorSpaceRgbColorSpace?- The meaning of the red, green and blue values, or
nullforRgbColorSpace.Srgb.
Returns
CieXyz The color.
FromRgb(Rgba64, RgbColorSpace?)
CieXyz.csConverts a 16-bit RGB color to CIEXYZ relative to CieXyz.D50. Alpha is ignored.
public static CieXyz FromRgb(Rgba64 color, RgbColorSpace? colorSpace = null)Parameters
colorRgba64- The color.
colorSpaceRgbColorSpace?- The meaning of the red, green and blue values, or
nullforRgbColorSpace.Srgb.
Returns
CieXyz The color.
GetHashCode()
CieXyz.csToRgba32(RgbColorSpace?)
CieXyz.csConverts 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
colorSpaceRgbColorSpace?- The meaning of the red, green and blue values, or
nullforRgbColorSpace.Srgb.
Returns
Rgba32 The color.
Exceptions
UnsupportedImageFeatureException- The space cannot convert colors to RGB values (
RgbColorSpace.CanConvertFromXyz).
ToRgba64(RgbColorSpace?)
CieXyz.csConverts 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
colorSpaceRgbColorSpace?- The meaning of the red, green and blue values, or
nullforRgbColorSpace.Srgb.
Returns
Rgba64 The color.
Exceptions
UnsupportedImageFeatureException- The space cannot convert colors to RGB values (
RgbColorSpace.CanConvertFromXyz).
ToString()
CieXyz.csOperators
| Name | Description |
|---|---|
| operator ==(CieXyz, CieXyz) | Compares two colors for equality, component by component. |
| operator !=(CieXyz, CieXyz) | Compares two colors for inequality, component by component. |