Allows encoding a small image with a limited number of colors into an integer.
The bit-width of a pixel in the image is ceil(log2(n_colors))
.
The bit-width of a socket image int is pixel-bit-width * size^2)
This python implementation doesn't concern itself with what the bit-width of the entire integer is. Real implementations care. This is determined by the image size. I'm assuming all images are square. When I say the size is "4" I really mean "4x4"). An image with size 4 with 4 possible colors would have 16 pixels and each pixel requires 2 bytes. This means we need a 32 bit int to hold our image,
See the attached image for a visualization. The difference is that this implementation puts (0, 0) at the end of the bit-string for conveinence with <</>> operators and the fact that I don't know the bit-width of python ints.