Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

GDI+ perfomance

1 view
Skip to first unread message

Alexander Abramov

unread,
May 30, 2002, 11:05:41 AM5/30/02
to
I wrote a simple Win32 program drawing lines under VC6 to compare the
performance of GDI+
with GDI. And the test shows that GDI code paints the lines much faster.
What's the
reason that GDI+ code works so slow at least in this sample?

Regards, Alexander.

(full src: http://www.rsu.ru/~aabramov/Misc/GDIPlusTest.zip)

#define GDIPLUS // comment this line to test GDI instead GDI+

#ifdef GDIPLUS
using namespace Gdiplus;
#endif

void OnPaint(HDC hdc, const RECT& rc)
{
#ifdef GDIPLUS
Graphics g(hdc);
Color color(0,0,255);
Pen pen(color);
#else
HPEN hpen=::CreatePen(PS_SOLID,1,RGB(0,0,255));
HPEN hpenOld=(HPEN)::SelectObject(hdc,hpen);
#endif

for(int i=rc.left;i<rc.right;i+=7)
for(int j=rc.top;j<rc.bottom;j+=7)
{
#ifdef GDIPLUS
g.DrawLine(&pen,rc.left,rc.top,i,j);
#else
::MoveToEx(hdc,rc.left,rc.top,0);
::LineTo(hdc,i,j);
#endif
}

#ifndef GDIPLUS
::SelectObject(hdc,hpenOld);
::DeleteObject(hpen);
#endif
}


John Hornick [MS]

unread,
May 30, 2002, 5:18:56 PM5/30/02
to
Hi,

GDI+ is not GDI. GDI+ v1 has more features and less hardware acceleration.
This can result in a perception of "slower" execution. Actually, your
test compares apples with oranges - GDI+ code could be doing antialiasing,
can handle non-integer coordinates, and doesn't have it's own DDI.

If you need hardware acceleration and speed, and don't need the new
features in GDI+, then continue to use GDI.

Thanks,
- John
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
Visit http://www.microsoft.com/security for current information on security.

0 new messages