Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!apple!agate!shelby!polya!rokicki From: rokicki@polya.Stanford.EDU (Tomas G. Rokicki) Newsgroups: comp.lang.postscript Subject: Re: compressed images Message-ID: <10749@polya.Stanford.EDU> Date: 20 Jul 89 18:29:44 GMT References: <59760@philabs.Philips.Com> Sender: Tomas G. Rokicki Organization: Stanford University Lines: 37 jcm@nori.Philips.Com (John Martin) writes: > Has anyone implemented a PostScript run length decoder procedure that > will allow run length compressed files to be sent to the printer? > Assume that the compression is done by a C program in advance. Sure, this is easy, and for most printers that run over 9600 buad serial lines, it's actually faster. You use a simple run-length scheme. The loop to decode looks like grab a byte if it's > 128 repeat the next byte (n-128) times else grab the next n bytes literally It's sometimes smart to not attempt full compression; ie, only compress into run-length if the run count is four or greater, or some such, to help avoid some interpreter overhead with all the really small chunks. I'll post code as soon as I go home and get some. Another idea that works much better for some pictures (and is faster for some as well) is to just send the first raster row, and then compute and send `differences'; these differences can be a right shift, a left shift, etc. This is especially fast for line-art type rasters or structured drawings. Now if we can only encourage Adobe to give us a readlempelzivstream instead of readhexstring . . . > I have made several attempts at getting this to work, but have run > into problems because of limited stack size, and inconsistent > treatment of whitespace characters by "read", "readhexstring", and > "readline". Use readhexstring exclusively; that's all you need. -tom