Results 1 to 6 of 6

Thread: Compression

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800

    Compression

    I know nothing about compression...how does it work...can I make a program compress things? any articles? explanations? thanks everyone!

  2. #2
    Zaei
    Guest
    I can spell out a simple RLE algorithm right here. Its really simple, but here goes:

    Using a fairly large buffer of byte (or other data type) data, loop through the entire thing. If there are 6 or more of the same byte in a row, in a new buffer, add a DWORD pos (the position in the file that the repetition occurs), and a length byte (total, 5 bytes). Then, in an output buffer, write out just one of the repeating data. other wise, just add the byte into the output. Here is an example:
    Code:
    input string = "xxxxxxxccffvvssssssrrccsssssccssawwpppp"
    output data = "40786xccffvvsrrccsssssccssawwppp"
    The first number is a dword, containing the position of the actual data's start position. The second pair of numbers is a position of compressed data, and the length. Same with the last pair of numbers. So, to decompress, simply parse the data, and check the header positions. If there is an entry, output "length" of the current data byte.

    As you can probably see, this is a very simple method. It would work well using DWORD input data, with images with large streches of a single color (masks for transparent Blts are an example).

    Z.

  3. #3
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    You can use Huffman coding

    or uses somebody else library like bzip2(BSD license)

    You can do the search on the web as I do not have the URLs.

    I only read these briefly so I can't really provide any substantial help.

    You can't really ask me question on Huffman coding bcos I myself have questions on Huffman coding which I haven't emailed to ask the webpage writer.(I saved the webpage in my HDD, so no URL.)

    Hope it still helps.
    I'm a VB6 beginner.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    ok I checked HowStuffWorks.com and found a pretty good article...so do I just open the file as text and then compress it as text???

  5. #5
    Zaei
    Guest
    Compress as binary. Text streams will convert some characters into another form, which will screw up your file.

    Z.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    So I open it as binary...then look for repetetive binary strings? replace them with a character of some sort...save it in text, then when decompressing convert it back to binary and save it as binary?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width