made pullout a percentage instead of a maximal value. (gimp_rgb_to_cmyk):

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

	* libgimpcolor/gimpcolorspace.[ch] (gimp_rgb_to_cmyk_int): made
	pullout a percentage instead of a maximal value.
	(gimp_rgb_to_cmyk): added a pullout parameter here as well.

	* app/gui/info-window.c
	* plug-ins/common/newsprint.c: changed accordingly.

	* modules/colorsel_cmyk.c: allow to specify the amount of black
	pulled out when converting to CMYK.
This commit is contained in:
Sven Neumann 2003-09-02 22:52:25 +00:00 committed by Sven Neumann
parent b9713670d8
commit 443a5f3fd2
9 changed files with 84 additions and 20 deletions

View File

@ -1,3 +1,15 @@
2003-09-03 Sven Neumann <sven@gimp.org>
* libgimpcolor/gimpcolorspace.[ch] (gimp_rgb_to_cmyk_int): made
pullout a percentage instead of a maximal value.
(gimp_rgb_to_cmyk): added a pullout parameter here as well.
* app/gui/info-window.c
* plug-ins/common/newsprint.c: changed accordingly.
* modules/colorsel_cmyk.c: allow to specify the amount of black
pulled out when converting to CMYK.
2003-09-03 Dave Neary <bolsh@gimp.org>
* NEWS: Changed slightly - I overestimated/overanticipated

View File

@ -625,7 +625,7 @@ info_window_update_extended (GimpDisplay *gdisp,
g_snprintf (buf, sizeof (buf), "%d", ROUND (hsv.v * 100.0));
gtk_label_set_text (GTK_LABEL (iwd->hsv_labels[2]), buf);
gimp_rgb_to_cmyk (&rgb, &cmyk);
gimp_rgb_to_cmyk (&rgb, 1.0, &cmyk);
g_snprintf (buf, sizeof (buf), "%d", ROUND (cmyk.c * 100.0));
gtk_label_set_text (GTK_LABEL (iwd->cmyk_labels[0]), buf);

View File

@ -625,7 +625,7 @@ info_window_update_extended (GimpDisplay *gdisp,
g_snprintf (buf, sizeof (buf), "%d", ROUND (hsv.v * 100.0));
gtk_label_set_text (GTK_LABEL (iwd->hsv_labels[2]), buf);
gimp_rgb_to_cmyk (&rgb, &cmyk);
gimp_rgb_to_cmyk (&rgb, 1.0, &cmyk);
g_snprintf (buf, sizeof (buf), "%d", ROUND (cmyk.c * 100.0));
gtk_label_set_text (GTK_LABEL (iwd->cmyk_labels[0]), buf);

View File

@ -1,3 +1,7 @@
2003-09-03 Sven Neumann <sven@gimp.org>
* libgimpcolor/tmpl/gimpcolorspace.sgml: updated.
2003-08-31 Sven Neumann <sven@gimp.org>
* libgimp/libgimp-sections.txt

View File

@ -51,6 +51,7 @@ different color spaces.
</para>
@rgb:
@pullout:
@cmyk:
@ -141,7 +142,7 @@ different color spaces.
@red:
@green:
@blue:
@black:
@pullout:
<!-- ##### FUNCTION gimp_cmyk_to_rgb_int ##### -->

View File

@ -274,6 +274,7 @@ gimp_hsl_to_rgb (const GimpHSL *hsl,
void
gimp_rgb_to_cmyk (const GimpRGB *rgb,
gdouble pullout,
GimpCMYK *cmyk)
{
gdouble c, m, y, k;
@ -290,6 +291,8 @@ gimp_rgb_to_cmyk (const GimpRGB *rgb,
if (m < k) k = m;
if (y < k) k = y;
k *= pullout;
if (k < 1.0)
{
cmyk->c = (c - k) / (1.0 - k);
@ -711,14 +714,14 @@ gimp_hls_to_rgb_int (gint *hue,
* @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
* @pullout: the percentage of black to pull out (0-100); 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.
* A value of 100 causes the maximum amount of black to be pulled out.
**/
void
gimp_rgb_to_cmyk_int (gint *red,
@ -740,12 +743,14 @@ gimp_rgb_to_cmyk_int (gint *red,
}
else
{
gint k = CLAMP (*pullout, 0, 255);
gint k = 255;
if (c < k) k = c;
if (m < k) k = m;
if (y < k) k = y;
k = (k * CLAMP (*pullout, 0, 100)) / 100;
*red = ((c - k) << 8) / (256 - k);
*green = ((m - k) << 8) / (256 - k);
*blue = ((y - k) << 8) / (256 - k);

View File

@ -35,6 +35,7 @@ void gimp_rgb_to_hsv (const GimpRGB *rgb,
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,
@ -66,7 +67,7 @@ void gimp_hsv_to_rgb_int (gint *hue /* returns red */,
void gimp_rgb_to_cmyk_int (gint *red /* returns cyan */,
gint *green /* returns magenta */,
gint *blue /* returns yellow */,
gint *black /* ignored as input */);
gint *pullout /* returns black */);
void gimp_cmyk_to_rgb_int (gint *cyan /* returns red */,
gint *magenta /* returns green */,
gint *yellow /* returns blue */,

View File

@ -44,7 +44,8 @@ struct _ColorselCmyk
GimpColorSelector parent_instance;
GimpCMYK cmyk;
GtkAdjustment *adj[4];
gdouble pullout;
GtkAdjustment *adj[5];
};
struct _ColorselCmykClass
@ -57,11 +58,13 @@ static GType colorsel_cmyk_get_type (GTypeModule *module);
static void colorsel_cmyk_class_init (ColorselCmykClass *klass);
static void colorsel_cmyk_init (ColorselCmyk *cmyk);
static void colorsel_cmyk_set_color (GimpColorSelector *selector,
const GimpRGB *rgb,
const GimpHSV *hsv);
static void colorsel_cmyk_adj_update (GtkAdjustment *adj,
ColorselCmyk *module);
static void colorsel_cmyk_set_color (GimpColorSelector *selector,
const GimpRGB *rgb,
const GimpHSV *hsv);
static void colorsel_cmyk_adj_update (GtkAdjustment *adj,
ColorselCmyk *module);
static void colorsel_cmyk_pullout_update (GtkAdjustment *adj,
ColorselCmyk *module);
static const GimpModuleInfo colorsel_cmyk_info =
@ -136,6 +139,9 @@ static void
colorsel_cmyk_init (ColorselCmyk *module)
{
GtkWidget *table;
GtkWidget *label;
GtkWidget *spinbutton;
GtkObject *adj;
gint i;
static const gchar *cmyk_labels[] =
@ -153,17 +159,19 @@ colorsel_cmyk_init (ColorselCmyk *module)
N_("Black")
};
table = gtk_table_new (4, 4, FALSE);
module->pullout = 1.0;
table = gtk_table_new (5, 4, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 1);
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 0);
gtk_table_set_row_spacing (GTK_TABLE (table), 3, 4);
gtk_box_pack_start (GTK_BOX (module), table, TRUE, FALSE, 0);
for (i = 0; i < 4; i++)
{
GtkObject *adj;
adj = gimp_scale_entry_new (GTK_TABLE (table), 1, i,
gettext (cmyk_labels[i]),
80, -1,
@ -182,6 +190,30 @@ colorsel_cmyk_init (ColorselCmyk *module)
module->adj[i] = GTK_ADJUSTMENT (adj);
}
label = gtk_label_new_with_mnemonic (_("Black Pullout (%):"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label,
2, 3, i, i + 1,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
spinbutton = gimp_spin_button_new (&adj, module->pullout * 100.0,
0.0, 100.0, 1.0, 10.0, 0.0,
1.0, 0);
gtk_table_attach (GTK_TABLE (table), spinbutton,
3, 4, i, i + 1,
GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show (spinbutton);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinbutton);
g_signal_connect (adj, "value_changed",
G_CALLBACK (colorsel_cmyk_pullout_update),
module);
module->adj[i] = GTK_ADJUSTMENT (adj);
gtk_widget_show (table);
}
@ -194,7 +226,7 @@ colorsel_cmyk_set_color (GimpColorSelector *selector,
module = COLORSEL_CMYK (selector);
gimp_rgb_to_cmyk (rgb, &module->cmyk);
gimp_rgb_to_cmyk (rgb, module->pullout, &module->cmyk);
gtk_adjustment_set_value (module->adj[0], module->cmyk.c * 100.0);
gtk_adjustment_set_value (module->adj[1], module->cmyk.m * 100.0);
@ -238,3 +270,14 @@ colorsel_cmyk_adj_update (GtkAdjustment *adj,
gimp_color_selector_color_changed (selector);
}
static void
colorsel_cmyk_pullout_update (GtkAdjustment *adj,
ColorselCmyk *module)
{
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (module);
module->pullout = adj->value / 100.0;
gimp_color_selector_set_color (selector, &selector->rgb, &selector->hsv);
}

View File

@ -1759,7 +1759,6 @@ newsprint (GimpDrawable *drawable)
gdouble r;
gdouble theta;
gdouble rot[4];
gint k_pullout;
gint bpp, colour_bpp;
gint has_alpha;
gint b;
@ -1787,7 +1786,6 @@ newsprint (GimpDrawable *drawable)
width = 1;
oversample = pvals.oversample;
k_pullout = (255 * pvals.k_pullout) / 100;
width *= oversample;
@ -1931,7 +1929,7 @@ do { \
r = data[0];
g = data[1];
b = data[2];
k = k_pullout;
k = pvals.k_pullout;
gimp_rgb_to_cmyk_int (&r, &g, &b, &k);