Solved

Question on GDI vs GDI+

Posted on 2012-04-12
7
441 Views
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).
0
Comment
Question by:knowlton
  • 4
  • 3
7 Comments
 
LVL 85

Accepted Solution

by:
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:

    g.Clear(Color.White);
0
 
LVL 5

Author Comment

by: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.
0
 
LVL 85

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?
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 5

Author Comment

by:knowlton
ID: 37840377
No idea either.
0
 
LVL 5

Author Comment

by:knowlton
ID: 37840385
What do you know about SharpDX, Idle?
0
 
LVL 85

Expert Comment

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

Author Comment

by: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.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

829 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