About Bitmaps

A bitmap is one of the GDI objects that can be selected into a device context (DC). Device Contexts are structures that define a set of graphic objects and their associated attributes, and graphic modes that affect output. The table below describes the GDI objects that can be selected into a DC.

Graphic Object Purpose
Bitmaps A bitmap is used to create, manipulate (scale, scroll, rotate, and paint), and store images as files on a disk.
Brushes A brush is used to paint the interior of polygons, ellipses, and paths.
Fonts Fonts are used to draw text on video displays and other output devices.
Logical Palette A logical palette is a color palette that an application creates and associates with a given device context.
Paths A path is one or more figures (or shapes) that are filled, outlined, or both filled and outlined.
Pens A pen is a graphics tool that a Win32-based application uses to draw lines and curves.
Regions A region is a rectangle, polygon, or ellipse (or a combination of two or more of these shapes) that can be filled, painted, inverted, framed, and used to perform hit testing (testing for the cursor location).

From a developer's perspective, a bitmap consists of a collection of structures that specify or contain the following elements:

A bitmap size is related to the type of image it contains. Bitmap images can be either monochrome or color. In an image, each pixel corresponds to one or more bits in a bitmap. Monochrome images have a ratio of one bit per pixel. Color imaging is more complex. The number of colors that can be displayed by a bitmap is equal to 2 times the number of bits per pixel. A 256-color bitmap requires 8 bits per pixel.

Control Panel applications are examples of applications that use bitmaps. When you select a wallpaper for your desktop, you actually select a bitmap, which the system uses to paint the desktop background. The system creates the selected wallpaper pattern by repeatedly drawing a 32- by 32-pixel pattern on the desktop. The wallpaper pattern is stored as a bitmap in the file REDBRICK.BMP.

The following illustration presents the developer's perspective of the bitmap found in the file REDBRICK.BMP. It shows a palette array, a 32- by 32-pixel rectangle, and the index array that maps colors from the palette to pixels in the rectangle.

In the preceding example, the rectangle of pixels was created on a VGA display device using a palette of 16 colors. A 16-color palette requires 4-bit indexes; therefore, the array that maps palette colors to pixel colors is composed of 4-bit indexes as well. (For more information about logical color-palettes, see Colors.)

Note  In the above bitmap, the system maps indexes to pixels beginning with the bottom scan line of the rectangular region and ending with the top scan line. (A scan line is a single row of adjacent pixels on a video display.) For example, the first row of the array (row 0) corresponds to the bottom row of pixels, scan line 31. This is because the above bitmap is a "bottom-up" device-independent bitmap (DIB), a common type of bitmap. In "top-down" DIBs and in device-dependent bitmaps (DDB), The system maps indexes to pixels beginning with the top scan line.