Commit 84fd11ad authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

allow to specify the amount of black pullout. Documented the function.

2003-09-02  Sven Neumann  <sven@gimp.org>

	* libgimpcolor/gimpcolorspace.c (gimp_rgb_to_cmyk_int): allow to
	specify the amount of black pullout. Documented the function.

	* plug-ins/common/newsprint.c: use the RGB to CMYK routine from
	libgimpcolor.
parent 138bab29
2003-09-02 Sven Neumann <sven@gimp.org>
* libgimpcolor/gimpcolorspace.c (gimp_rgb_to_cmyk_int): allow to
specify the amount of black pullout. Documented the function.
* plug-ins/common/newsprint.c: use the RGB to CMYK routine from
libgimpcolor.
2003-09-02 Sven Neumann <sven@gimp.org>
* app/tools/gimpdrawtool.[ch]: added new function
......@@ -706,19 +706,42 @@ gimp_hls_to_rgb_int (gint *hue,
}
}
/**
* gimp_rgb_to_cmyk_int:
* @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 maximum amount of black to pull out; returns
* the black value (0-255)
*
* 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.
* For most cases, @pullout should be choosen as 255.
**/
void
gimp_rgb_to_cmyk_int (gint *red,
gint *green,
gint *blue,
gint *black)
gint *pullout)
{
gint c, m, y, k;
gint c, m, y;
c = 255 - *red;
m = 255 - *green;
y = 255 - *blue;
k = 255;
if (*pullout == 0)
{
*red = c;
*green = m;
*blue = y;
}
else
{
gint k = CLAMP (*pullout, 0, 255);
if (c < k) k = c;
if (m < k) k = m;
if (y < k) k = y;
......@@ -726,7 +749,8 @@ gimp_rgb_to_cmyk_int (gint *red,
*red = ((c - k) << 8) / (256 - k);
*green = ((m - k) << 8) / (256 - k);
*blue = ((y - k) << 8) / (256 - k);
*black = k;
*pullout = k;
}
}
void
......
......@@ -1759,7 +1759,7 @@ newsprint (GimpDrawable *drawable)
gdouble r;
gdouble theta;
gdouble rot[4];
gdouble k_pullout;
gint k_pullout;
gint bpp, colour_bpp;
gint has_alpha;
gint b;
......@@ -1787,7 +1787,7 @@ newsprint (GimpDrawable *drawable)
width = 1;
oversample = pvals.oversample;
k_pullout = ((gdouble) pvals.k_pullout) / 100.0;
k_pullout = (255 * pvals.k_pullout) / 100;
width *= oversample;
......@@ -1925,20 +1925,21 @@ do { \
switch (colourspace)
{
case CS_CMYK:
data[3] = 0xff;
{
gint r,g,b,k;
data[0] = 0xff - data[0];
data[3] = MIN (data[3], data[0]);
data[1] = 0xff - data[1];
data[3] = MIN (data[3], data[1]);
data[2] = 0xff - data[2];
data[3] = MIN (data[3], data[2]);
r = data[0];
g = data[1];
b = data[2];
k = k_pullout;
data[3] = ((gdouble)data[3]) * k_pullout;
gimp_rgb_to_cmyk_int (&r, &g, &b, &k);
data[0] -= data[3];
data[1] -= data[3];
data[2] -= data[3];
data[0] = r;
data[1] = g;
data[2] = b;
data[3] = k;
}
break;
case CS_INTENSITY:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment