[gs-commits] rev 11752 - in branches/jpx_openjpeg/gs: base psi

larsu at ghostscript.com larsu at ghostscript.com
Mon Oct 4 14:30:28 UTC 2010


Author: larsu
Date: 2010-10-04 14:30:28 +0000 (Mon, 04 Oct 2010)
New Revision: 11752

Modified:
   branches/jpx_openjpeg/gs/base/sjpx_opj.c
   branches/jpx_openjpeg/gs/base/sjpx_opj.h
   branches/jpx_openjpeg/gs/psi/zfjpx.c
Log:
Add support for overriding JPX colorspaces with /ICCBased from the PDF.

This fixes #688807 again for openjpeg.



Modified: branches/jpx_openjpeg/gs/base/sjpx_opj.c
===================================================================
--- branches/jpx_openjpeg/gs/base/sjpx_opj.c	2010-10-03 16:13:00 UTC (rev 11751)
+++ branches/jpx_openjpeg/gs/base/sjpx_opj.c	2010-10-04 14:30:28 UTC (rev 11752)
@@ -415,6 +415,7 @@
                 case gs_jpx_cs_cmyk:
 		    done = copy_row_cmyk(pw->ptr, image, x, y, usable);
 		    break;
+		case gs_jpx_cs_iccbased:
                 default:
                     done = copy_row_default(pw->ptr, image, x, y, usable);
                     break;

Modified: branches/jpx_openjpeg/gs/base/sjpx_opj.h
===================================================================
--- branches/jpx_openjpeg/gs/base/sjpx_opj.h	2010-10-03 16:13:00 UTC (rev 11751)
+++ branches/jpx_openjpeg/gs/base/sjpx_opj.h	2010-10-04 14:30:28 UTC (rev 11752)
@@ -29,7 +29,8 @@
   gs_jpx_cs_gray,   /* single component grayscale image */
   gs_jpx_cs_rgb,    /* three component (s)RGB image */
   gs_jpx_cs_cmyk,   /* four component CMYK image */
-  gs_jpx_cs_indexed /* PDF image wants raw index values */
+  gs_jpx_cs_indexed,/* PDF image wants raw index values */
+  gs_jpx_cs_iccbased/* icc colorspace is set by PDF */
 } gs_jpx_cs;
 
 /* Our local state consists of pointers to the openjpeg library's

Modified: branches/jpx_openjpeg/gs/psi/zfjpx.c
===================================================================
--- branches/jpx_openjpeg/gs/psi/zfjpx.c	2010-10-03 16:13:00 UTC (rev 11751)
+++ branches/jpx_openjpeg/gs/psi/zfjpx.c	2010-10-04 14:30:28 UTC (rev 11752)
@@ -88,40 +88,8 @@
 		else if (!ISTRCMP(&sref, "DeviceCMYK"))
 		    state.colorspace = gs_jpx_cs_cmyk;
 		else if (!ISTRCMP(&sref, "ICCBased")) {
-		    /* The second array element should be the profile's
-		       stream dict */
-		    ref *csdict = sop->value.refs + 1;
-		    ref *nref;
-		    ref altname;
-		    if (r_is_array(sop) && (r_size(sop) > 1) &&
-		      r_has_type(csdict, t_dictionary)) {
-		        check_dict_read(*csdict);
-		        /* try to look up the alternate space */
-		        if (dict_find_string(csdict, "Alternate", &nref) > 0) {
-		          name_string_ref(imemory, csname, &altname);
-		          if (!ISTRCMP(&altname, "DeviceGray"))
-		            state.colorspace = gs_jpx_cs_gray;
-		          else if (!ISTRCMP(&altname, "DeviceRGB"))
-		            state.colorspace = gs_jpx_cs_rgb;
-		          else if (!ISTRCMP(&altname, "DeviceCMYK"))
-		            state.colorspace = gs_jpx_cs_cmyk;
+		    state.colorspace = gs_jpx_cs_iccbased;
 		        }
-		        /* else guess based on the number of components */
-			if (state.colorspace == gs_jpx_cs_unset &&
-				dict_find_string(csdict, "N", &nref) > 0) {
-			  if_debug1('w', "[w] JPX image has an external %d"
-				   " channel colorspace\n", nref->value.intval);
-			  switch (nref->value.intval) {
-			    case 1: state.colorspace = gs_jpx_cs_gray;
-				break;
-			    case 3: state.colorspace = gs_jpx_cs_rgb;
-				break;
-			    case 4: state.colorspace = gs_jpx_cs_cmyk;
-				break;
-			  }
-			}
-		    }
-		}
 	    } else {
 		if_debug0('w', "[w] Couldn't read JPX ColorSpace key!\n");
 	    }



More information about the gs-commits mailing list