#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, double adjust, double isat) |
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) |
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) |
|
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 2007 of file color-conversions.c. |
|
Definition at line 1146 of file color-conversions.c. |
|
Definition at line 1392 of file color-conversions.c. |
|
Definition at line 1592 of file color-conversions.c. |
|
Definition at line 1211 of file color-conversions.c. |
|
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 1710 of file color-conversions.c. |
|
Definition at line 929 of file color-conversions.c. |
|
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")); \ if (!lut->cmyk_tmp) \ lut->cmyk_tmp = stp_malloc(4 * 2 * lut->image_width); \ name##_##bits##_to_##name3(vars, in, lut->cmyk_tmp); \ return name4##_kcmy_to_cmykrb(vars, lut->cmyk_tmp, out); \ } Definition at line 1903 of file color-conversions.c. |
|
Definition at line 556 of file color-conversions.c. |
|
Definition at line 1055 of file color-conversions.c. |
|
Definition at line 1338 of file color-conversions.c. |
|
Definition at line 1537 of file color-conversions.c. |
|
Definition at line 1097 of file color-conversions.c. |
|
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")); \ if (!lut->cmy_tmp) \ lut->cmy_tmp = stp_malloc(4 * 2 * lut->image_width); \ name##_##bits##_to_##name3(vars, in, lut->cmy_tmp); \ return name4##_cmy_to_kcmy(vars, lut->cmy_tmp, out); \ } Definition at line 839 of file color-conversions.c. |
|
Definition at line 872 of file color-conversions.c. |
|
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: \ 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 2161 of file color-conversions.c. |
|
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: \ 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 2212 of file color-conversions.c. |
|
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: \ 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 2187 of file color-conversions.c. |
|
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")); \ if (!lut->gray_tmp) \ lut->gray_tmp = stp_malloc(2 * lut->image_width); \ name##_##bits##_to_gray_noninvert(vars, in, lut->gray_tmp); \ return gray_16_to_##name2(vars, (unsigned char *) lut->gray_tmp, out); \ } Definition at line 1964 of file color-conversions.c. |
|
Definition at line 643 of file color-conversions.c. |
|
Definition at line 57 of file color-conversions.c. |
|
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(). |
|
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\n", \ #fromname, lut->channel_depth, #toname, \ lut->input_color_description->name, \ lut->output_color_description->name, \ 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 534 of file color-conversions.c. |
|
Definition at line 749 of file color-conversions.c. |
|
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 808 of file color-conversions.c. |
|
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 1016 of file color-conversions.c. |
|
Definition at line 1296 of file color-conversions.c. |
|
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 1506 of file color-conversions.c. |
|
Definition at line 1449 of file color-conversions.c. |
|
Definition at line 1651 of file color-conversions.c. |
|
Definition at line 1254 of file color-conversions.c. |
|
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[i] = s_in[i] * (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 1745 of file color-conversions.c. |
|
Definition at line 976 of file color-conversions.c. |
|
Definition at line 53 of file color-conversions.c. |
|
Definition at line 52 of file color-conversions.c. |
|
Definition at line 51 of file color-conversions.c. |
|
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 712 of file color-conversions.c. |
|
Definition at line 2083 of file color-conversions.c. |
|
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 2125 of file color-conversions.c. |
|
Definition at line 2043 of file color-conversions.c. |
|
Definition at line 236 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(). |
|
Definition at line 309 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(). |
|
Definition at line 222 of file color-conversions.c. References interpolate_value(). |
|
Definition at line 154 of file color-conversions.c. References hsl_value(). |
|
Definition at line 61 of file color-conversions.c. |
|
Definition at line 386 of file color-conversions.c. References lut_t::channel_curves, FMIN, lut_t::gcr_curve, lut_t::image_width, lut_t::steps, stp_curve_cache_get_ushort_data(), stp_curve_resample(), and stp_get_component_data(). |
|
Definition at line 1780 of file color-conversions.c. References FMIN, lut_t::image_width, short_copy(), short_eq(), and stp_get_component_data(). |
|
Definition at line 137 of file color-conversions.c. |
|
Definition at line 201 of file color-conversions.c. |
|
Definition at line 341 of file color-conversions.c. References lut_t::steps. |
|
Definition at line 486 of file color-conversions.c. References FMIN, lut_t::image_width, short_copy(), short_eq(), and stp_get_component_data(). |
|
Definition at line 1842 of file color-conversions.c. References FMIN, lut_t::image_width, short_copy(), short_eq(), and stp_get_component_data(). |
|
Definition at line 374 of file color-conversions.c. Referenced by generic_kcmy_to_cmykrb(), raw_cmy_to_kcmy(), and raw_kcmy_to_cmykrb(). |
|
Definition at line 360 of file color-conversions.c. Referenced by generic_kcmy_to_cmykrb(), raw_cmy_to_kcmy(), and raw_kcmy_to_cmykrb(). |
|
Definition at line 2338 of file color-conversions.c. References lut_t::color_correction, COLOR_CORRECTION_DESATURATED, color_correction_t::correction, raw_to_raw(), and stp_get_component_data(). |
|
Definition at line 2316 of file color-conversions.c. References color_description_t::color_id, lut_t::input_color_description, and stp_get_component_data(). |
|
Definition at line 2272 of file color-conversions.c. References color_description_t::color_id, lut_t::input_color_description, and stp_get_component_data(). |
|
Definition at line 2250 of file color-conversions.c. References color_description_t::color_id, lut_t::input_color_description, and stp_get_component_data(). |
|
Definition at line 2294 of file color-conversions.c. References color_description_t::color_id, lut_t::input_color_description, and stp_get_component_data(). |
|
Definition at line 185 of file color-conversions.c. References FMIN. |
|
Definition at line 213 of file color-conversions.c. References calc_hsl_to_rgb(), calc_rgb_to_hsl(), and update_saturation(). |