Generic subroutines for inserting PNG files in PostScript
Hi, I have a generic subroutine for inserting JPGs in PostScript:
/insertjpg {
/ypix exch def %height of jpeg in pixels
/xpix exch def %width of jpeg in pixels
/ymeas exch def %height of jpeg in measured distance, WITHOUT unit of measurement
/xmeas exch def %width of jpeg in measured distance, WITHOUT unit of measurement
/ypos exch def %y-position of jpeg
/xpos exch def %x-position of jpeg
/jpg exch def %full path/filename of jpeg, enclosed in parentheses
gsave
xpos ypos translate
xmeas ymeas scale
/DeviceRGB setcolorspace % How color values will be interpreted
<< % Start image dictionary
/ImageType 1
/Width xpix % Dimensions of source image
/Height ypix
/BitsPerComponent 8
/Decode [0 1 0 1 0 1] % Decode color values in normal way
/ImageMatrix [xpix 0 0 ypix neg 0 ypix] % Map unit square to source
/DataSource jpg (r) file /DCTDecode filter
>> % End image dictionary
image
xpos neg ypos translate
xmeas pt ymeas pt scale
grestore
} def
I'm trying to adapt the following code so I can insert PNGs, but I keep getting the error %%[ Error: ioerror; OffendingCommand: imageDistiller ]%%
/insertpng {
/ypix exch def %height of png in pixels
/xpix exch def %width of png in pixels
/ymeas exch def %height of png in measured distance, WITHOUT unit of measurement
/xmeas exch def %width of png in measured distance, WITHOUT unit of measurement
/ypos exch def %y-position of png
/xpos exch def %x-position of png
/png exch def %full path/filename of png, enclosed in parentheses
gsave
xpos ypos translate
xmeas ymeas scale
/DeviceRGB setcolorspace % How color values will be interpreted
<< % Start image dictionary
/ImageType 1
/Width xpix % Dimensions of source image
/Height ypix
/BitsPerComponent 8
/ImageMatrix [xpix 0 0 ypix neg 0 ypix] % Map unit square to source
/Decode [0 1 0 1 0 1] % Decode color values in normal way
%/Interpolate true
/ImageMask true
/DataSource png (r) file
%/ASCII85Decode filter
<< /Predictor 15 /Columns xpix /Colors 3 /BitsPerComponent 8 >> /FlateDecode filter
>>
image
xpos neg ypos translate
xmeas pt ymeas pt scale
grestore
} def
I appreciate any help you can offer.
