From patchwork Thu Jun 2 13:31:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mandeep Kumar X-Patchwork-Id: 1724 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:54:57 -0000 Delivered-To: patches@linaro.org Received: by 10.52.181.10 with SMTP id ds10cs369917vdc; Thu, 2 Jun 2011 06:31:34 -0700 (PDT) Received: by 10.42.140.8 with SMTP id i8mr1434736icu.446.1307021494529; Thu, 02 Jun 2011 06:31:34 -0700 (PDT) Received: from mail-pw0-f50.google.com (mail-pw0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id el7si3305857icb.45.2011.06.02.06.31.31 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 02 Jun 2011 06:31:33 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of mandeep.kumar@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of mandeep.kumar@linaro.org) smtp.mail=mandeep.kumar@linaro.org Received: by pwi3 with SMTP id 3so584598pwi.37 for ; Thu, 02 Jun 2011 06:31:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.61.18 with SMTP id j18mr111825wfa.75.1307021491366; Thu, 02 Jun 2011 06:31:31 -0700 (PDT) Received: by 10.142.143.8 with HTTP; Thu, 2 Jun 2011 06:31:31 -0700 (PDT) Date: Thu, 2 Jun 2011 08:31:31 -0500 Message-ID: Subject: [PATCH] Added CMYK to RGB color conversion. From: Mandeep Kumar To: Kurt Taylor , Rob Clark , Rony Nandy , Kan Hu , Feng Wei , Vishal Raj , Benjamin Gaignard , Sudip Jain Cc: Patch Tracking >From e821a725e69102ec42bb56ad9b783b415141fda3 Mon Sep 17 00:00:00 2001 From: Mandeep Kumar Date: Tue, 3 May 2011 17:33:49 -0500 Subject: [PATCH] Added CMYK to RGB color conversion. --- djpeg.c | 4 ++++ jdcolor.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 0 deletions(-) mode change 100644 => 100755 djpeg.c mode change 100644 => 100755 jdcolor.c diff --git a/djpeg.c b/djpeg.c old mode 100644 new mode 100755 index 466973f..4c8545e --- a/djpeg.c +++ b/djpeg.c @@ -539,6 +539,10 @@ main (int argc, char **argv) /* Adjust default decompression parameters by re-parsing the options */ file_index = parse_switches(&cinfo, argc, argv, 0, TRUE); + if (cinfo.jpeg_color_space == JCS_CMYK) { + cinfo.out_color_space = JCS_RGB; + } + /* Initialize the output module now to let it override any crucial * option settings (for instance, GIF wants to force color quantization). */ diff --git a/jdcolor.c b/jdcolor.c old mode 100644 new mode 100755 index bc73b3f..4678467 --- a/jdcolor.c +++ b/jdcolor.c @@ -159,6 +159,42 @@ ycc_rgb_convert (j_decompress_ptr cinfo, } } +/* + * Convert cmyk to rgb + */ +METHODDEF(void) +cmyk_rgb_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + double c, m, y, k; + register JSAMPROW outptr; + register JSAMPROW inptr0, inptr1, inptr2, inptr3; + register JDIMENSION col; + + JDIMENSION num_cols = cinfo->output_width; + + while (--num_rows >= 0) { + inptr0 = input_buf[0][input_row]; + inptr1 = input_buf[1][input_row]; + inptr2 = input_buf[2][input_row]; + inptr3 = input_buf[3][input_row]; + input_row++; + outptr = *output_buf++; + for (col = 0; col < num_cols; col++) { + c = (double) GETJSAMPLE(inptr0[col]); + m = (double) GETJSAMPLE(inptr1[col]); + y = (double) GETJSAMPLE(inptr2[col]); + k = (double) GETJSAMPLE(inptr3[col]); + + outptr[RGB_RED] = (JSAMPLE)(c*k/255); + outptr[RGB_GREEN] = (JSAMPLE)(m*k/255); + outptr[RGB_BLUE] = (JSAMPLE)(y*k/255); + outptr += RGB_PIXELSIZE; + } + } +} + /**************** Cases other than YCbCr -> RGB **************/ @@ -377,6 +413,8 @@ jinit_color_deconverter (j_decompress_ptr cinfo) cconvert->pub.color_convert = ycc_rgb_convert; build_ycc_rgb_table(cinfo); } + } else if (cinfo->jpeg_color_space == JCS_CMYK) { + cconvert->pub.color_convert = cmyk_rgb_convert; } else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) { cconvert->pub.color_convert = gray_rgb_convert; } else if (cinfo->jpeg_color_space == cinfo->out_color_space &&