4.1.5 Dimensions and Mapping Modes

A printer driver provides values in its GDIINFO structure specifying the aspect ratio, logical pixels-per-inch, and mapping modes for the printer. The following sections detail these modes.

4.1.5.1 Aspect Ratio

The aspect ratio defines the relative dimensions of the printer's pixels. The ratio consists of three values: an x-, y-, and xy-aspect. These represent the relative width, height, and diagonal length (or hypotenuse) of a pixel. GDI uses the aspect ratio to determine how to draw squares and circles as well as drawing lines at an angle.

The aspect values have the following relationship:

(dpAspectXY * dpAspectXY) == (dpAspectX * dpAspectX) +

(dpAspectY * dpAspectY)

Because the dimensions are given as relative values, they may be scaled as needed to obtain accurate integer values. Keep the values under 1000 for numerical stability in GDI calculations. For example, a device with a 1:1 aspect ratio (such as a 300 dpi laser printer) can use 100 for the dpAspectX member and the dpAspectY member and 141 (100 * 1.41421 . . . ) for dpAspectXY.

4.1.5.2 Logical Pixels-Per-Inch

Printer drivers should always use real inches. A 300 dpi laser printer puts 300 in both members.

4.1.5.3 Mapping Modes

The printer driver provides viewport and window extents for the standard mapping modes: MM_LOENGLISH, MM_HIENGLISH, MM_LOMETRIC, MM_HIMETRIC, and MM_TWIPS.

Place the device resolution in pixels-per-inch in the viewport extents and the number of logical units-per-inch in the window extent. The y-coordinate of the viewport is negated to reflect the fact that the x-axis is along the top of the paper in the default mapping mode (MM_TEXT, which specifies device coordinates) with y increasing while going down the page; whereas in the other mapping modes, the x-axis is along the bottom edge of the page.

For example, on a 300 dpi laser printer, the MM_TWIPS mapping mode will require that the dpTwpWin member be set to (1440,1440) and the dpTwpVpt member be set to (300, -300).