[gimp/gimp-2-6] Bug 621363 - CMYK decompose broken
- From: Sven Neumann <neo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-6] Bug 621363 - CMYK decompose broken
- Date: Wed, 7 Jul 2010 18:23:22 +0000 (UTC)
commit 3133d68d5d8502453169899bfbc8960c745c5d70
Author: Rupert Weber <rpwh gmx de>
Date: Sat Jul 3 12:57:41 2010 +0200
Bug 621363 - CMYK decompose broken
The CMYK Decompose/Recompose plugin used its own (faulty) algorithm
for RGB<->CMYK conversions. This fix changes the plugin to use the
conversion routines provided by libgimpcolorspace.
plug-ins/common/compose.c | 47 ++++++++-----------
plug-ins/common/decompose.c | 101 +++++++++++++++++++++++--------------------
2 files changed, 74 insertions(+), 74 deletions(-)
---
diff --git a/plug-ins/common/compose.c b/plug-ins/common/compose.c
index bc711bf..2b0a2d5 100644
--- a/plug-ins/common/compose.c
+++ b/plug-ins/common/compose.c
@@ -1153,39 +1153,32 @@ compose_cmyk (guchar **src,
register const guchar *black_src = src[3];
register guchar *rgb_dst = dst;
register gint count = numpix;
- gint cyan, magenta, yellow, black;
- gint cyan_incr = incr_src[0];
- gint magenta_incr = incr_src[1];
- gint yellow_incr = incr_src[2];
- gint black_incr = incr_src[3];
+ gint cyan_incr = incr_src[0];
+ gint magenta_incr = incr_src[1];
+ gint yellow_incr = incr_src[2];
+ gint black_incr = incr_src[3];
+ GimpRGB grgb;
+
+ gimp_rgb_set (&grgb, 0, 0, 0);
while (count-- > 0)
{
- black = (gint)*black_src;
- if (black)
- {
- cyan = (gint) *cyan_src;
- magenta = (gint) *magenta_src;
- yellow = (gint) *yellow_src;
+ GimpCMYK gcmyk;
+ guchar r, g, b;
- cyan += black; if (cyan > 255) cyan = 255;
- magenta += black; if (magenta > 255) magenta = 255;
- yellow += black; if (yellow > 255) yellow = 255;
+ gimp_cmyk_set_uchar (&gcmyk,
+ *cyan_src, *magenta_src, *yellow_src, *black_src);
+ gimp_cmyk_to_rgb (&gcmyk, &grgb);
+ gimp_rgb_get_uchar (&grgb, &r, &g, &b);
- *(rgb_dst++) = 255 - cyan;
- *(rgb_dst++) = 255 - magenta;
- *(rgb_dst++) = 255 - yellow;
- }
- else
- {
- *(rgb_dst++) = 255 - *cyan_src;
- *(rgb_dst++) = 255 - *magenta_src;
- *(rgb_dst++) = 255 - *yellow_src;
- }
- cyan_src += cyan_incr;
+ *rgb_dst++ = r;
+ *rgb_dst++ = g;
+ *rgb_dst++ = b;
+
+ cyan_src += cyan_incr;
magenta_src += magenta_incr;
- yellow_src += yellow_incr;
- black_src += black_incr;
+ yellow_src += yellow_incr;
+ black_src += black_incr;
if (dst_has_alpha)
rgb_dst++;
diff --git a/plug-ins/common/decompose.c b/plug-ins/common/decompose.c
index 940d422..3783ffa 100644
--- a/plug-ins/common/decompose.c
+++ b/plug-ins/common/decompose.c
@@ -1159,28 +1159,25 @@ extract_cmyk (const guchar *src,
register guchar *magenta_dst = dst[1];
register guchar *yellow_dst = dst[2];
register guchar *black_dst = dst[3];
- register guchar k, s;
register gint count = numpix, offset = bpp-3;
+ GimpCMYK gcmyk;
+
+ gimp_cmyk_set (&gcmyk, 0,0,0,0);
while (count-- > 0)
{
- *cyan_dst = k = 255 - *(rgb_src++);
- *magenta_dst = s = 255 - *(rgb_src++);
- if (s < k)
- k = s;
- *yellow_dst = s = 255 - *(rgb_src++);
- if (s < k)
- k = s; /* Black intensity is minimum of c, m, y */
- if (k)
- {
- *cyan_dst -= k; /* Remove common part of c, m, y */
- *magenta_dst -= k;
- *yellow_dst -= k;
- }
- cyan_dst++;
- magenta_dst++;
- yellow_dst++;
- *(black_dst++) = k;
+ GimpRGB grgb;
+ guchar r, g, b;
+
+ r = *rgb_src++;
+ g = *rgb_src++;
+ b = *rgb_src++;
+
+ gimp_rgb_set_uchar (&grgb, r, g, b);
+ gimp_rgb_to_cmyk (&grgb, 1.0, &gcmyk);
+ gimp_cmyk_get_uchar (&gcmyk,
+ cyan_dst++, magenta_dst++, yellow_dst++,
+ black_dst++);
rgb_src += offset;
}
@@ -1195,18 +1192,23 @@ extract_cyank (const guchar *src,
{
register const guchar *rgb_src = src;
register guchar *cyan_dst = dst[0];
- register guchar s, k;
register gint count = numpix, offset = bpp-3;
+ GimpCMYK gcmyk;
+
+ gimp_cmyk_set (&gcmyk, 0,0,0,0);
while (count-- > 0)
{
- *cyan_dst = k = 255 - *(rgb_src++);
- s = 255 - *(rgb_src++); /* magenta */
- if (s < k) k = s;
- s = 255 - *(rgb_src++); /* yellow */
- if (s < k) k = s;
- if (k) *cyan_dst -= k;
- cyan_dst++;
+ GimpRGB grgb;
+ guchar r, g, b;
+
+ r = *rgb_src++;
+ g = *rgb_src++;
+ b = *rgb_src++;
+
+ gimp_rgb_set_uchar (&grgb, r,g,b);
+ gimp_rgb_to_cmyk (&grgb, 1.0, &gcmyk);
+ gimp_cmyk_get_uchar (&gcmyk, cyan_dst++, NULL, NULL, NULL);
rgb_src += offset;
}
@@ -1221,21 +1223,23 @@ extract_magentak (const guchar *src,
{
register const guchar *rgb_src = src;
register guchar *magenta_dst = dst[0];
- register guchar s, k;
register gint count = numpix, offset = bpp-3;
+ GimpCMYK gcmyk;
+
+ gimp_cmyk_set (&gcmyk, 0,0,0,0);
while (count-- > 0)
{
- k = 255 - *(rgb_src++); /* cyan */
- *magenta_dst = s = 255 - *(rgb_src++); /* magenta */
- if (s < k)
- k = s;
- s = 255 - *(rgb_src++); /* yellow */
- if (s < k)
- k = s;
- if (k)
- *magenta_dst -= k;
- magenta_dst++;
+ GimpRGB grgb;
+ guchar r, g, b;
+
+ r = *rgb_src++;
+ g = *rgb_src++;
+ b = *rgb_src++;
+
+ gimp_rgb_set_uchar (&grgb, r,g,b);
+ gimp_rgb_to_cmyk (&grgb, 1.0, &gcmyk);
+ gimp_cmyk_get_uchar (&gcmyk, NULL, magenta_dst++, NULL, NULL);
rgb_src += offset;
}
@@ -1251,20 +1255,23 @@ extract_yellowk (const guchar *src,
{
register const guchar *rgb_src = src;
register guchar *yellow_dst = dst[0];
- register guchar s, k;
register gint count = numpix, offset = bpp-3;
+ GimpCMYK gcmyk;
+
+ gimp_cmyk_set (&gcmyk, 0,0,0,0);
while (count-- > 0)
{
- k = 255 - *(rgb_src++); /* cyan */
- s = 255 - *(rgb_src++); /* magenta */
- if (s < k) k = s;
- *yellow_dst = s = 255 - *(rgb_src++);
- if (s < k)
- k = s;
- if (k)
- *yellow_dst -= k;
- yellow_dst++;
+ GimpRGB grgb;
+ guchar r, g, b;
+
+ r = *rgb_src++;
+ g = *rgb_src++;
+ b = *rgb_src++;
+
+ gimp_rgb_set_uchar (&grgb, r,g,b);
+ gimp_rgb_to_cmyk (&grgb, 1.0, &gcmyk);
+ gimp_cmyk_get_uchar (&gcmyk, NULL, NULL, yellow_dst++, NULL);
rgb_src += offset;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]