[gs-commits] rev 11794 - branches/luratech_work/Resource/Init

alexcher at ghostscript.com alexcher at ghostscript.com
Wed Oct 13 04:22:30 UTC 2010


Author: alexcher
Date: 2010-10-13 04:22:30 +0000 (Wed, 13 Oct 2010)
New Revision: 11794

Modified:
   branches/luratech_work/Resource/Init/pdf_base.ps
   branches/luratech_work/Resource/Init/pdf_draw.ps
Log:
Move the code that propagates external color space to JPXDecode filter
from the stream handler to the image processing logic where it belongs.
Fix a case where the color space was not resolved. Also propagate Alpha
flag to the filter.
	

Modified: branches/luratech_work/Resource/Init/pdf_base.ps
===================================================================
--- branches/luratech_work/Resource/Init/pdf_base.ps	2010-10-12 23:27:36 UTC (rev 11793)
+++ branches/luratech_work/Resource/Init/pdf_base.ps	2010-10-13 04:22:30 UTC (rev 11794)
@@ -462,20 +462,32 @@
 		% PDF linearization, we no longer do this.
   get oforce
 } bind def
+
 /oforce_array { % <array> oforce_array <array>
   [ exch { oforce } forall ]
 } bind def
+
 /oforce_elems { % <array> oforce_elems <first> ... <last>
   { oforce } forall
 } bind def
+
 /oforce_recursive { % <any> oforce_recursive <any>
-  oforce dup type dup /arraytype eq {
-    pop [ exch { oforce_recursive } forall ]
+  dup type /arraytype eq {    
+    dup rcheck {              % protect tint transform functions, etc.
+      oforce                  % but dereference {1 0 R}
+      dup type /arraytype eq {
+        [ exch { oforce_recursive } forall ]
   } {
-    /dicttype eq {
+        dup type /dicttype eq {
      << exch { oforce_recursive exch oforce exch } forall >> 
     } if
   } ifelse
+    } if
+  } {
+    dup type /dicttype eq {
+      << exch { oforce_recursive exch oforce exch } forall >> 
+    } if
+  } ifelse
 } bind def
 
 % A null value in a dictionary is equivalent to an omitted key;
@@ -996,29 +1008,6 @@
   } if
 } bind def
 
-% When used with a PDF image dict, the JPXDecode filter needs to know
-% about any ColorSpace entries, since this overrides whatever is in
-% the image stream itself. We therefore propagate any such key into
-% a filter's DecodeParms.
-/jpxparmfix {	% <streamdict> <readdata?> jpxparmfix <streamdict <readdata?>
-  1 index /Filter .knownget
-    { /JPXDecode eq % we only need to do this for JPXDecode filters
-	% TODO: handle filter arrays
-      {
-	1 index /ColorSpace knownoget {
-	  2 index /DecodeParms knownoget {
-	    % insert in the existing DecodeParms dict
-	    /ColorSpace 3 -1 roll put
-	  }{
-	    1 dict % need to create a custom DecodeParms dict
-	    dup /ColorSpace 4 -1 roll put
-	    2 index exch /DecodeParms exch put
-	  } ifelse
-	} if
-      } if
-    } if
-} bind def
-
 % Resolve a stream dictionary to a PostScript stream.
 % Streams with no filters require special handling:
 %     - Whether we are going to interpret the stream, or If we are just
@@ -1027,7 +1016,6 @@
 % Note that, in general, resolving a stream repositions PDFfile.
 % Clients must save and restore the position of PDFfile themselves.
 /resolvestream {	% <streamdict> <readdata?> resolvestream <stream>
-  jpxparmfix
   1 index /F knownoget {
 		% This stream is stored on an external file.
     (r) file 3 -1 roll

Modified: branches/luratech_work/Resource/Init/pdf_draw.ps
===================================================================
--- branches/luratech_work/Resource/Init/pdf_draw.ps	2010-10-12 23:27:36 UTC (rev 11793)
+++ branches/luratech_work/Resource/Init/pdf_draw.ps	2010-10-13 04:22:30 UTC (rev 11794)
@@ -1163,6 +1163,51 @@
 currentdict /jp2_tag_dict .undef
 currentdict /jp2_csp_dict .undef
 
+% Add a key-value pair to the last /DecodeParms dictionary
+% <resdict> <key> <value> -> <resdict>
+/add-to-last-param {
+  2 index /DecodeParms knownoget {
+    dup {} eq {
+      pop //false
+    } {
+      //true
+    } ifelse
+  } {
+    //false
+  } ifelse {
+    dup type /arraytype eq {
+      [ exch { oforce } forall
+        dup //null eq { pop 1 dict } if
+      ] 
+      dup dup length 1 sub get           % <resdict> <key> <value> []   <<>>
+    } {
+      dup                                % <resdict> <key> <value> <<>> <<>>
+    } ifelse
+    4 2 roll put                         % <resdict> obj
+  } {
+    mark 3 1 roll .dicttomark            % <resdict> obj
+  } ifelse
+  1 index exch
+  /DecodeParms exch put                  % <resdict>
+} bdef
+
+/last-ditch-bpc-csp {
+  currentdict /BitsPerComponent oknown not {
+    (   **** Warning: image has no /BitsPerComponent key; assuming 8 bit.\n)
+    pdfformaterror
+    /BitsPerComponent 8 def
+  } if
+
+  currentdict /ColorSpace knownoget not {
+    dup /ColorSpace knownoget not {
+      (   **** Warning: image has no /ColorSpace key; assuming /DeviceRGB.\n)
+      pdfformaterror
+      /DeviceRGB
+    } if
+  } if
+  resolvecolorspace /ColorSpace exch def
+} bdef
+
 /makeimagedict {	% <resdict> <newdict> makeimagedict <imagemask>
 			% On return, newdict' is currentdict
   begin
@@ -1173,6 +1218,7 @@
   /Interpolate 2 copy knownoget { def } { pop } ifelse
   makeimagekeys
 } bdef
+
 /makeimagekeys {	% <resdict> makeimagekeys <imagemask>
               	% newdict is currentdict
 		% Assumes Width, Height, BPC, Interpolate already copied.
@@ -1273,27 +1319,21 @@
 
       dup /SMaskInData knownoget {
         0 ne {
-          % For now do nothing
+          % Propagate Alpha flag to the filter
+          /Alpha //true //add-to-last-param exec
         } if
       } if
  
-    } if  % fi JPX tricks
+      //last-ditch-bpc-csp exec
 
-    currentdict /BitsPerComponent oknown not {
-      (   **** Warning: image has no /BitsPerComponent key; assuming 8 bit.\n)
-      pdfformaterror
-      /BitsPerComponent 8 def
+      dup /ColorSpace oknown {
+        % Propagate known color space to the filter
+        /ColorSpace currentdict /ColorSpace get //add-to-last-param exec
     } if
+    } { % not JPX image
+      //last-ditch-bpc-csp exec
+    } ifelse % fi JPX tricks
 
-    currentdict /ColorSpace knownoget not {
-      dup /ColorSpace knownoget not {
-        (   **** Warning: image has no /ColorSpace key; assuming /DeviceRGB.\n)
-        pdfformaterror
-        /DeviceRGB
-      } if
-    } if
-    resolvecolorspace /ColorSpace exch def
-
 		% Decode is required for the PostScript image operators.
     /Decode 2 copy knownoget not {
       ColorSpace //defaultdecodedict
@@ -1307,6 +1347,9 @@
   } ifelse
 } bdef
 
+currentdict /add-to-last-param undef
+currentdict /last-ditch-bpc-csp undef
+
 /DoImage {
   checkaltimage dup length 6 add dict
   1 index /SMask knownoget { 1 index exch /SMask exch put } if



More information about the gs-commits mailing list