Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Wed, 16 Jul 2008 16:14:24 +0200,    group: microsoft.public.win32.programmer.gdi        back       


Rounding errors between GDI+ & GDI ...   
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.
date: Wed, 16 Jul 2008 16:14:24 +0200   author:   Jean-Edouard Lachand-Robert

Re: Rounding errors between GDI+ & GDI ...   
I have also discovered that DPtoLP returns different values depending on the mapping
modes, so there are several serious problems of which you seem to have identified another.

GDI+ uses GM_ADVANCED mode, and that's where the errors occur.

See my essay on errors in Windows documentation at 

http://www.flounder.com/msdn_documentation_errors_and_omissions.htm#DPtoLP

				joe

On Wed, 16 Jul 2008 16:14:24 +0200, Jean-Edouard Lachand-Robert
 wrote:

>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.
date: Thu, 31 Jul 2008 04:43:44 -0400   author:   Joseph M. Newcomer

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us