Forum > Beginners
RLE: Run Length Encode Text Compression App (Simple)
Boleeman:
An RLE Text Compression sample program (originally listed by DreamVB)
Nice lossless text compression.
Bart:
For the average text RLE is not very suitable, since normal text doesn't have many repeating characters in it.
Since you put a number (at least 1 byte) in front of every token, it'll make the "compressed" text larger than the original.
This:
--- Code: ---The quick brown fox jumps over the lazy dog.
--- End code ---
will be "compressed" into this:
--- Code: ---1T1h1e1 1q1u1i1c1k1 1b1r1o1w1n1 1f1o1x1 1j1u1m1p1s1 1o1v1e1r1 1t1h1e1 1l1a1z1y1 1d1o1g1.
--- End code ---
Also, your compression routine crashes if the input string is empty.
Bart
jamie:
RLE is pretty much useless for text. In most cases, it will make the final bin larger.
Boleeman:
Just an example of how to collect and add up character tallies. Not meant to be a serious type of compression, although it is used in BMP images, where the pixels may repeat a bit more than in text.
The program does not crash when the 1st Memo is empty (as shown in the attached gif) when running on Windows10.
Would love to see a simple example of RLE image compression for say a small Pixel editor.
KodeZwerg:
compression in general should not lead to anything that you could display visual. (the "compressed" i mean)
just use binary and/or take a look at zLib for example. easy to handle, way better compressed.
so in your case it ends as bytes like "0x0130" (2 byteset that decode to 1x "0") while your current doing would be visual "10" and maybe it break at that point since "10" is a number and "accidently" decode to the next non-number like 10x "??????????"
Navigation
[0] Message Index
[#] Next page