![]() |
![]() |
![]() |
GIMP Color Library Reference Manual | ![]() |
---|---|---|---|---|
GimpColorSpaceGimpColorSpace — Utility functions which convert colors between different color models. |
void gimp_rgb_to_hsv (const GimpRGB *rgb, GimpHSV *hsv); void gimp_rgb_to_hsl (const GimpRGB *rgb, GimpHSL *hsl); void gimp_rgb_to_cmyk (const GimpRGB *rgb, gdouble pullout, GimpCMYK *cmyk); void gimp_hsv_to_rgb (const GimpHSV *hsv, GimpRGB *rgb); void gimp_hsl_to_rgb (const GimpHSL *hsl, GimpRGB *rgb); void gimp_cmyk_to_rgb (const GimpCMYK *cmyk, GimpRGB *rgb); void gimp_rgb_to_hwb (const GimpRGB *rgb, gdouble *hue, gdouble *whiteness, gdouble *blackness); void gimp_hwb_to_rgb (gdouble hue, gdouble whiteness, gdouble blackness, GimpRGB *rgb); void gimp_rgb_to_hsv_int (gint *red, gint *green, gint *blue); void gimp_hsv_to_rgb_int (gint *hue, gint *saturation, gint *value); void gimp_rgb_to_hsl_int (gint *red, gint *green, gint *blue); void gimp_rgb_to_cmyk_int (gint *red, gint *green, gint *blue, gint *pullout); void gimp_cmyk_to_rgb_int (gint *cyan, gint *magenta, gint *yellow, gint *black); gint gimp_rgb_to_l_int (gint red, gint green, gint blue); void gimp_hsl_to_rgb_int (gint *hue, gint *saturation, gint *lightness); void gimp_rgb_to_hsv4 (const guchar *rgb, gdouble *hue, gdouble *saturation, gdouble *value); void gimp_hsv_to_rgb4 (guchar *rgb, gdouble hue, gdouble saturation, gdouble value);
When programming pixel data manipulation functions you will often use algorithms operating on a color model different from the one GIMP uses. This file provides utility functions to convert colors between different color spaces.
void gimp_rgb_to_hsv (const GimpRGB *rgb, GimpHSV *hsv);
Does a conversion from RGB to HSV (Hue, Saturation, Value) colorspace.
|
A color value in the RGB colorspace |
|
The value converted to the HSV colorspace |
void gimp_rgb_to_hsl (const GimpRGB *rgb, GimpHSL *hsl);
Convert an RGB color value to a HSL (Hue, Saturation, Lightness) color value.
|
A color value in the RGB colorspace |
|
The value converted to HSL |
void gimp_rgb_to_cmyk (const GimpRGB *rgb, gdouble pullout, GimpCMYK *cmyk);
Does a naive conversion from RGB to CMYK colorspace. A simple
formula that doesn't take any color-profiles into account is used.
The amount of black pullout how can be controlled via the pullout
parameter. A pullout
value of 0 makes this a conversion to CMY.
A value of 1 causes the maximum amount of black to be pulled out.
|
A value in the RGB colorspace |
|
A scaling value (0-1) indicating how much black should be pulled out |
|
The input value naively converted to the CMYK colorspace |
void gimp_hsv_to_rgb (const GimpHSV *hsv, GimpRGB *rgb);
Converts a color value from HSV to RGB colorspace
|
A color value in the HSV colorspace |
|
The returned RGB value. |
void gimp_hsl_to_rgb (const GimpHSL *hsl, GimpRGB *rgb);
Convert a HSL color value to an RGB color value.
|
A color value in the HSL colorspace |
|
The value converted to a value in the RGB colorspace |
void gimp_cmyk_to_rgb (const GimpCMYK *cmyk, GimpRGB *rgb);
Does a simple transformation from the CMYK colorspace to the RGB colorspace, without taking color profiles into account.
|
A color value in the CMYK colorspace |
|
The value converted to the RGB colorspace |
void gimp_rgb_to_hwb (const GimpRGB *rgb, gdouble *hue, gdouble *whiteness, gdouble *blackness);
Theoretically, hue 0 (pure red) is identical to hue 6 in these transforms. Pure red always maps to 6 in this implementation. Therefore UNDEFINED can be defined as 0 in situations where only unsigned numbers are desired.
RGB are each on [0, 1]. Whiteness and Blackness are returned in the range [0, 1] and H is returned in the range [0, 6]. If W == 1 - B, H is undefined.
|
A color value in the RGB colorspace |
|
The hue value of the above color, in the range 0 to 6 |
|
The whiteness value of the above color, in the range 0 to 1 |
|
The blackness value of the above color, in the range 0 to 1 |
void gimp_hwb_to_rgb (gdouble hue, gdouble whiteness, gdouble blackness, GimpRGB *rgb);
H is defined in the range [0, 6] or UNDEFINED, B and W are both in the range [0, 1]. The returned RGB values are all in the range [0, 1].
|
A hue value, in the range 0 to 6 |
|
A whiteness value, in the range 0 to 1 |
|
A blackness value, in the range 0 to 1 |
|
The above color converted to the RGB colorspace |
void gimp_rgb_to_hsv_int (gint *red, gint *green, gint *blue);
The arguments are pointers to int representing channel values in the RGB colorspace, and the values pointed to are all in the range [0, 255].
The function changes the arguments to point to the HSV value corresponding, with the returned values in the following ranges: H [0, 359], S [0, 255], V [0, 255].
|
The red channel value, returns the Hue channel |
|
The green channel value, returns the Saturation channel |
|
The blue channel value, returns the Value channel |
void gimp_hsv_to_rgb_int (gint *hue, gint *saturation, gint *value);
The arguments are pointers to int, with the values pointed to in the following ranges: H [0, 360], S [0, 255], V [0, 255].
The function changes the arguments to point to the RGB value corresponding, with the returned values all in the range [0, 255].
|
The hue channel, returns the red channel |
|
The saturation channel, returns the green channel |
|
The value channel, returns the blue channel |
void gimp_rgb_to_hsl_int (gint *red, gint *green, gint *blue);
The arguments are pointers to int representing channel values in the RGB colorspace, and the values pointed to are all in the range [0, 255].
The function changes the arguments to point to the corresponding HLS value with the values pointed to in the following ranges: H [0, 360], L [0, 255], S [0, 255].
|
Red channel, returns Hue channel |
|
Green channel, returns Lightness channel |
|
Blue channel, returns Saturation channel |
void gimp_rgb_to_cmyk_int (gint *red, gint *green, gint *blue, gint *pullout);
Does a naive conversion from RGB to CMYK colorspace. A simple
formula that doesn't take any color-profiles into account is used.
The amount of black pullout how can be controlled via the pullout
parameter. A pullout
value of 0 makes this a conversion to CMY.
A value of 100 causes the maximum amount of black to be pulled out.
|
the red channel; returns the cyan value (0-255) |
|
the green channel; returns the magenta value (0-255) |
|
the blue channel; returns the yellow value (0-255) |
|
the percentage of black to pull out (0-100); returns the black value (0-255) |
void gimp_cmyk_to_rgb_int (gint *cyan, gint *magenta, gint *yellow, gint *black);
Does a naive conversion from CMYK to RGB colorspace. A simple formula that doesn't take any color-profiles into account is used.
|
the cyan channel; returns the red value (0-255) |
|
the magenta channel; returns the green value (0-255) |
|
the yellow channel; returns the blue value (0-255) |
|
the black channel (0-255); doesn't change |
gint gimp_rgb_to_l_int (gint red, gint green, gint blue);
Calculates the lightness value of an RGB triplet with the formula L = (max(R, G, B) + min (R, G, B)) / 2
|
Red channel |
|
Green channel |
|
Blue channel |
Returns : |
Luminance vaue corresponding to the input RGB value |
void gimp_hsl_to_rgb_int (gint *hue, gint *saturation, gint *lightness);
The arguments are pointers to int, with the values pointed to in the following ranges: H [0, 360], L [0, 255], S [0, 255].
The function changes the arguments to point to the RGB value corresponding, with the returned values all in the range [0, 255].
|
Hue channel, returns Red channel |
|
Saturation channel, returns Green channel |
|
Lightness channel, returns Blue channel |
void gimp_rgb_to_hsv4 (const guchar *rgb, gdouble *hue, gdouble *saturation, gdouble *value);
|
RGB triplet, rgb[0] is red channel, rgb[1] is green, rgb[2] is blue (0..255) |
|
Pointer to hue channel (0..1) |
|
Pointer to saturation channel (0..1) |
|
Pointer to value channel (0..1) |