Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using /flatedecode with a dictionary

Status
Not open for further replies.

havingnoidea

Programmer
Apr 26, 2005
2
0
0
CH
Hi all,

My original idea was to embed a bitmap image into an eps file. Because bitmaps in general are quite large I decided to compress it. First I thought i could simply generate a png image and embed it into an eps but then I found out that it is not possible for Postscript interpreters to decode png files directly. So I compressed the bitmap directly with the deflate algorithm (same as used in png) and used the FlateDecode filter to decode the image.

The following code is an example I wrote. The code is partly taken form an example that shows how to use the DCTDecode filter. I changed it to FlateDecode and it works this way.


%!PS-Adobe-3.0 EPSF-3.0
%%Creator: <not yet specified>
%%Title: flate_encoded.eps
%%CreationDate: Tue Apr 26 16:13:50 2005
%%BoundingBox: 0 0 548 534
%%DocumentData: Binary
%%LanguageLevel: 3
%%EndComments
%%BeginProlog
%%EndProlog
%%Page: 1 1
548 534 scale
/Data currentfile /FlateDecode filter def
/DeviceRGB setcolorspace
{ << /ImageType 1
/Width 762
/Height 743
/ImageMatrix [ 762 0 0 -743 0 743 ]
/DataSource Data
/BitsPerComponent 8
/Decode [0 1 0 1 0 1]
>> image
showpage
} exec [ deflate compressed bitmap ]
%%EOF

In the "Postscript Language Reference Manual 3rd Edition" (page 141) I discovered that Postscript supports so called PNG predictor functions which would make the compression more effective. My question now is: How do I have to change the above code so that i'm able to use the PNG predictors to decode the image? I know that I have to specify a dictionary as input for the FlateDecode filter but I'm relatively new to postscript. Any ideas how to do this?

thanks for your help
 
alright, I found a solution, the code has to look like this:

%!PS-Adobe-3.0 EPSF-3.0
%%Creator: <muss noch festgelegt werden>
%%Title: _flate_encoded.eps
%%CreationDate: Sun May 01 16:28:28 2005
%%BoundingBox: 0 0 552 552
%%DocumentData: Binary
%%LanguageLevel: 3
%%EndComments
%%BeginProlog
%%EndProlog
%%Page: 1 1
552 552 scale
/Data currentfile
<< /Predictor 11
/Columns 768
/Colors 3
/BitsPerComponent 8
>> /FlateDecode filter def
/DeviceRGB setcolorspace
{ << /ImageType 1
/Width 768
/Height 768
/ImageMatrix [ 768 0 0 -768 0 768 ]
/DataSource Data
/BitsPerComponent 8
/Decode [0 1 0 1 0 1]
>> image
showpage
} exec [deflate compressed (with PNG Sub-Predictor) bitmap]
%%EOF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top