Monochrome Bitmaps

The monochrome bitmap is another bitmap format available in Fastgraph. Like other bitmaps, a monochrome bitmap is a rectangular grid of pixels, but each pixel is represented by a single bit. This means we can store eight pixels in each byte of the bitmap. If a bit is 1, the corresponding pixel will be displayed in the current color. If a bit is 0, the corresponding pixel will be transparent. Monochrome bitmaps are often useful for displaying bitmapped text, or for displaying single-color images in different colors.

Let's again consider the familiar 9x5 triangle image:

. . . . * . . . .
. . . * x * . . .
. . * x x x * . .
. * x x x x x * .
* * * * * * * * *

Recall that the triangle's perimeter is a different color than its interior, so we must create one bitmap for the perimeter pixels and another for its interior pixels. Let's separate the image into these two bitmaps.

. . . . * . . . .        . . . . . . . . .
. . . * . * . . .        . . . . x . . . .
. . * . . . * . .        . . . x x x . . .
. * . . . . . * .        . . x x x x x . .
* * * * * * * * *        . . . . . . . . .
perimeter pixels         interior pixels 

The next step is to convert these two bitmaps into their binary representations. As mentioned before, we can store eight horizontally adjacent pixels in each byte of the bitmap. Each row contains nine pixels, so we need two bytes to store one row of pixels. In each row, we thus have seven filler bits that pad the rightmost byte to a multiple of eight pixels. This presents no problem, because we can set the filler bits to zero, effectively making them transparent pixels. Each bitmap is five pixels high, so we need a 10-byte array to store each bitmap (five rows times two bytes per row). The binary representations of each bitmap, along with their hexadecimal equivalents, are shown here. The filler bits needed to pad each row of the bitmaps after the ninth pixel are shown in italics. All filler bits must be zero.

0

0

0

0

1

0

0

0

 

0

0

0

0

0

0

0

0

08

00

0

0

0

1

0

1

0

0

0

0

0

0

0

0

0

0

14

00

0

0

1

0

0

0

1

0

0

0

0

0

0

0

0

0

22

00

0

1

0

0

0

0

0

1

0

0

0

0

0

0

0

0

41

00

1

1

1

1

1

1

1

1

1

0

0

0

0

0

0

0

FF

80

perimeter bitmap

0

0

0

0

0

0

0

0

 

0

0

0

0

0

0

0

0

00

00

0

0

0

0

1

0

0

0

0

0

0

0

0

0

0

0

08

00

0

0

0

1

1

1

0

0

0

0

0

0

0

0

0

0

1C

00

0

0

1

1

1

1

1

0

0

0

0

0

0

0

0

0

3E

00

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

00

00

interior bitmap

The subscript order for monochrome bitmaps is the same as for other bitmaps. That is, the first element of the bitmap array represents the lower left corner of the image. The subscript progression then continues to the right and upward. Assuming subscripts begin at zero, the subscript order for the 2x5 monochrome bitmap array for our 9x5 triangle image would thus be:

[8]

[9]

[6]

[7]

[4]

[5]

[2]

[3]

[0]

[1]

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.