Article View: comp.lang.postscript
Article #1768Level II compression questions
From: Boyd Blackwell
Date: Fri, 14 Aug 1992 03:04
Date: Fri, 14 Aug 1992 03:04
70 lines
3081 bytes
3081 bytes
I have just attempted to convert gnu-compress4.01 to produce compressed
output suitable for feeding into LZWDecode filter in Level II postscript. It
works up to the first token length change. Before beating my haed against the
wall, I would like to know if anyone already has c code for LZWEncode.
It is like unix compress, BUT
a/ does not start with the magic number and the bit length
b/ DOES start with an explicit table clear 256(10)
c/ appears to change bit length smoothly without a buffer flush
d/ ends with an EOD token (what a good idea!) 257(10)
e/ pushes bits the other way - i.e. the MSBit
first (CLEAR is 0x80 0x0.. not 0x00 0x8..)
This is based on the Postscript Language Reference Manual *SECOND* edition
pp.130 132 - (yes it is worth buying!)
If anyone can correct my interpretation or provide more info, I will post a
corrected article.
Hint: If you want to test any of these filters, you can let your Laserwriter
IIf or IIg or your Tek Phaser II PXe/i do it for you - they can encode and
decode.
Here is some smaple code
%!
%designed as a quick test bdb 6/92
(filter test: ) print
/=print where not {/=print {( ) cvs print} def 1} if pop % 1 or dict
statusdict begin revision ( )
printername product
print ([) print print (] rev. ) print =print ( ) print
pagecount =print ( pages ) print
end
(\nLZWEncode ASCII info following this file:\n) print
realtime
(%stdout) (w) file
/ASCIIHexEncode filter dup
/LZWEncode filter dup /FILTER exch def
{ FILTER (%stdin) (r) file 256 string readstring
{writestring} {writestring closefile closefile
(\nEND: ) print
realtime exch sub 1000 div =print ( sec ) print exit} ifelse} loop
-----A---B
% replace the above line (-----A)with your test data line(s) - up to about 20k chars
% the example -----A---B comes from the Ps Lang. Ref Man (45 45 45 45 45 65...)
Sample run:
===========
% setenv PRINTER scu_colour
% /usr/local/cap/lwpr ~/ps/foo.ps
abInit: [ddp: 4.23, 51], [GW: 4.23, 33] starting
Status: status: idle
status: idle
Sending /users/prl1/bdb112/ps/foo.ps
filter test: Phaser II PXe[Phaser II PXe] rev. 2 103 pages
LZWEncode ASCII info following this file:
800B6050220C0C840A8080>
END: 0.0 sec bdb112@rsphy1>
Note the line 800B.... is the same as p 132. Ps Lang. Ref Man
--
-Boyd Blackwell
Plasma Research Lab, RSPhysSE, ANU/ GPO Box 4 /Canberra ACT 2601/AUSTRALIA
internet: bdb112@prl1.anu.edu.au
PHONE: +61 62 49 2482 +61 62 51 2605(h) FAX: Boyd Blackwell, PRL +61 62 49 1884
Technical Details
Message-ID:
<1992Aug14.030418.1512@newshost.anu.edu.au>Path:
arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!manuel!rsphy3.anu.edu.au!bdb112Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.postscript Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!manuel!rsphy3.anu.edu.au!bdb112 From: bdb112@rsphy3.anu.edu.au (Boyd Blackwell) Subject: Level II compression questions Message-ID: <1992Aug14.030418.1512@newshost.anu.edu.au> Keywords: ENcode compression Level II source Sender: news@newshost.anu.edu.au Reply-To: bdb112@rsphy3.anu.edu.au (Boyd Blackwell) Organization: Plasma Research Laboratory Date: Fri, 14 Aug 92 03:04:18 GMT Lines: 70