Making an image compressor?
Hey, I'm wondering if it would be relatively not so hard to add some algorithms in my code to shrink the size of images?
So say I told my program to add all of My Pictures to it, can I shrink it somehow?
WinRar does a nice job, how complex is it lol?
What exactly is the process of shrinking the images, I don't quite understand it, (or shrinking anything, music, videos, text)
Kind Regards
Re: Making an image compressor?
This is not really the place to discuss compression algorithms. I'm sure there's plenty of literature available on that subject. In order to use a compression algorithm in your VB project you have to either write code to perform the byte by byte conversions yourself or else use classes that already implement that logic.
The .NET Framework supports GZIP compression by default, but GZIP only supports one source file per archive. If you want to compress multiple files using GZIP then you would normally create a TAR archive containing the multiple source files first, then use GZIP to compress that TAR file. The result is affectionately known as a "tar ball". Note that TAR merely combines files; it does not compress them. Also note that the Framework doesn't support TAR by default, so you'd have to read the format spec and implement the logic yourself.
Alternatively, you could use something like the free SharpZipLib to compress multiple files using the ZIP format. I submitted some code that provided a simple wrapper for #ZipLib to the VB.NET CodeBank some years ago. Although it was for an older version it should still be OK or close to it for the current version.
There would also be other implementations of compression algorithms available for .NET, both free and commercial. Just be aware that some compression algorithms carry a license fee, which I think is why the Framework doesn't implement ZIP itself.
Re: Making an image compressor?
I see, how hard is it to perform the byte-to-byte calculations, and what exactly would I be doing?
Say I have 50,000 bytes (one image) stored in memory, when I loop through those bytes and make changes, what am I changing exactly to make it smaller?
Kind Regards
Re: Making an image compressor?
Quote:
Originally Posted by
Icyculyr
I see, how hard is it to perform the byte-to-byte calculations, and what exactly would I be doing?
The specifics depend on the algorithm. If you want help to implement a specific algorithm then you should first pick the algorithm and then go and read the specification for it. You can then ask us specific questions when you encounter problems. In general, you'd be reading a series of bytes, performing a transformation and then outputting the result, which will be another series of bytes. The transformation part is where the compression algorithm comes in, obviously.