Solved

Question on GDI vs GDI+

Posted on 2012-04-12
7
417 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
Comment Utility
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
Comment Utility
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
Comment Utility
I'm not sure how you'd do it with WPF, but you can probably just add a REFERENCE to the Console app?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 5

Author Comment

by:knowlton
Comment Utility
No idea either.
0
 
LVL 5

Author Comment

by:knowlton
Comment Utility
What do you know about SharpDX, Idle?
0
 
LVL 85

Expert Comment

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

Author Comment

by:knowlton
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now