December 2008

Bitmap Schematic



A: Starting Bitmap

10010001110100000101100000100110000000000000000000000000000000000000000000-
00000000000000000001111111111111111111111111111111111111111111111111111111-
11111111111111111111111111111111111111000100100001111111111110

B: Parsing Step

1001000111010000010110000010011
0000000000000000000000000000000
0000000000000000000000000000000
1111111111111111111111111111111
1111111111111111111111111111111
1111111111111111111111111111111
000100100001111111111110

C: WAH Encoding

1001000111010000010110000010011

01001000111010000010110000010011

0000000000000000000000000000000
0000000000000000000000000000000

10000000000000000000000000000010

1111111111111111111111111111111
1111111111111111111111111111111
1111111111111111111111111111111

11000000000000000000000000000011

000100100001111111111110

00000000000100100001111111111110

D: WAH Compressed Bitmap

01001000111010000010110000010011 10000000000000000000000000000010 11000000000000000000000000000011 00000000000100100001111111111110 00000000000000000000000000011000

How WAH Works
Word-aligned hybrid (WAH) code can compress a bitmap, depicted in A as a sequence of 210 1s and 0s. The objective is to compress this information but to keep it divided in groups that are the same length as the word – or fundamental unit of information – used in the computer. This example assumes that the computer word is 32 bits long. To start encoding a bitmap, this algorithm breaks (or parses) the bitmap in pieces that are 31 bits long (B). In this example, the parsing step creates six 31-bit groups and 24 bits in a final, incomplete group. WAH (the encoding shown by the arrows) stores each 31-bit group in a 32-bit word, with the “most significant bit” or MSB (the farthest left bit, highlighted in red) indicating a literal with 0 or fill word with 1 (shown in C). A literal word consists of the MSB plus the 31 bits from the group, as shown with the first group of mixed 1s and 0s. Groups of the same bit – such as the two groups of 0s and three groups of 1s – get encoded as fill words that consist of the MSB, the second MSB (highlighted in yellow, and 0 when the fill is all 0s, and 1 when the fill is all 1s), and the remaining 30 bits encode the number of 31-bit groups in the fill. For the two groups of 0s, for example, the 10 at the right end of the WAH-encoded word is binary for 2, which indicates two groups of 31 bits in the fill. For the three groups of 1s, the WAH-encoded words ends in 11, which is binary for 3 – indicating three groups of 31 bits in the fill. The final group – only 24 bits and shaded in gray in the WAH encoding – gets stored as a literal word and 0s are added to complete the word. WAH adds one last word that denotes how many bits in the partial word are used – 24, stated as 11000 in binary code (D).