Xref: utzoo comp.lang.postscript:1002 comp.sys.mac.programmer:2544 Path: utzoo!dciem!trigraph!john From: john@trigraph.UUCP (John Chew) Newsgroups: comp.lang.postscript,comp.sys.mac.programmer Subject: Re: Is run-length compression possible in PostScript? Message-ID: <406@trigraph.UUCP> Date: 26 Sep 88 13:33:05 GMT Article-I.D.: trigraph.406 References: <260@rna.UUCP> Reply-To: poslfit@gpu.utcs.toronto.edu Organization: Trigraph Inc., Toronto, Canada Lines: 41 Summary: yes. look... In article <260@rna.UUCP> marc@rna.UUCP (Marc Johnson) writes: >I am producing bitmapped images on a LaserWriter Plus using PostScript, >noteably the "image" operator. The image data can get huge, and I would >like to do run-length compression. Anybody know how if this is possible >using the "image" operator, or any other method in PostScript? >Please e-mail responses. Well... it's only a dozen lines and it might be of general interest, so here's what we use to send large bitmap logos over slow serial links to remote laserwriters. I am open to e-mailed constructive criticism, con- cerning anything but indentation style :-). To use, put the definitions for ++ and rld (run-length-decode) in your program prologue, then put in reasonable values for tx, ty, sx, sy, wid, hgt, inv, mat, lots-of-hex-data, size-of-expanded-string and put the rest into your program script. This should of course work with the image operator just as easily as with the imagemask operator. %%%%% START CUTTING HERE %%%%% /++ {dup load dup 1 add exch 3 1 roll def}bind def /rld {0 begin/s 2 index def/d 1 index def/sln s length def/sp 0 def/dp 0 def {sp sln eq {exit}if s/sp ++ get dup 127 gt {256 sub neg s/sp ++ get exch {dup d/dp ++ 3 -1 roll put}repeat pop} {{d/dp ++ s/sp ++ get put}repeat}ifelse }loop end}bind def/rld load 0 5 dict put tx ty translate sx sy scale wid hgt inv [mat] {size-of-expanded-string string rld exch pop} imagemask %%%%% THAT'S ALL %%%%% John Chew -- john j. chew, iii poslfit@utorgpu.bitnet trigraph, inc. poslfit@gpu.utcs.toronto.edu toronto, canada {uunet!mnetor!utzoo,utgpu,utcsri}!trigraph!john [it is my opinion that these are solely my opinions.]