Base class for all types of color. There are two types of colors: Colors that manage their own values and colors that point to values in memory. Colors that point to values in memory have the suffix Data, where colors that manage their own values don't: ie: RGBColor8 is a color that holds 3 RGB uint8 (Byte) color values. RGBColorData8 on the other hand holds 3 pointers to RGB uint8 (Byte) values and does not own the data it points to. Colors that point to values in memory are useful when working with bitmaps and a copy is often unnecessary. They're also very useful to change the color value of a pixel in a bitmap directly, look at conversion for more info.
Converts and copies the values associated with this color in to the target color. Channels that can't be converted are initialized to 0. When converting to and from float colors, normalized color values are used. Float values that do not fall within the 0-1 range are clamped. When the target does not manage it's own color values, ie: holds pointers to color values in memory, the values that are pointed to in target are overridden. This makes it possible (for example) to write colors directly in to a bitmap without having to copy them over.
This is therefore valid (source)RGBAColorData8 -> (target)RGBColor8, the target will have a copy of the values pointed to by it's source The following is also valid: (source)RGBColor8 -> (target)RGBColorData8, the target will have the values it points to replaced by the converted color value
- Parameters
-
target | the converted color value |
Converts the color values in source Color to target Color using the given conversion method It's required that the from color has an equal or higher amount of color channels Therefore this conversion is valid: RGBA8 to RGBFloat, but not: RGB8 to RGBAFloat The following is also valid: RGBColorData16 to RGBColorFloat or, RGBAColorData8 to RGBColorData16 When converting to and from float colors, normalized color values are used. Float values that do not fall within the 0-1 range are clamped When the target does not manage it's own color values, ie: holds pointers to color values in memory, the values that are pointed to are overridden by the result of the conversion This makes it possible (for example) to write colors directly in to a bitmap without having to copy them over.
This call is faster than the default convertColor method and is recommended to be used in loops! Make sure to call getConverter() before staring the loop to acquire the right conversion method
- Parameters
-
source | the color to convert |
target | holds the converted color values |
converter | the method used to convert source color into target color |