RLE Compression
Blitz3D Forums/Blitz3D Programming/RLE Compression
| ||
here is my attempt at RLE Compression for 24-Bit BMPs. It converts the RGB Values to a single integer. First each value R,G, & B get converted to Multiples of 8 (0,8,16,24,etc...) then combined into an integer 0-32767 (this reduces the quality i know. But i still think it looks good. Integers 32768-65535 are the counters. Note:32768=3 65535=32770 The reason is that when saving only 2 identical colors side by side it is still 2 integers. And in some cases, the file will not be compressed depending on the order of the colors. I know it is 2 bytes per integer. But when comparing the final result to the 24-bit BMP Image, its 2 bytes per pixel instead of 3. I dunno if this is useful at all. Probably not. I just wanted to see if i could do it. it is on the following link in the code archeives. It is with this particular code arc thread because it is yet another RLE Compression. http://www.blitzbasic.com/codearcs/codearcs.php?code=556 just input your inputfilename$ and outputfilename$. ------------------------- |
| ||
It converts the RGB Values to a single integer. First each value R,G, & B get converted to Multiples of 8 (0,8,16,24,etc...) then combined into an integer 0-32767 (this reduces the quality i know. But i still think it looks good. So, this is lossy compression, perhaps, ... Nice work, when I have time, I'll come back to look at this code. ![]() |
| ||
While run length encoding is not the greatest form of compression....here's a tip... transform your image from its 3(or 4) 8 bit channels into 24 or 32 channels (of 1 bit per channel).....and run length encode those.....typically images are often of a similar brightness and so you will for example get very long runs of particular bits - much more than you would of individual bytes or ints.. |