|
-
Dec 14th, 2001, 10:40 PM
#1
Thread Starter
Frenzied Member
Compression
I know nothing about compression...how does it work...can I make a program compress things? any articles? explanations? thanks everyone!
-
Dec 14th, 2001, 11:21 PM
#2
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.
-
Dec 15th, 2001, 03:56 AM
#3
Hyperactive Member
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.
-
Dec 16th, 2001, 02:26 PM
#4
Thread Starter
Frenzied Member
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???
-
Dec 16th, 2001, 03:57 PM
#5
Compress as binary. Text streams will convert some characters into another form, which will screw up your file.
Z.
-
Dec 16th, 2001, 04:48 PM
#6
Thread Starter
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|