The Size of the Device

The most important information that your Windows program can obtain about the video device from GetDeviceCaps is the size of the display (in both millimeters and pixels) and the display's pixel aspect ratio. These dimensions can help in scaling images to be displayed. To give you some idea of what these numbers look like, the table below presents information from GetDeviceCaps for four common IBM video adapters: the Color/Graphics Adapter (CGA), Enhanced Graphics Adapter (EGA), the Video Graphics Array (VGA), and the 8514/A:

GetDeviceCaps Index CGA EGA VGA 8514/A

HORZSIZE (width in mm) 240 240 208 280
VERTSIZE (height in mm) 180 175 156 210
HORZRES (pixel width) 640 640 640 1024
VERTRES (pixel height) 200 350 480 760
ASPECTX (horizontal) 5 38 36 10
ASPECTY (vertical) 12 48 36 14
ASPECTXY (diagonal) 13 61 51 14
LOGPIXELSX (x pixels/inch) 96 96 96 120
LOGPIXELSY (y pixels/inch) 48 72 96 120

The HORZSIZE and VERTSIZE values are the width and height of the display area in millimeters. Of course, the Windows driver doesn't really know the size of the display you have attached to your video adapter. These dimensions are based on standard display sizes for the adapters.

The HORZRES and VERTRES values are the width and height of the display area in pixels. For a device context for a video display, these are the same values as those returned from GetSystemMetrics.

The ASPECTX, ASPECTY, and ASPECTXY values are the relative width, height, and diagonal size of each pixel. ASPECTXY equals the square root of the sum of ASPECTX squared and ASPECTY squared.

The LOGPIXELSX and LOGPIXELSY values are the number of pixels per a horizontal and a vertical ”logical inch.“ A logical inch is not a real inch (25.4 mm), as you can easily determine by performing a few calculations using the HORZSIZE, VERTSIZE, HORZRES, and VERTRES values. These LOGPIXELSX and LOGPIXELSY values require a little explanation. You may have noticed that the WRITE program and some other Windows programs display a ruler that isn't quite right: If you measure the ruler as displayed on an VGA, you'll find that what it declares as 1 inch is really more like 1-1/2 inches. These programs are using the LOGPIXELSX and LOGPIXELSY values for the ruler. If WRITE used actual physical dimensions, normal 10-point or 12-point text would be so small as to be nearly illegible. These logical dimensions in effect blow up the display to allow an adequate size for displaying text. When we start working with text and fonts in Chapter 14, we'll wrestle again with this problem. It affects only video displays; for printers, all the dimensions returned from GetDeviceCaps are consistent.