Microsoft KB Archive/63939

{|
 * width="100%"|

HPClip.exe Uses Scaling Factor to Set Clipping Region

 * }

Q63939

-

The information in this article applies to:


 * Microsoft Windows Device Development Kit (DDK) for Windows, versions 3.0, 3.1

-

SUMMARY
HPClip.exe is a sample that demonstrates how to use a scaling factor to set a clipping region on a printer device that supports a lower graphics resolution than text resolution.

MORE INFORMATION
The following files are available for download from the Microsoft Download Center. Click the file names below to download the files:

"Hpclip.exe" For more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address

"http://www.microsoft.com/downloads/search.asp" and then click How to use the Microsoft Download Center. In the Microsoft Windows graphical environment, printer drivers that can create graphics in finer resolutions than text support the GETSCALINGFACTOR printer escape. For example, the HP LaserJet printer with the HPPCL driver can create graphics at 300, 150, and 75 dots per inch (dpi). Because text on this printer is always printed in 300 dpi, the printer driver responds to this printer escape to inform the caller of the scaling factors from the text resolution to the current graphics resolution, for both the X and Y axes. If the user sets the graphics resolution of an HPPCL printer to 150 dpi through the Control Panel, the driver returns the values (1, 1) for this escape (exponent of 2). If the graphics resolution is 75 dpi, the scaling factors are (2, 2). The same logic holds for 300 dpi; the scaling factors are (0, 0). The X and Y factors are always the same on HPPCL because this printer always has the same resolutions on the X and Y axes. On another printer device, the two factors may differ from each other.

The scaling factors are typically used to set clipping regions on this type of printer device. Because the graphics device interface (GDI) sets a clipping region only at the text resolution, it is the application's responsibility to adjust the region's coordinates before passing them to the call that creates the region. For example, suppose an application creates a rectangular clipping region on an HPPCL printer. The coordinates (X1, Y1) specify the upper-left corner and (X2, Y2) the lower-right corner, all in device units. Before passing these parameters to the CreateRectRgn function, the application must send the GETSCALINGFACTOR printer escape to obtain the current scaling factors. If the current graphics resolution is 150 dpi, the scaling factors should be (1, 1). The application would adjust the coordinates to (X1 >> 1, Y1 >> 1) and (X2 >> 1, Y2 >> 1), which is equivalent to dividing each by 2. After Windows creates the region, calling the SelectClipRgn function selects the region into the device context as the clipping region.