## GimpColorSpace

GimpColorSpace — Utility functions which convert colors between different color models.

## Synopsis

    struct      GimpHSL;
    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_hls_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_hls_to_rgb_int             (gint *hue,
                                                 gint *lightness,
                                                 gint *saturation);
    void        gimp_rgb_to_hsv4                (guchar *rgb,
                                                 gdouble *hue,
                                                 gdouble *saturation,
                                                 gdouble *value);
    void        gimp_hsv_to_rgb4                (guchar *rgb,
                                                 gdouble hue,
                                                 gdouble saturation,
                                                 gdouble value);

## Description

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 concert colors between different color spaces.

## Details

### struct GimpHSL

    struct GimpHSL {

      gdouble h, s, l, a;
    };

### gimp_rgb_to_hsv ()

    void        gimp_rgb_to_hsv                 (const GimpRGB *rgb,
                                                 GimpHSV *hsv);

`rgb` : |
`hsv` : |

### gimp_rgb_to_hsl ()

    void        gimp_rgb_to_hsl                 (const GimpRGB *rgb,
                                                 GimpHSL *hsl);

`rgb` : |
`hsl` : |

### gimp_rgb_to_cmyk ()

    void        gimp_rgb_to_cmyk                (const GimpRGB *rgb,
                                                 gdouble pullout,
                                                 GimpCMYK *cmyk);

`rgb` : |
`pullout` : |
`cmyk` : |

### gimp_hsv_to_rgb ()

    void        gimp_hsv_to_rgb                 (const GimpHSV *hsv,
                                                 GimpRGB *rgb);

`hsv` : |
`rgb` : |

### gimp_hsl_to_rgb ()

    void        gimp_hsl_to_rgb                 (const GimpHSL *hsl,
                                                 GimpRGB *rgb);

`hsl` : |
`rgb` : |

### gimp_cmyk_to_rgb ()

    void        gimp_cmyk_to_rgb                (const GimpCMYK *cmyk,
                                                 GimpRGB *rgb);

`cmyk` : |
`rgb` : |

### gimp_rgb_to_hwb ()

    void        gimp_rgb_to_hwb                 (const GimpRGB *rgb,
                                                 gdouble *hue,
                                                 gdouble *whiteness,
                                                 gdouble *blackness);

`rgb` : |
`hue` : |
`whiteness` : |
`blackness` : |

### gimp_hwb_to_rgb ()

    void        gimp_hwb_to_rgb                 (gdouble hue,
                                                 gdouble whiteness,
                                                 gdouble blackness,
                                                 GimpRGB *rgb);

`hue` : |
`whiteness` : |
`blackness` : |
`rgb` : |

### gimp_rgb_to_hsv_int ()

    void        gimp_rgb_to_hsv_int             (gint *red,
                                                 gint *green,
                                                 gint *blue);

`red` : |
`green` : |
`blue` : |

### gimp_hsv_to_rgb_int ()

    void        gimp_hsv_to_rgb_int             (gint *hue,
                                                 gint *saturation,
                                                 gint *value);

`hue` : |
`saturation` : |
`value` : |

### gimp_rgb_to_hls_int ()

    void        gimp_rgb_to_hls_int             (gint *red,
                                                 gint *green,
                                                 gint *blue);

`red` : |
`green` : |
`blue` : |

### gimp_rgb_to_cmyk_int ()

    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.

`red` : | the red channel; returns the cyan value (0-255)
`green` : | the green channel; returns the magenta value (0-255)
`blue` : | the blue channel; returns the yellow value (0-255)
`pullout` : | the percentage of black to pull out (0-100); returns the black value (0-255)

### gimp_cmyk_to_rgb_int ()

    void        gimp_cmyk_to_rgb_int            (gint *cyan,
                                                 gint *magenta,
                                                 gint *yellow,
                                                 gint *black);

`cyan` : |
`magenta` : |
`yellow` : |
`black` : |

### gimp_rgb_to_l_int ()

    gint        gimp_rgb_to_l_int               (gint red,
                                                 gint green,
                                                 gint blue);

`red` : |
`green` : |
`blue` : |
Returns : |

### gimp_hls_to_rgb_int ()

    void        gimp_hls_to_rgb_int             (gint *hue,
                                                 gint *lightness,
                                                 gint *saturation);

`hue` : |
`lightness` : |
`saturation` : |

### gimp_rgb_to_hsv4 ()

    void        gimp_rgb_to_hsv4                (guchar *rgb,
                                                 gdouble *hue,
                                                 gdouble *saturation,
                                                 gdouble *value);

`rgb` : |
`hue` : |
`saturation` : |
`value` : |

### gimp_hsv_to_rgb4 ()

    void        gimp_hsv_to_rgb4                (guchar *rgb,
                                                 gdouble hue,
                                                 gdouble saturation,
                                                 gdouble value);

`rgb` : |
`hue` : |
`saturation` : |
`value` : |