A second limit involves the maximum number of colors used in a bitmap. Each pixel on the screen can have one or more bits of color information attached to it. The number of bits associated with each pixel in a bitmap is known as the image depth. Using one color bit per pixel in a bitmap allows the pixel to be either on or off—producing a monochrome image. Using four color bits per pixel allows the bitmap to support 16 different colors; and using eight color bits per pixel allows the bitmap to support 256 colors.
Note:
A bitmap that uses one color bit per pixel does not necessarily display images in just black or white; it just limits the image to using two hues or colors.
Simple drawings and cartoons can get by with just 16 colors. Natural images, however, normally require at least 256 colors. Some software packages can now create 24-bit bitmaps that contain 16 million different colors.
As the tones in the image are sampled to create a bitmap, a color palette—a table of distinct color values—is also created. Each color in a palette is identified by components of the colors red, green, and blue (RGB). The digitizing software assigns an entry in this palette to each pixel in the bitmap. The number of colors in the palette depends on the image depth.
A Multimedia PC equipped with a standard VGA display can support 16 colors in 640 by 480 resolution mode, or 256 colors in 320 by 200 resolution mode. A Multimedia PC equipped with an enhanced VGA display can support 256 colors in 640 by 480 resolution mode.
This disparity of quality creates somewhat of a dilemma—if you want to develop your applications for the broadest market, you can use 16-color (4-bit) bitmaps. However, Windows with Multimedia automatically maps each color to the closest fit when displaying 8-bit images on 4-bit displays. Two 4-bit display drivers included with the system software can yield good results with this 8-to-4 bit mapping:
The 16-color grayscale driver works with a fixed palette; results are good but color is lost since the image appears in tones of grey, black, and white. You can suggest that customers with 4-bit systems use the grayscale display driver.
The palettized VGA driver supports custom color palettes; results are good if the optimal palette is used. You can include a custom palette giving good results displaying 8-bit images on 4-bit displays.
A color enhancement called dithering can also improve the appearance of bitmaps, whether they're monochrome, 16-color, or 256-color. Dithering is a technique for representing an image using fewer colors than it originally had. Using a subset of the colors defined for a bitmap, dithering varies the grouping of pixels to best recreate the effect of the colors lost. A good dithering method can create the illusion of having additional colors in a bitmap. You can create dithered 4-bit versions of your 8-bit images with BitEdit.
If you want your applications to have the greatest allure, use 256-color (8-bit) bitmaps. To guarantee you cover all bases, include both 4-bit and 8-bit images and have your application identify the display capabilities so it knows which to use. The MDK provides the BitEdit and PalEdit tools for use with bitmaps and their color palettes. Use BitEdit to modify and enhance the bitmap image itself. Use PalEdit to display and modify a bitmap's associated color palette.