Question on GDI vs GDI+

Posted on 2012-04-12
Last Modified: 2012-06-27
Graphics g = Graphics.FromImage(bm)



 g.FillRectangle(solidWhiteBrush, 0, 0, bm.Width, bm.Height);

 g.DrawString(AnnotationText, AnnotationFont, solidBlackBrush, new PointF(7f, 2f));

Here are my questions:

1)This is GDI+, correct?
(Running this on Windows 7)

2)What is the difference between GDI and GDI+?  Is the version of GDI tied to a particular OS?

3)Can the above code be optimized to run faster?

The intent of the code is to annotate an image with some text (a date stamp).
Question by:Tom Knowlton
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 86

Accepted Solution

Mike Tomlinson earned 500 total points
ID: 37840349
In a nutshell:
WinForms is based on GDI+, while WPF is based on DirectX.
GDI was used before XP, while GDI+ is used in XP and above.
*Vista and Win 7 actually use a completely different drawing system (The Desktop Window Manager) that buffers GDI+ into a composite image with DirectX to render the operating system.

So yes, and no.  Yes, you are using GDI+ to add text to your image.  But when it gets displayed on the screen it's actually using DirectX because you are running Win 7.

Don't think you can make the code much faster.

Instead of FillRectangle(), you can do this to paint your bitmap a solid color:


Author Comment

by:Tom Knowlton
ID: 37840362
Is it possible to use or hook into WPF if I am running from inside a console app in C#?

Essentially, I have a console app (NO GUI) just running and it is annotating images using (at the moment) calls to GDI+.

I want to do the same thing in the console app, except I want to access either WPF or SharpDX libraries.  Again -- there is no GUI -- this is all done sight unseen.
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 37840375
I'm not sure how you'd do it with WPF, but you can probably just add a REFERENCE to the Console app?
Stressed Out?

Watch some penguins on the livecam!


Author Comment

by:Tom Knowlton
ID: 37840377
No idea either.

Author Comment

by:Tom Knowlton
ID: 37840385
What do you know about SharpDX, Idle?
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 37840386
Absolutely nothing, other than it wraps a bunch of DirectX stuff for you.  =\

Author Comment

by:Tom Knowlton
ID: 37840393
That is about what I know, too.  :(

One way or another I am sure I'll figure this out.

I have a few other questions on this topic right now.  If you know any EE gurus on SharpDX please send them my way, okay?  Any C# / XNA / game developer types you are acquainted with might know about SharpDX.

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question