70.1.2 Color Video-Display Technology

In addition to understanding the physics of color and light, it's important that you also understand certain aspects of color video-display technology. A color video-display is normally a raster device (as opposed to a vector device)—it treats the display surface as a coordinate space and draws lines, curves, text, and filled objects by repeatedly “scanning” rows of picture elements (called pixels) from left to right and from top to bottom. The pixels become visible when one or more electron guns in the back of the display fire an electron beam onto a phosphor coating on the back of the display surface. When struck by the electron beam(s), the phosphor “glows” and emits visible light. In the simplest case, a single pixel is created by combining the light produced by three electron guns. When the beam of each gun strikes the phosphor coating, it generates red, green, or blue light of varying intensity. When viewed by the human eye, the three dots produced by the three guns appear to merge and form a single color. The point at which the three dots merge is a single pixel.

Color video-technology is often called an additive technology because the color of a pixel is specified by adding the intensity values for each of the primaries. For example, if the minimum intensity on a given display was specified as 0 and maximum intensity was specified as 255, a white pixel would be identified by the RGB triplet (255, 255, 255), a black pixel would be identified by the RGB triplet (0, 0, 0), and a cyan pixel would be identified by the RGB triplet (0, 255, 255).

The recent introduction of the 8514, VGA, and more recently, super-VGA video adapters brought significant improvements over the color capabilities and resolutions of early devices such as the CGA and the EGA. The CGA (or Color/Graphics Adapter) was capable of producing a maximum of 4 colors with a resolution of 320 by 200 pixels. The EGA (or Enhanced Graphics Adapter) was capable of producing a maximum of 16 simultaneous colors (from an array of 64 total available colors) with a resolution of 640 by 350 pixels. The more recent VGA adapter is capable of producing 16 simultaneous colors (from an array of 262,144 colors) with a resolution of 640 by 480 pixels. The 8514 and super-VGA displays offer resolutions and color capabilities beyond that of the standard VGA. Some super-VGA displays are capable of displaying over 16 million colors at a resolution of 1024 by 768 pixels. The improvements in color capabilities and resolution have finally made it possible to display realistic bitmapped images in the client area of your application's window. For example, to realistically display a scanned color image of a sailboat on the ocean, a display may need to provide seven different shades of blue, four different shades of green, and several different shades of gray to correctly reproduce the color of the water. Using the CGA display, this would have been impossible. Using the EGA display, this would have been accomplished by dithering (that is, by mixing some of the 64 available colors to produce the required shades of blue, green, and gray). The results of dithering would approximate the original colors; however, the end result would not be realistic. Using the super-VGA display the picture could be drawn using pure colors that matched the original image.

Most of the 8514 and super-VGA display adapters impose a limit on the number of colors that can appear simultaneously on the screen. This limit is a function of the resolution of the display and the amount of memory on the adapter card. For example, an adapter with 512K of video memory could display as many as 256 simultaneous colors on a display with a resolution of 640 by 480 pixels. (An array of 256 colors would require an 8-bit index to identify each element or color. A resolution of 640 by 480 pixels requires a 307,200 element array of pixels. The total number of bytes required to support this color scheme can be determined by multiplying the color-array index size (8-bits) by the total number of pixels (307,200). The result, 2,457,600, is the number of bits required to store the color data for the entire display. Since the video adapter in this example provides 512K (or 4,096,000 bits) of memory, we are assured that there is adequate memory to support 256 simultaneous colors.)

If the display resolution in the previous example were increased to 1024 by 768, the memory limitations of the adapter card would prevent the simultaneous display of 256 colors—instead, only 16 different colors could appear simultaneously. This problem is fairly common on a number of displays—only a subset of the total number of colors can appear simultaneously The array which identifies this subset is called the system palette. You can determine whether or not a device supports a system palette by calling the GetDeviceCaps function and specifying the RASTERCAPS constant. And, if it does, you can retrieve the system-palette size by calling the GetDeviceCaps function and specifying the NUMCOLORS constant as the second argument.