libgimpprint API Reference: color-conversions.c File Reference

Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

# src/main/color-conversions.c File Reference

`#include <gimp-print/gimp-print.h>`
`#include "gimp-print-internal.h"`
`#include <gimp-print/gimp-print-intl-internal.h>`
`#include <gimp-print/curve-cache.h>`
`#include <math.h>`
`#include <string.h>`
`#include "color-conversion.h"`

Go to the source code of this file.

## Defines
#define | LUM_RED 31
#define | LUM_GREEN 61
#define | LUM_BLUE 8
#define | FMAX(a, b) ((a) > (b) ? (a) : (b))
#define | FMIN(a, b) ((a) < (b) ? (a) : (b))
#define | GENERIC_COLOR_FUNC(fromname, toname)
#define | COLOR_TO_COLOR_FUNC(T, bits)
#define | FAST_COLOR_TO_COLOR_FUNC(T, bits)
#define | RAW_COLOR_TO_COLOR_FUNC(T, bits)
#define | GRAY_TO_COLOR_FUNC(T, bits)
#define | GRAY_TO_COLOR_RAW_FUNC(T, bits)
#define | COLOR_TO_KCMY_FUNC(name, name2, name3, name4, bits)
#define | COLOR_TO_KCMY_THRESHOLD_FUNC(T, name)
#define | CMYK_TO_KCMY_THRESHOLD_FUNC(T, name)
#define | KCMY_TO_KCMY_THRESHOLD_FUNC(T, name)
#define | GRAY_TO_COLOR_THRESHOLD_FUNC(T, name, bits, channels)
#define | COLOR_TO_COLOR_THRESHOLD_FUNC(T, name)
#define | COLOR_TO_GRAY_THRESHOLD_FUNC(T, name, channels, max_channels)
#define | CMYK_TO_COLOR_FUNC(namein, name2, T, bits, offset)
#define | CMYK_TO_KCMY_FUNC(T, size)
#define | KCMY_TO_KCMY_FUNC(T, size)
#define | GRAY_TO_GRAY_FUNC(T, bits)
#define | COLOR_TO_GRAY_FUNC(T, bits)
#define | CMYK_TO_GRAY_FUNC(T, bits)
#define | KCMY_TO_GRAY_FUNC(T, bits)
#define | GRAY_TO_GRAY_RAW_FUNC(T, bits)
#define | COLOR_TO_GRAY_RAW_FUNC(T, bits, invertable, name2)
#define | CMYK_TO_GRAY_RAW_FUNC(T, bits, invertable, name2)
#define | KCMY_TO_GRAY_RAW_FUNC(T, bits, invertable, name2)
#define | CMYK_TO_KCMY_RAW_FUNC(T, bits)
#define | KCMY_TO_KCMY_RAW_FUNC(T, bits)
#define | COLOR_TO_CMYKRB_FUNC(name, name2, name3, name4, bits)
#define | DESATURATED_FUNC(name, name2, bits)
#define | CMYK_DISPATCH(name)
#define | RAW_TO_RAW_THRESHOLD_FUNC(T, name)
#define | RAW_TO_RAW_FUNC(T, size)
#define | RAW_TO_RAW_RAW_FUNC(T, bits)
#define | CONVERSION_FUNCTION_WITH_FAST(from, to, from2)
#define | CONVERSION_FUNCTION_WITHOUT_FAST(from, to, from2)
#define | CONVERSION_FUNCTION_WITHOUT_DESATURATED(from, to, from2)
## Functions
void | calc_rgb_to_hsl (unsigned short *rgb, double *hue, double *sat, double *lightness)
double | hsl_value (double n1, double n2, double hue)
void | calc_hsl_to_rgb (unsigned short *rgb, double h, double s, double l)
double | update_saturation (double sat, double adjust, double isat)
double | interpolate_value (const double *vec, double val)
void | update_saturation_from_rgb (unsigned short *rgb, const unsigned short *brightness_lookup, double adjust, double isat, int do_usermap)
double | adjust_hue (const double *hue_map, double hue, size_t points)
void | adjust_hsl (unsigned short *rgbout, lut_t *lut, double ssat, double isat, int split_saturation)
void | adjust_hsl_bright (unsigned short *rgbout, lut_t *lut, double ssat, double isat, int split_saturation)
void | lookup_rgb (lut_t *lut, unsigned short *rgbout, const unsigned short *red, const unsigned short *green, const unsigned short *blue, unsigned steps)
int | short_eq (const unsigned short *i1, const unsigned short *i2, size_t count)
void | short_copy (unsigned short *out, const unsigned short *in, size_t count)
unsigned | generic_cmy_to_kcmy (const stp_vars_t *vars, const unsigned short *in, unsigned short *out)
unsigned | raw_cmy_to_kcmy (const stp_vars_t *vars, const unsigned short *in, unsigned short *out)
unsigned | generic_kcmy_to_cmykrb (const stp_vars_t *vars, const unsigned short *in, unsigned short *out)
unsigned | raw_kcmy_to_cmykrb (const stp_vars_t *vars, const unsigned short *in, unsigned short *out)
unsigned | stpi_color_convert_to_gray (const stp_vars_t *v, const unsigned char *in, unsigned short *out)
unsigned | stpi_color_convert_to_color (const stp_vars_t *v, const unsigned char *in, unsigned short *out)
unsigned | stpi_color_convert_to_kcmy (const stp_vars_t *v, const unsigned char *in, unsigned short *out)
unsigned | stpi_color_convert_to_cmykrb (const stp_vars_t *v, const unsigned char *in, unsigned short *out)
unsigned | stpi_color_convert_raw (const stp_vars_t *v, const unsigned char *in, unsigned short *out)

## Define Documentation

#define CMYK_DISPATCH | ( | name |  | ) |

| Value:
    static unsigned                                                         \
    CMYK_to_##name(const stp_vars_t *vars, const unsigned char *in,         \
                   unsigned short *out)                                     \
    {                                                                       \
      lut_t *lut = (lut_t *)(stp_get_component_data(vars, "Color"));        \
      if (lut->input_color_description->color_id == COLOR_ID_CMYK)          \
        return cmyk_to_##name(vars, in, out);                               \
      else if (lut->input_color_description->color_id == COLOR_ID_KCMY)     \
        return kcmy_to_##name(vars, in, out);                               \
      else                                                                  \
        {                                                                   \
          stp_eprintf(vars, "Bad dispatch to CMYK_to_%s: %d\n", #name,      \
                      lut->input_color_description->color_id);              \
          return 0;                                                         \
        }                                                                   \
    }
Definition at line 2099 of file color-conversions.c.

#define CMYK_TO_COLOR_FUNC | ( | namein,
|  | name2,
|  | T,
|  | bits,
|  | offset |  | ) |

| Definition at line 1206 of file color-conversions.c.

#define CMYK_TO_GRAY_FUNC | ( | T,
|  | bits |  | ) |

| Definition at line 1468 of file color-conversions.c.

#define CMYK_TO_GRAY_RAW_FUNC | ( | T,
|  | bits,
|  | invertable,
|  | name2 |  | ) |

| Definition at line 1674 of file color-conversions.c.

#define CMYK_TO_KCMY_FUNC | ( | T,
|  | size |  | ) |

| Definition at line 1277 of file color-conversions.c.

#define CMYK_TO_KCMY_RAW_FUNC | ( | T,
|  | bits |  | ) |

| Value:
    static unsigned                                                         \
    cmyk_##bits##_to_kcmy_raw(const stp_vars_t *vars,                       \
                              const unsigned char *in,                      \
                              unsigned short *out)                          \
    {                                                                       \
      int i;                                                                \
      int j;                                                                \
      int nz[4];                                                            \
      unsigned retval = 0;                                                  \
      const T *s_in = (const T *) in;                                       \
      lut_t *lut = (lut_t *)(stp_get_component_data(vars, "Color"));        \
                                                                            \
      memset(nz, 0, sizeof(nz));                                            \
      for (i = 0; i < lut->image_width; i++)                                \
        {                                                                   \
          out[0] = s_in[3] * (65535 / ((1 << bits) - 1));                   \
          out[1] = s_in[0] * (65535 / ((1 << bits) - 1));                   \
          out[2] = s_in[1] * (65535 / ((1 << bits) - 1));                   \
          out[3] = s_in[2] * (65535 / ((1 << bits) - 1));                   \
          for (j = 0; j < 4; j++)                                           \
            nz[j] |= out[j];                                                \
          s_in += 4;                                                        \
          out += 4;                                                         \
        }                                                                   \
      for (j = 0; j < 4; j++)                                               \
        if (nz[j] == 0)                                                     \
          retval |= (1 << j);                                               \
      return retval;                                                        \
    }
Definition at line 1792 of file color-conversions.c.

#define CMYK_TO_KCMY_THRESHOLD_FUNC | ( | T,
|  | name |  | ) |

| Definition at line 988 of file color-conversions.c.

#define COLOR_TO_CMYKRB_FUNC | ( | name,
|  | name2,
|  | name3,
|  | name4,
|  | bits |  | ) |

| Value:
    static unsigned                                                             \
    name##_##bits##_to_##name2(const stp_vars_t *vars, const unsigned char *in, \
                              unsigned short *out)                              \
    {                                                                           \
      lut_t *lut = (lut_t *)(stp_get_component_data(vars, "Color"));            \
      size_t real_steps = lut->steps;                                           \
      unsigned status;                                                          \
      if (!lut->cmyk_tmp)                                                       \
        lut->cmyk_tmp = stp_malloc(4 * 2 * lut->image_width);                   \
      name##_##bits##_to_##name3(vars, in, lut->cmyk_tmp);                      \
      lut->steps = 65536;                                                       \
      status = name4##_kcmy_to_cmykrb(vars, lut->cmyk_tmp, out);                \
      lut->steps = real_steps;                                                  \
      return status;                                                            \
    }
Definition at line 1985 of file color-conversions.c.

#define COLOR_TO_COLOR_FUNC | ( | T,
|  | bits |  | ) |

| Definition at line 567 of file color-conversions.c.

#define COLOR_TO_COLOR_THRESHOLD_FUNC | ( | T,
|  | name |  | ) |

| Definition at line 1114 of file color-conversions.c.

#define COLOR_TO_GRAY_FUNC | ( | T,
|  | bits |  | ) |

| Definition at line 1411 of file color-conversions.c.

#define COLOR_TO_GRAY_RAW_FUNC | ( | T,
|  | bits,
|  | invertable,
|  | name2 |  | ) |

| Definition at line 1619 of file color-conversions.c.

#define COLOR_TO_GRAY_THRESHOLD_FUNC | ( | T,
|  | name,
|  | channels,
|  | max_channels |  | ) |

| Definition at line 1156 of file color-conversions.c.

#define COLOR_TO_KCMY_FUNC | ( | name,
|  | name2,
|  | name3,
|  | name4,
|  | bits |  | ) |

| Value:
    static unsigned                                                             \
    name##_##bits##_to_##name2(const stp_vars_t *vars, const unsigned char *in, \
                               unsigned short *out)                             \
    {                                                                           \
      lut_t *lut = (lut_t *)(stp_get_component_data(vars, "Color"));            \
      size_t real_steps = lut->steps;                                           \
      unsigned status;                                                          \
      if (!lut->cmy_tmp)                                                        \
        lut->cmy_tmp = stp_malloc(4 * 2 * lut->image_width);                    \
      name##_##bits##_to_##name3(vars, in, lut->cmy_tmp);                       \
      lut->steps = 65536;                                                       \
      status = name4##_cmy_to_kcmy(vars, lut->cmy_tmp, out);                    \
      lut->steps = real_steps;                                                  \
      return status;                                                            \
    }
Definition at line 893 of file color-conversions.c.

#define COLOR_TO_KCMY_THRESHOLD_FUNC | ( | T,
|  | name |  | ) |

| Definition at line 931 of file color-conversions.c.

#define CONVERSION_FUNCTION_WITH_FAST | ( | from,
|  | to,
|  | from2 |  | ) |

| Value:
    static unsigned                                                 \
    generic_##from##_to_##to(const stp_vars_t *v,                   \
                             const unsigned char *in,               \
                             unsigned short *out)                   \
    {                                                               \
      lut_t *lut = (lut_t *)(stp_get_component_data(v, "Color"));   \
      switch (lut->color_correction->correction)                    \
        {                                                           \
        case COLOR_CORRECTION_UNCORRECTED:                          \
          return from2##_to_##to##_fast(v, in, out);                \
        case COLOR_CORRECTION_ACCURATE:                             \
        case COLOR_CORRECTION_BRIGHT:                               \
          return from2##_to_##to(v, in, out);                       \
        case COLOR_CORRECTION_DESATURATED:                          \
          return from2##_to_##to##_desaturated(v, in, out);         \
        case COLOR_CORRECTION_THRESHOLD:                            \
        case COLOR_CORRECTION_PREDITHERED:                          \
          return from2##_to_##to##_threshold(v, in, out);           \
        case COLOR_CORRECTION_DENSITY:                              \
        case COLOR_CORRECTION_RAW:                                  \
          return from2##_to_##to##_raw(v, in, out);                 \
        default:                                                    \
          return (unsigned) -1;                                     \
        }                                                           \
    }
Definition at line 2256 of file color-conversions.c.

#define CONVERSION_FUNCTION_WITHOUT_DESATURATED | ( | from,
|  | to,
|  | from2 |  | ) |

| Value:
    static unsigned                                                         \
    generic_##from##_to_##to(const stp_vars_t *v,                           \
                             const unsigned char *in,                       \
                             unsigned short *out)                           \
    {                                                                       \
      lut_t *lut = (lut_t *)(stp_get_component_data(v, "Color"));           \
      switch (lut->color_correction->correction)                            \
        {                                                                   \
        case COLOR_CORRECTION_UNCORRECTED:                                  \
        case COLOR_CORRECTION_ACCURATE:                                     \
        case COLOR_CORRECTION_BRIGHT:                                       \
        case COLOR_CORRECTION_DESATURATED:                                  \
          return from2##_to_##to(v, in, out);                               \
        case COLOR_CORRECTION_THRESHOLD:                                    \
        case COLOR_CORRECTION_PREDITHERED:                                  \
          return from2##_to_##to##_threshold(v, in, out);                   \
        case COLOR_CORRECTION_DENSITY:                                      \
        case COLOR_CORRECTION_RAW:                                          \
          return from2##_to_##to##_raw(v, in, out);                         \
        default:                                                            \
          return (unsigned) -1;                                             \
        }                                                                   \
    }
Definition at line 2309 of file color-conversions.c.

#define CONVERSION_FUNCTION_WITHOUT_FAST | ( | from,
|  | to,
|  | from2 |  | ) |

| Value:
    static unsigned                                                 \
    generic_##from##_to_##to(const stp_vars_t *v,                   \
                             const unsigned char *in,               \
                             unsigned short *out)                   \
    {                                                               \
      lut_t *lut = (lut_t *)(stp_get_component_data(v, "Color"));   \
      switch (lut->color_correction->correction)                    \
        {                                                           \
        case COLOR_CORRECTION_UNCORRECTED:                          \
        case COLOR_CORRECTION_ACCURATE:                             \
        case COLOR_CORRECTION_BRIGHT:                               \
          return from2##_to_##to(v, in, out);                       \
        case COLOR_CORRECTION_DESATURATED:                          \
          return from2##_to_##to##_desaturated(v, in, out);         \
        case COLOR_CORRECTION_THRESHOLD:                            \
        case COLOR_CORRECTION_PREDITHERED:                          \
          return from2##_to_##to##_threshold(v, in, out);           \
        case COLOR_CORRECTION_DENSITY:                              \
        case COLOR_CORRECTION_RAW:                                  \
          return from2##_to_##to##_raw(v, in, out);                 \
        default:                                                    \
          return (unsigned) -1;                                     \
        }                                                           \
    }
Definition at line 2283 of file color-conversions.c.

#define DESATURATED_FUNC | ( | name,
|  | name2,
|  | bits |  | ) |

| Value:
    static unsigned                                                            \
    name##_##bits##_to_##name2##_desaturated(const stp_vars_t *vars,           \
                                             const unsigned char *in,          \
                                             unsigned short *out)              \
    {                                                                          \
      lut_t *lut = (lut_t *)(stp_get_component_data(vars, "Color"));           \
      size_t real_steps = lut->steps;                                          \
      unsigned status;                                                         \
      if (!lut->gray_tmp)                                                      \
        lut->gray_tmp = stp_malloc(2 * lut->image_width);                      \
      name##_##bits##_to_gray_noninvert(vars, in, lut->gray_tmp);              \
      lut->steps = 65536;                                                      \
      status = gray_16_to_##name2(vars, (unsigned char *) lut->gray_tmp, out); \
      lut->steps = real_steps;                                                 \
      return status;                                                           \
    }
Definition at line 2051 of file color-conversions.c.

#define FAST_COLOR_TO_COLOR_FUNC | ( | T,
|  | bits |  | ) |

| Definition at line 673 of file color-conversions.c.

#define FMAX | ( | a,
|  | b |  | ) | ((a) > (b) ? (a) : (b))

| Definition at line 57 of file color-conversions.c.

#define FMIN | ( | a,
|  | b |  | ) | ((a) < (b) ? (a) : (b))

| Definition at line 58 of file color-conversions.c. Referenced by calc_rgb_to_hsl(), generic_cmy_to_kcmy(), generic_kcmy_to_cmykrb(), raw_cmy_to_kcmy(), raw_kcmy_to_cmykrb(), and update_saturation().

#define GENERIC_COLOR_FUNC | ( | fromname,
|  | toname |  | ) |

| Value:
    static unsigned                                                         \
    fromname##_to_##toname(const stp_vars_t *vars, const unsigned char *in, \
                           unsigned short *out)                             \
    {                                                                       \
      lut_t *lut = (lut_t *)(stp_get_component_data(vars, "Color"));        \
      if (!lut->printed_colorfunc)                                          \
        {                                                                   \
          lut->printed_colorfunc = 1;                                       \
          stp_dprintf(STP_DBG_COLORFUNC, vars,                              \
                       "Colorfunc is %s_%d_to_%s, %s, %s, %d, %d\n",        \
                       #fromname, lut->channel_depth, #toname,              \
                       lut->input_color_description->name,                  \
                       lut->output_color_description->name,                 \
                       lut->steps, lut->invert_output);                     \
        }                                                                   \
      if (lut->channel_depth == 8)                                          \
        return fromname##_8_to_##toname(vars, in, out);                     \
      else                                                                  \
        return fromname##_16_to_##toname(vars, in, out);                    \
    }
Definition at line 545 of file color-conversions.c.

#define GRAY_TO_COLOR_FUNC | ( | T,
|  | bits |  | ) |

| Definition at line 798 of file color-conversions.c.

#define GRAY_TO_COLOR_RAW_FUNC | ( | T,
|  | bits |  | ) |

| Value:
    static unsigned                                                            \
    gray_##bits##_to_color_raw(const stp_vars_t *vars, const unsigned char *in,\
                               unsigned short *out)                            \
    {                                                                          \
      int i;                                                                   \
      int nz = 7;                                                              \
      const T *s_in = (const T *) in;                                          \
      lut_t *lut = (lut_t *)(stp_get_component_data(vars, "Color"));           \
      unsigned mask = 0;                                                       \
      if (lut->invert_output)                                                  \
        mask = 0xffff;                                                         \
                                                                               \
      for (i = 0; i < lut->image_width; i++)                                   \
        {                                                                      \
          unsigned outval = (s_in[0] * (65535 / (1 << bits))) ^ mask;          \
          out[0] = outval;                                                     \
          out[1] = outval;                                                     \
          out[2] = outval;                                                     \
          if (outval)                                                          \
            nz = 0;                                                            \
          s_in++;                                                              \
          out += 3;                                                            \
        }                                                                      \
      return nz;                                                               \
    }
Definition at line 862 of file color-conversions.c.

#define GRAY_TO_COLOR_THRESHOLD_FUNC | ( | T,
|  | name,
|  | bits,
|  | channels |  | ) |

| Value:
    static unsigned                                                         \
    gray_##bits##_to_##name##_threshold(const stp_vars_t *vars,             \
                                        const unsigned char *in,            \
                                        unsigned short *out)                \
    {                                                                       \
      int i;                                                                \
      int z = (1 << channels) - 1;                                          \
      int desired_high_bit = 0;                                             \
      unsigned high_bit = 1 << ((sizeof(T) * 8) - 1);                       \
      const T *s_in = (const T *) in;                                       \
      lut_t *lut = (lut_t *)(stp_get_component_data(vars, "Color"));        \
      int width = lut->image_width;                                         \
      memset(out, 0, width * channels * sizeof(unsigned short));            \
      if (!lut->invert_output)                                              \
        desired_high_bit = high_bit;                                        \
                                                                            \
      for (i = 0; i < width; i++, out += channels, s_in++)                  \
        {                                                                   \
          if ((s_in[0] & high_bit) == desired_high_bit)                     \
            {                                                               \
              int j;                                                        \
              z = 0;                                                        \
              for (j = 0; j < channels; j++)                                \
                out[j] = 65535;                                             \
            }                                                               \
        }                                                                   \
      return z;                                                             \
    }
Definition at line 1075 of file color-conversions.c.

#define GRAY_TO_GRAY_FUNC | ( | T,
|  | bits |  | ) |

| Definition at line 1367 of file color-conversions.c.

#define GRAY_TO_GRAY_RAW_FUNC | ( | T,
|  | bits |  | ) |

| Value:
    static unsigned                                                         \
    gray_##bits##_to_gray_raw(const stp_vars_t *vars,                       \
                              const unsigned char *in,                      \
                              unsigned short *out)                          \
    {                                                                       \
      int i;                                                                \
      int nz = 0;                                                           \
      const T *s_in = (const T *) in;                                       \
      lut_t *lut = (lut_t *)(stp_get_component_data(vars, "Color"));        \
      int width = lut->image_width;                                         \
      unsigned mask = 0;                                                    \
      if (lut->invert_output)                                               \
        mask = 0xffff;                                                      \
                                                                            \
      memset(out, 0, width * sizeof(unsigned short));                       \
                                                                            \
      for (i = 0; i < lut->image_width; i++)                                \
        {                                                                   \
          out[0] = (s_in[0] * (65535 / ((1 << bits) - 1))) ^ mask;          \
          nz |= out[0];                                                     \
          s_in ++;                                                          \
          out ++;                                                           \
        }                                                                   \
      return nz == 0;                                                       \
    }
Definition at line 1588 of file color-conversions.c.

#define KCMY_TO_GRAY_FUNC | ( | T,
|  | bits |  | ) |

| Definition at line 1528 of file color-conversions.c.

#define KCMY_TO_GRAY_RAW_FUNC | ( | T,
|  | bits,
|  | invertable,
|  | name2 |  | ) |

| Definition at line 1733 of file color-conversions.c.

#define KCMY_TO_KCMY_FUNC | ( | T,
|  | size |  | ) |

| Definition at line 1322 of file color-conversions.c.

#define KCMY_TO_KCMY_RAW_FUNC | ( | T,
|  | bits |  | ) |

| Value:
    static unsigned                                                         \
    kcmy_##bits##_to_kcmy_raw(const stp_vars_t *vars,                       \
                              const unsigned char *in,                      \
                              unsigned short *out)                          \
    {                                                                       \
      int i;                                                                \
      int j;                                                                \
      int nz[4];                                                            \
      unsigned retval = 0;                                                  \
      const T *s_in = (const T *) in;                                       \
      lut_t *lut = (lut_t *)(stp_get_component_data(vars, "Color"));        \
                                                                            \
      memset(nz, 0, sizeof(nz));                                            \
      for (i = 0; i < lut->image_width; i++)                                \
        {                                                                   \
          for (j = 0; j < 4; j++)                                           \
            {                                                               \
              out[j] = s_in[j] * (65535 / ((1 << bits) - 1));               \
              nz[j] |= out[j];                                              \
            }                                                               \
          s_in += 4;                                                        \
          out += 4;                                                         \
        }                                                                   \
      for (j = 0; j < 4; j++)                                               \
        if (nz[j] == 0)                                                     \
          retval |= (1 << j);                                               \
      return retval;                                                        \
    }
Definition at line 1827 of file color-conversions.c.

#define KCMY_TO_KCMY_THRESHOLD_FUNC | ( | T,
|  | name |  | ) |

| Definition at line 1035 of file color-conversions.c.

#define LUM_BLUE 8

| Definition at line 53 of file color-conversions.c.

#define LUM_GREEN 61

| Definition at line 52 of file color-conversions.c.

#define LUM_RED 31

| Definition at line 51 of file color-conversions.c.

#define RAW_COLOR_TO_COLOR_FUNC | ( | T,
|  | bits |  | ) |

| Value:
    static unsigned                                                             \
    color_##bits##_to_color_raw(const stp_vars_t *vars, const unsigned char *in,\
                                unsigned short *out)                            \
    {                                                                           \
      int i;                                                                    \
      int j;                                                                    \
      int nz = 0;                                                               \
      const T *s_in = (const T *) in;                                           \
      lut_t *lut = (lut_t *)(stp_get_component_data(vars, "Color"));            \
      unsigned mask = 0;                                                        \
      if (lut->invert_output)                                                   \
        mask = 0xffff;                                                          \
                                                                                \
      for (i = 0; i < lut->image_width; i++)                                    \
        {                                                                       \
          unsigned bit = 1;                                                     \
          for (j = 0; j < 3; j++, bit += bit)                                   \
            {                                                                   \
              out[j] = (s_in[j] * (65535 / ((1 << bits) - 1))) ^ mask;          \
              if (out[j])                                                       \
                nz |= bit;                                                      \
            }                                                                   \
          s_in += 3;                                                            \
          out += 3;                                                             \
        }                                                                       \
      return nz;                                                                \
    }
Definition at line 761 of file color-conversions.c.

#define RAW_TO_RAW_FUNC | ( | T,
|  | size |  | ) |

| Definition at line 2175 of file color-conversions.c.

#define RAW_TO_RAW_RAW_FUNC | ( | T,
|  | bits |  | ) |

| Value:
    static unsigned                                                         \
    raw_##bits##_to_raw_raw(const stp_vars_t *vars,                         \
                            const unsigned char *in,                        \
                            unsigned short *out)                            \
    {                                                                       \
      int i;                                                                \
      int j;                                                                \
      int nz[STP_CHANNEL_LIMIT];                                            \
      unsigned retval = 0;                                                  \
      const T *s_in = (const T *) in;                                       \
      lut_t *lut = (lut_t *)(stp_get_component_data(vars, "Color"));        \
      int colors = lut->in_channels;                                        \
                                                                            \
      memset(nz, 0, sizeof(nz));                                            \
      for (i = 0; i < lut->image_width; i++)                                \
        {                                                                   \
          for (j = 0; j < colors; j++)                                      \
            {                                                               \
              nz[j] |= s_in[j];                                             \
              out[j] = s_in[j] * (65535 / ((1 << bits) - 1));               \
            }                                                               \
          s_in += colors;                                                   \
          out += colors;                                                    \
        }                                                                   \
      for (j = 0; j < colors; j++)                                          \
        if (nz[j] == 0)                                                     \
          retval |= (1 << j);                                               \
      return retval;                                                        \
    }
Definition at line 2220 of file color-conversions.c.

#define RAW_TO_RAW_THRESHOLD_FUNC | ( | T,
|  | name |  | ) |

| Definition at line 2135 of file color-conversions.c.

## Function Documentation

void adjust_hsl | ( | unsigned short * | rgbout,
|  | lut_t * | lut,
|  | double | ssat,
|  | double | isat,
|  | int | split_saturation
| ) | `[inline, static]`

| Definition at line 246 of file color-conversions.c. References adjust_hue(), calc_hsl_to_rgb(), calc_rgb_to_hsl(), CURVE_CACHE_FAST_COUNT, CURVE_CACHE_FAST_DOUBLE, stp_cached_curve_t::d_cache, lut_t::hue_map, interpolate_value(), lut_t::lum_map, lut_t::sat_map, and update_saturation().

void adjust_hsl_bright | ( | unsigned short * | rgbout,
|  | lut_t * | lut,
|  | double | ssat,
|  | double | isat,
|  | int | split_saturation
| ) | `[inline, static]`

| Definition at line 319 of file color-conversions.c. References adjust_hue(), calc_hsl_to_rgb(), calc_rgb_to_hsl(), CURVE_CACHE_FAST_COUNT, CURVE_CACHE_FAST_DOUBLE, lut_t::hue_map, interpolate_value(), lut_t::lum_map, and update_saturation().

double adjust_hue | ( | const double * | hue_map,
|  | double | hue,
|  | size_t | points
| ) | `[inline, static]`

| Definition at line 232 of file color-conversions.c. References interpolate_value(). Referenced by adjust_hsl(), and adjust_hsl_bright().

void calc_hsl_to_rgb | ( | unsigned short * | rgb,
|  | double | h,
|  | double | s,
|  | double | l
| ) | `[inline, static]`

| Definition at line 154 of file color-conversions.c. References hsl_value(). Referenced by adjust_hsl(), adjust_hsl_bright(), and update_saturation_from_rgb().

void calc_rgb_to_hsl | ( | unsigned short * | rgb,
|  | double * | hue,
|  | double * | sat,
|  | double * | lightness
| ) | `[inline, static]`

| Definition at line 61 of file color-conversions.c. References FMIN, and max. Referenced by adjust_hsl(), adjust_hsl_bright(), and update_saturation_from_rgb().

unsigned generic_cmy_to_kcmy | ( | const stp_vars_t * | vars,
|  | const unsigned short * | in,
|  | unsigned short * | out
| ) | `[static]`

| Definition at line 396 of file color-conversions.c. References lut_t::channel_curves, CHANNEL_K, FMIN, lut_t::gcr_curve, lut_t::image_width, lut_t::steps, stp_curve_cache_get_curve(), stp_curve_cache_get_ushort_data(), stp_curve_resample(), stp_get_component_data(), and stp_vars_t.

unsigned generic_kcmy_to_cmykrb | ( | const stp_vars_t * | vars,
|  | const unsigned short * | in,
|  | unsigned short * | out
| ) | `[static]`

| Definition at line 1862 of file color-conversions.c. References FMIN, lut_t::image_width, short_copy(), short_eq(), stp_get_component_data(), and stp_vars_t.

double hsl_value | ( | double | n1,
|  | double | n2,
|  | double | hue
| ) | `[inline, static]`

| Definition at line 137 of file color-conversions.c. Referenced by calc_hsl_to_rgb().

double interpolate_value | ( | const double * | vec,
|  | double | val
| ) | `[inline, static]`

| Definition at line 201 of file color-conversions.c. Referenced by adjust_hsl(), adjust_hsl_bright(), and adjust_hue().

void lookup_rgb | ( | lut_t * | lut,
|  | unsigned short * | rgbout,
|  | const unsigned short * | red,
|  | const unsigned short * | green,
|  | const unsigned short * | blue,
|  | unsigned | steps
| ) | `[inline, static]`

| Definition at line 351 of file color-conversions.c.

unsigned raw_cmy_to_kcmy | ( | const stp_vars_t * | vars,
|  | const unsigned short * | in,
|  | unsigned short * | out
| ) | `[static]`

| Definition at line 497 of file color-conversions.c. References FMIN, lut_t::image_width, short_copy(), short_eq(), stp_get_component_data(), and stp_vars_t.

unsigned raw_kcmy_to_cmykrb | ( | const stp_vars_t * | vars,
|  | const unsigned short * | in,
|  | unsigned short * | out
| ) | `[static]`

| Definition at line 1924 of file color-conversions.c. References FMIN, lut_t::image_width, short_copy(), short_eq(), stp_get_component_data(), and stp_vars_t.

void short_copy | ( | unsigned short * | out,
|  | const unsigned short * | in,
|  | size_t | count
| ) | `[inline, static]`

| Definition at line 384 of file color-conversions.c. Referenced by generic_kcmy_to_cmykrb(), raw_cmy_to_kcmy(), and raw_kcmy_to_cmykrb().

int short_eq | ( | const unsigned short * | i1,
|  | const unsigned short * | i2,
|  | size_t | count
| ) | `[inline, static]`

| Definition at line 370 of file color-conversions.c. Referenced by generic_kcmy_to_cmykrb(), raw_cmy_to_kcmy(), and raw_kcmy_to_cmykrb().

unsigned stpi_color_convert_raw | ( | const stp_vars_t * | v,
|  | const unsigned char * | in,
|  | unsigned short * | out
| ) |

| Definition at line 2436 of file color-conversions.c. References lut_t::color_correction, COLOR_CORRECTION_ACCURATE, COLOR_CORRECTION_BRIGHT, COLOR_CORRECTION_DEFAULT, COLOR_CORRECTION_DENSITY, COLOR_CORRECTION_DESATURATED, COLOR_CORRECTION_PREDITHERED, COLOR_CORRECTION_RAW, COLOR_CORRECTION_THRESHOLD, COLOR_CORRECTION_UNCORRECTED, color_correction_t::correction, stp_get_component_data(), and stp_vars_t.

unsigned stpi_color_convert_to_cmykrb | ( | const stp_vars_t * | v,
|  | const unsigned char * | in,
|  | unsigned short * | out
| ) |

| Definition at line 2414 of file color-conversions.c. References color_description_t::color_id, COLOR_ID_CMY, COLOR_ID_CMYK, COLOR_ID_GRAY, COLOR_ID_KCMY, COLOR_ID_RGB, COLOR_ID_WHITE, lut_t::input_color_description, stp_get_component_data(), and stp_vars_t.

unsigned stpi_color_convert_to_color | ( | const stp_vars_t * | v,
|  | const unsigned char * | in,
|  | unsigned short * | out
| ) |

| Definition at line 2370 of file color-conversions.c. References color_description_t::color_id, COLOR_ID_CMY, COLOR_ID_CMYK, COLOR_ID_GRAY, COLOR_ID_KCMY, COLOR_ID_RGB, COLOR_ID_WHITE, lut_t::input_color_description, stp_get_component_data(), and stp_vars_t.

unsigned stpi_color_convert_to_gray | ( | const stp_vars_t * | v,
|  | const unsigned char * | in,
|  | unsigned short * | out
| ) |

| Definition at line 2348 of file color-conversions.c. References color_description_t::color_id, COLOR_ID_CMY, COLOR_ID_CMYK, COLOR_ID_GRAY, COLOR_ID_KCMY, COLOR_ID_RGB, COLOR_ID_WHITE, lut_t::input_color_description, stp_get_component_data(), and stp_vars_t.

unsigned stpi_color_convert_to_kcmy | ( | const stp_vars_t * | v,
|  | const unsigned char * | in,
|  | unsigned short * | out
| ) |

| Definition at line 2392 of file color-conversions.c. References color_description_t::color_id, COLOR_ID_CMY, COLOR_ID_CMYK, COLOR_ID_GRAY, COLOR_ID_KCMY, COLOR_ID_RGB, COLOR_ID_WHITE, lut_t::input_color_description, stp_get_component_data(), and stp_vars_t.

double update_saturation | ( | double | sat,
|  | double | adjust,
|  | double | isat
| ) | `[inline, static]`

| Definition at line 185 of file color-conversions.c. References FMIN. Referenced by adjust_hsl(), adjust_hsl_bright(), and update_saturation_from_rgb().

void update_saturation_from_rgb | ( | unsigned short * | rgb,
|  | const unsigned short * | brightness_lookup,
|  | double | adjust,
|  | double | isat,
|  | int | do_usermap
| ) | `[inline, static]`

| Definition at line 213 of file color-conversions.c. References calc_hsl_to_rgb(), calc_rgb_to_hsl(), and update_saturation().