Saturday 20 September 2008

Lempel-Ziv-Welch? What the hell?

Okay, I've been too free today, so I've been researching about data compression methods. At first, I came across this method called Huffman's coding, which is quite smart. It creates a tree with all the data that needs to be compressed according to the "weight" of each data or how often each of the data occurs. The problem is, I couldn't really implement it in C# quite nicely.

So, I scrapped it and went on searching for some other compression methods. Then, Wikipedia showed me LZW, Lempel Ziv Welch. It's a widely used compression method for graphics. So, I thought, why not give it a try. It's quite simple.

So, I spent about 2 hours coding the algorithm, and in the end, it works!! I simply made a file, which is about 1.67 KB in size. Then use it on my implementation of LZW, and it successfully halved its size! That's quite a major achievement for me, since I'm not really good at these things.

Now, I'm making a decompressor for it. If it works out, then I can build my own installer, so I don't need to rely on third party installers next time. My Mr Ball Arena is actually using a third party installer now.

Wow, learning new things can be quite fun!

EDIT:
Okay, so I tested mt decompressor as well, turns out my compressor is highly flawed!! I didn't know there were so many freaking glitches!! I guess my implementation is totally wrong. Sigh... back to the drawing board!

0 comments: