BUG: Outline of a Pie() Slice May Not Be Completely Smooth

Last reviewed: January 5, 1995
Article ID: Q111866
The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) for Windows versions 3.0 and 3.1

SYMPTOMS

The outline of a Pie() slice may not be completely smooth.

CAUSE

Windows calculates the Pie() center using device points. Round-off errors, especially in mapping modes other than MM_TEXT, can put the center of the pie off center, resulting in a slightly "crinkly" pie slice.

RESOLUTION

The bounding rectangle of the Pie() function includes the top left coordinates (X1,Y1) but not the bottom right coordinates (X2,Y2). Adding 1 to X2 and Y2 makes the real extent even, and therefore the radius can be nicely placed. But this method works on the screen only in the default MM_TEXT mode. If you change the mapping of the device context to some high resolution mode, such as MM_HIENGLISH or MM_TWIPS, the center again goes off 1 by pixel and you get slightly crinkly pie slices.

Windows converts all four pairs of coordinates of the Pie() function from logical points to device points, and then it calculates the center of the pie. If you're going from a high resolution mode to a low resolution device, such as the screen or a 75 dpi printer, you'll get rounding errors.

As a workaround, an application can do a DPtoLP() of (1,1) and add that to X2 and Y2. For example, in MM_HIENGLISH, the result of the DPtoLP() of (1,1) is about 13 logical points instead of just 1. Note, however, that this method will not work all the time, because the rounding error will depend on the actual coordinates.

If an application requires smooth pie slices, and must use a mapping mode other than MM_TEXT, the application could proceed as follows (this does defeat the purpose of using a mapping mode):

  1. Call LPtoDP() for all four coordinate pairs.
2. Make sure the coordinate pairs are proper and will allow a true center
   for the pie.
3. Call DPtoLP() on the coordinate pairs. 4. Pass the coordinates to Pie().

STATUS

Microsoft has confirmed this to be a bug in Windows versions 3.0 and 3.1. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.


Additional reference words: buglist3.00 buglist3.10 3.00 3.10
KBCategory: kbprg kbbuglist
KBSubcategory: GdiDrw


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: January 5, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.