[Mono-bugs] [Bug 50081][Nor] Changed - JPEGCodec output only supports RGB buffers.

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 20 Sep 2004 13:24:27 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by miguel@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=50081

--- shadow/50081	2004-05-15 00:16:56.000000000 -0400
+++ shadow/50081.tmp.14431	2004-09-20 13:24:27.000000000 -0400
@@ -1,17 +1,17 @@
 Bug#: 50081
 Product: Mono: Class Libraries
 Version: unspecified
 OS: unknown
 OS Details: 
-Status: REOPENED   
+Status: NEW   
 Resolution: 
 Severity: Unknown
 Priority: Normal
 Component: Sys.Drawing.
-AssignedTo: mono-bugs@ximian.com                            
+AssignedTo: rkumar@novell.com                            
 ReportedBy: miguel@ximian.com               
 QAContact: mono-bugs@ximian.com
 TargetMilestone: ---
 URL: 
 Cc: 
 Summary: JPEGCodec output only supports RGB buffers.
@@ -22,6 +22,59 @@
 ------- Additional Comments From peter@novonyx.com  2004-05-14 23:02 -------
 Could you explain exactly what you mean by 'only supports RGB
 buffers'? Is this still the case with the the rewrite/fixes that vlad did?
 
 ------- Additional Comments From miguel@ximian.com  2004-05-15 00:16 -------
 I honestly forget what this bug was all about.  Am closing.
+
+------- Additional Comments From miguel@ximian.com  2004-09-20 13:24 -------
+Ok, reopening:
+
+The current jpegcodec.c only supports the following formats on 
+input:
+
+    if (cinfo.jpeg_color_space != JCS_GRAYSCALE &&
+        cinfo.jpeg_color_space != JCS_RGB &&
+        cinfo.jpeg_color_space != JCS_YCbCr)
+
+It is at least missing:
+
+        JCS_CMYK
+
+Which requires a little work, just a cmyk to rgb conversion, you can
+see some code here:
+
+convert_cmyk_to_rgb (struct jpeg_decompress_struct *cinfo,
+                     guchar **lines)
+{
+        gint i, j;
+
+        g_return_if_fail (cinfo != NULL);
+        g_return_if_fail (cinfo->output_components == 4);
+        g_return_if_fail (cinfo->out_color_space == JCS_CMYK);
+
+        for (i = cinfo->rec_outbuf_height - 1; i >= 0; i--) {
+                guchar *p;
+
+                p = lines[i];
+                for (j = 0; j < cinfo->output_width; j++) {
+                        int c, m, y, k;
+                        c = p[0];
+                        m = p[1];
+                        y = p[2];
+                        k = p[3];
+                        if (cinfo->saw_Adobe_marker) {
+                                p[0] = k*c / 255;
+                                p[1] = k*m / 255;
+                                p[2] = k*y / 255;
+                        }
+                        else {
+                                p[0] = (255 - k)*(255 - c) / 255;
+                                p[1] = (255 - k)*(255 - m) / 255;
+                                p[2] = (255 - k)*(255 - y) / 255;
+                        }
+                        p[3] = 255;
+                        p += 4;
+                }
+        }
+}
+