home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.graphics:13192 comp.lang.postscript:6098
- Newsgroups: comp.graphics,comp.lang.postscript
- Path: sparky!uunet!van-bc!cs.ubc.ca!news.UVic.CA!spang.Camosun.BC.CA!suncad.camosun.bc.ca!morley
- From: morley@suncad.camosun.bc.ca (Mark Morley)
- Subject: Re: Anyone got RLE code in C?
- Message-ID: <1992Dec24.042641.1705@spang.Camosun.BC.CA>
- Sender: news@spang.Camosun.BC.CA (Network News)
- Nntp-Posting-Host: suncad.camosun.bc.ca
- Organization: Camosun College, Victoria B.C, Canada
- X-Newsreader: Tin 1.1 PL4
- References: <1haknjINNn0p@phakt.usc.edu>
- Date: Thu, 24 Dec 1992 04:26:41 GMT
- Lines: 44
-
- sgoldste@phakt.usc.edu (Fogbound Child) writes:
- : Hi there!
- :
- : I'm looking for some C code to do the RLE encoding used by Postscript[tm]
- : for image compression.
- :
- : If it's out there and available, please let me know. Otherwise, I'll write it
- : and make it available sometime in January.
- :
- : Thanks!
- : ___Samuel___
- : --
- : _________Pratice Safe .Signature! Prevent Dangerous Signature Virii!_______
- : Guildenstern: Our names shouted in a certain dawn ... a message ... a
- : summons ... There must have been a moment, at the beginning,
- : where we could have said -- no. But somehow we missed it.
-
- Hmmm... Just the other day I wrote a set of C routines for doing RLE
- compression/decompression. I'm not sure if the routines are compatible
- with Postscript RLE or not, but you're welcome to them (as is anyone else
- who cares to ask). The routines are less than a week old, but I've
- successfully compressed and decompressed all sorts of files, so I'm
- satisfied that they work. To show how the routines compress the data,
- I'll describe how the decompression takes place...
-
- 1) Read a byte. If the byte is a null (0) then we have reached the end of
- the compressed information - STOP.
- 2) Let N = the value of the lower 7 bits of the byte. Let F be either 1
- or 0, the setting of the high bit.
- 3) If F == 1 then read the next byte and repeat it N+1 times.
- If F == 0 then read the next N bytes literally.
- 4) Goto step 1
-
- I use this method along with a huffman method in a new image format I've
- developed for a project I'm working on. If there's enough interest I'll
- place it at an FTP site somewhere (probably wuarchive).
-
- MARK
-
- ====================================================================
- Mark Morley, UNIX/SUN Administrator NET: morley@camosun.bc.ca
- Camosun College - Interurban Campus TEL: (604) 370-4601
- 4461 Interurban Road Room 143-Tech FAX: (604) 370-3660
- Victoria, B.C. Canada V8X 3X1
-