Further CGA ETG Compression
I’ve been trying to find a way to compress images even more, so I could expand the size of the color tweets available. Basically, since Twitter uses only the usable characters of ASCII text, and it can be hard to type higher-bit ASCII on some keyboards, I’ve pretty much exhausted the palette of encoding options with my 6-bit “0-9 A-Z a-v” encoding scheme. So… instead of encoding, maybe I could address patterns in the data itself.
One of the easiest things to see in the data are strings of repeating elements. If I could further encode those strings I could save room and not have long lines of
33333 for fields of color in the image. Let’s say I simply put the number of pixels in front of the code for the pixel color, and the TwGD will decipher what was meant. So, a string of eight white CGA pixels,
FFFFFFFF, would be represented as
The only problem with this is that the character
8 already encodes for dark grey. Putting numbers in the stream will collide with the numbers already there. So I’ll need to convert the hex numbers into a new coding scheme, so the pixel quantities don’t mess with the pixel codes. Say, pixel 0 (black) equals
a, pixel 1 (dark blue) equals
b, and so on. In this scheme, the string of white,
FFFFFFFF, would become
8p. That’s a savings of 6 characters!
Of course, you won’t get that kind of savings everywhere. Especially 2-pixel doubles, since you’re just replacing 2 identical pixel codes with a “2” and the new code. There’s still some squishing to be had here. For this special case, I came up with a second series of codes, using punctuation to stand for pixel doubles. Here’s the full set of codes for this scheme, which I’m calling Similar String CGA encoding (“CGS”)
0 = a 00 = !
1 = b
2 = c
3 = d
4 = e
5 = f
6 = g
7 = h
8 = i
9 = j
A = k
B = l
C = m
D = n
E = o
F = p
So, using this additional compression scheme, I was able to encode a 12 x 17 pixel CGA image with plenty of room to spare. It doesn’t sound like too much extra, but that’s 150% the area of the 10 x 13 CGA pixel image I tweeted back in December, and includes the ETG header information, too.
Here’s the image, a color version of the self-portrait from yesterday:
And the resulting tweet, using “CGS” as the code for this new compression scheme: