Mindhue Studio

Printmaking, conceptual and installation art

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 000000 or 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 8F.

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   11 = "
2 = c   22 = $
3 = d   33 = %
4 = e   44 = &
5 = f   55 = '
6 = g   66 = (
7 = h   77 = )
8 = i   88 = *
9 = j   99 = +
A = k   AA = ,
B = l   BB = -
C = m   CC = .
D = n   DD = /
E = o   EE = :
F = p   FF = ;

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:

`GCS`12x17`{6ag12ae!ghi9ago11ag8aigag4ah*gpiag3a4h3pigahih3ihphioa3hp
)phigia)ih;hp)!*)p3hpi3ai5hgh3a3ihp4h!*haihp)g!b)i!i)3ajd)i8abj3hi5a

1 Comments on “Further CGA ETG Compression”

  1. Pingback: Cross-stitch CGA Palette | Mindhue Studio