[gs-commits] rev 11844 - trunk/gs/Resource/Init
alexcher at ghostscript.com
alexcher at ghostscript.com
Sat Oct 23 22:38:17 UTC 2010
Author: alexcher
Date: 2010-10-23 22:38:17 +0000 (Sat, 23 Oct 2010)
New Revision: 11844
Modified:
trunk/gs/Resource/Init/pdf_draw.ps
Log:
Move checking for /JPXDecode filter in front of checking for missing color
spaces to handle /SMaskInData attribute in all cases. Fix handling of filter
arrays and a wrong name /DecodeParms.
Modified: trunk/gs/Resource/Init/pdf_draw.ps
===================================================================
--- trunk/gs/Resource/Init/pdf_draw.ps 2010-10-23 22:19:53 UTC (rev 11843)
+++ trunk/gs/Resource/Init/pdf_draw.ps 2010-10-23 22:38:17 UTC (rev 11844)
@@ -1163,7 +1163,62 @@
currentdict /jp2_tag_dict .undef
currentdict /jp2_csp_dict .undef
-/makeimagedict { % <resdict> <newdict> makeimagedict <imagemask>
+% 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
+
+/get-smask-in-data { % <dict> -> <int>
+ /SMaskInData knownoget {
+ dup dup 1 ne exch 2 ne and {
+ pop 0
+ } if
+ } {
+ 0
+ } ifelse
+} bdef
+
+/makeimagedict { % <resdict> <newdict> makeimagedict <imagemask?>
% On return, newdict' is currentdict
begin
/Width 2 copy oget def
@@ -1173,6 +1228,7 @@
/Interpolate 2 copy knownoget { def } { pop } ifelse
makeimagekeys
} bdef
+
/makeimagekeys { % <resdict> makeimagekeys <imagemask>
% newdict is currentdict
% Assumes Width, Height, BPC, Interpolate already copied.
@@ -1195,8 +1251,6 @@
//true
} {
% Opaque image
- dup /ColorSpace oknown
- 1 index /BitsPerComponent oknown and not {
dup /Filter knownoget {
dup type /arraytype eq {
dup length
@@ -1206,11 +1260,15 @@
pop
} ifelse
} if
- /JPXDecode eq {
+ /JPXDecode eq
+ } {
+ //false
+ } ifelse { % /JPXDecode tricks
+ dup /ColorSpace oknown
+ 1 index /BitsPerComponent oknown and not {
% JPXDecode filters can omit the /ColorSpace and /BitsPerComponent
% keys, in which case the interpreter must retrieve this information
- % from inside the compressed stream. Here we substitute the most
- % likely values as a work-around.
+ % from inside the compressed stream.
dup /IDFlag known {
( **** Warning: PDF spec bans inline JPX images.\n) pdfformaterror
% Inline stream is not positionable. Cannot get ColorSpace.
@@ -1223,29 +1281,29 @@
dup length 1 sub 0 exch getinterval
1 index exch /Filter exch put
- dup /Params knownoget {
+ dup /DecodeParms knownoget {
dup type /arraytype eq {
dup length 1 gt {
dup length 1 sub 0 exch getinterval
- 1 index exch /Params exch put
+ 1 index exch /DecodeParms exch put
} {
pop
- dup /Params undef
+ dup /DecodeParms undef
} ifelse
} {
pop
- dup /Params undef
+ dup /DecodeParms undef
} ifelse
} if
} {
pop
dup /Filter undef
- dup /Params undef
+ dup /DecodeParms undef
} ifelse
} {
pop
dup /Filter undef
- dup /Params undef
+ dup /DecodeParms undef
} ifelse
//false resolvestream get_jp2_csp
@@ -1267,23 +1325,28 @@
} forall
} ifelse
- } if
- } if
- currentdict /BitsPerComponent oknown not {
- ( **** Warning: image has no /BitsPerComponent key; assuming 8 bit.\n)
- pdfformaterror
- /BitsPerComponent 8 def
- } if
- } if
+ } if % fi missing csp, bpc
- currentdict /ColorSpace knownoget not {
- dup /ColorSpace knownoget not {
- ( **** Warning: image has no /ColorSpace key; assuming /DeviceRGB.\n)
- pdfformaterror
- /DeviceRGB
+ dup get-smask-in-data dup 0 ne {
+ PDFusingtransparency {
+ /SMaskInData exch def % Propagate the flag to imagedict
+ /Alpha //true //add-to-last-param exec % and to the filter.
+ } {
+ pop
+ } ifelse
+ } {
+ pop
+ } ifelse
+
+ //last-ditch-bpc-csp exec
+
+ dup /ColorSpace oknown {
+ % Propagate known color space to the filter
+ /ColorSpace currentdict /ColorSpace get //add-to-last-param exec
} if
- } if
- resolvecolorspace /ColorSpace exch def
+ } { % not JPX image
+ //last-ditch-bpc-csp exec
+ } ifelse % fi JPX tricks
% Decode is required for the PostScript image operators.
/Decode 2 copy knownoget not {
@@ -1298,6 +1361,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