Rounding errors between GDI+ & GDI ...
- From: Jean-Edouard Lachand-Robert <jlachand@xxxxxxxxxxxxxxxxx>
- Date: Wed, 16 Jul 2008 16:14:24 +0200
Hello,
Please consider the following code :
void Test (HDC hDC)
{
// Set graphics mode to 72 dpi ...
SetMapMode(hDC, MM_ISOTROPIC);
SetWindowExtEx(hDC, 72, 72, NULL);
SetViewportExtEx(hDC, GetDeviceCaps(hDC, LOGPIXELSX), GetDeviceCaps(hDC, LOGPIXELSY), NULL);
SetGraphicsMode(hDC, GM_ADVANCED);
// Draw a 2x2 inch rectangle using GDI
HBRUSH hbOld = (HBRUSH)SelectObject(hDC, (HBRUSH)GetStockObject(NULL_BRUSH));
Rectangle(hDC, 100, 100, 100 + 144, 100 + 144);
SelectObject(hDC, hbOld);
// Draw over a 2x2 inch rectangle using GDI+
Graphics g(hDC);
SolidBrush br(Color(200, 255, 128, 0));
g.FillRectangle(&br, 100, 100, 144, 144);
}
It demonstrates that if you draw a GDI+ primitive over a GDI one, they do not perfectly overlap when the GDI mapping mode is not trivial. I guess that the Graphics objet performs some additionnal transformations to mimic the GDI mapping mode. Problem is: the result is not the same as drawing through the GDI internal matrix.
Any clue how to bypass this problem (without giving up the GDI transformations of course)?
Thanks,
Jean-Ed.
.
- Follow-Ups:
- Re: Rounding errors between GDI+ & GDI ...
- From: Joseph M . Newcomer
- Re: Rounding errors between GDI+ & GDI ...
- Prev by Date: RE: ReadPrint Failure. How to use it properly
- Next by Date: Re: Drag-and-drop from an HMENU
- Previous by thread: StrokeAndFillPath vs. StrokePath and FillPath called seperately
- Next by thread: Re: Rounding errors between GDI+ & GDI ...
- Index(es):
Relevant Pages
|
Loading