home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / graphics / 13192 < prev    next >
Encoding:
Internet Message Format  |  1992-12-24  |  2.5 KB

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