SAMPLE: How GETSCALINGFACTOR Affects a Clipping Region

Last reviewed: February 15, 1996
Article ID: Q63939
The information in this article applies to:
  • Microsoft Windows Device Driver Kit (DDK) for Windows versions 3.0 and 3.1

SUMMARY

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.

MORE INFORMATION

The GETSCALINGFACTOR printer escape is documented in Chapter 5 of the Microsoft Windows Software Development Kit (SDK) "Programmer's Reference, Volume 3: Messages, Structures, and Macros" manual for version 3.1, and in Chapter 11 of the Microsoft Windows Device Driver Kit (DDK) "Device Driver Adaptation Guide."

HPCLIP is a file in the Microsoft Software Library that demonstrates using a scaling factor to set a clipping region on a printer device that supports a lower graphics resolution than text resolution.

Download HPCLIP.EXE, a self-extracting file, from the Microsoft Software Library (MSL) on the following services:

  • Microsoft Download Service (MSDL)

          Dial (206) 936-6735 to connect to MSDL
          Download HPCLIP.EXE (size: 18915 bytes) 
    
  • Internet (anonymous FTP)

          ftp ftp.microsoft.com
          Change to the \softlib\mslfiles directory
          Get HPCLIP.EXE (size: 18915 bytes) 
    


Additional reference words: 3.00 3.10 DDKPRINT softlib HPCLIP.EXE
KBCategory: kbprg kbfile
KBSubcategory: GdiPrnMisc


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 15, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.