Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Color Spaces

Andreu Correa Casablanca edited this page Mar 11, 2015 · 3 revisions

ColorSpaces are mainly handled by the AConvertibleColor class in the Litipk.ColorSharp.ColorSpaces namespace. All color spaces are represented by subclasses of the former.

Supported Color Spaces

The currently supported color spaces are:

  • CIE's 1931 XYZ : Litipk.ColorSharp.ColorSpaces.CIEXYZ .
  • CIE's 1931 xyY : Litipk.ColorSharp.ColorSpaces.CIExyY .
  • CIE's 1960 UCS/Yuv : Litipk.ColorSharp.ColorSpaces.CIEUCS .
  • sRGB (1996, from Microsoft & HP) : Litipk.ColorSharp.ColorSpaces.SRGB .

Color Conversions

All color objects share a common interface that allows you to convert objects between color spaces. There are many conversion methods. The recommended ones are:

  • T ConvertTo<T> () : That's the recommended one. You have to know the target color space in compile time, the library will do whatever is possible to convert the color without information loss.
  • AConvertibleColor ConvertTo (Type t) : If the target color space is determined at runtime, then you can use this method. The only problem is that you'll have to cast the result if you need to access type-specific properties of the result.

If you want to get rid of all the "magic" stuff, you can use the direct methods:

  • CIEXYZ ToCIEXYZ()
  • CIExyY ToCIExyY()
  • CIEUCS ToCIEUCS()
  • SRGB ToSRGB()

Color Properties

All color objects share a common interface that allows you to extract many color properties from your samples.

  • double GetCCT () - CCT (Correlated Color Temperature) : The color temperature of a light source is the temperature of an ideal black-body radiator that radiates light of comparable hue to that of the light source.
  • bool IsInsideColorSpace : Tells us if the object is a valid color sample. If we use SRGB this problem doesn't exist because the shape of the color space is a cube, but with many other color spaces, like CIE XYZ or CIE LAB, knowing at construction time if the object is a valid one it's not trivial. Because this, we provide a method that allows you to check it only if the check is needed, in order to save CPU time.
Clone this wiki locally