Mixing GDI+ and GDI in .NET application

  • Thread starter Marcin Rzeznicki
  • Start date
M

Marcin Rzeznicki

Hello,
Do you think it is legitimate practice to mix GDI+ and GDI calls (via
Get/ReleaseHDC()) in paint event of a control? I've heard there is
possibility of performance loss while "locking" Graphics object which
is done as a side-effect to GetHDC() call - could you confirm? Another
question that comes to my mind when planning mentioned operation is: if
the control painted on uses double-buffering style, will GDI calls make
use of "back buffer" or will they mess it somehow eg drawing directly
to screen bypassing back buffer (I think it depends on what is returned
via GetHDC() - hndle to back buffer context or just control window
context)? Thank you in advance for your answers.
 
S

sudhaibs

Hello,

We have a Opening for Java located in North Jersey.

JAVA Requirement:

· Very strong in - JAVA fundamentals
· J2EE, EJB (stateless Session beans ect...)
· Server lets, Life cycle of EJB's
· JAVA threads, web logics 8.1
· Unix
· Web Services- very strong
· J unit, importance of quality
· SDLC process
· Version control software
· Should be very good team player
· Strong Communication and Technical Skills
· Work independently

If you are interested and find yourself eligible for this post conatct
me so that we can further proceed.

Thanks and Regards,
Sudha
Phone- 732-981-0450 ext-110
 
B

Bob Powell [MVP]

GDI+ and GDI calls is a great technique for increasing performance as long
as you stick with the right memory, IE screen memory.

Some GDI operations don't work well on double buffered controls because many
of the advantages of GDI come from hardware acceleration that is impossible
on in-memory bitmaps.

When the GDI drivers attempt to work on certain memory they are unable to do
the operation with hardware and revert to software for the task.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
M

Marcin Rzeznicki

Bob Powell [MVP] napisal(a):
GDI+ and GDI calls is a great technique for increasing performance as long
as you stick with the right memory, IE screen memory.

Some GDI operations don't work well on double buffered controls because many
of the advantages of GDI come from hardware acceleration that is impossible
on in-memory bitmaps.

When the GDI drivers attempt to work on certain memory they are unable to do
the operation with hardware and revert to software for the task.

I mainly think about GDI text output operations. Another question is,
is it possible to interchange GDI and GDI+ measurements eg text
bounding rectangle. Text is printed out to screen and measured with
GDI, and the rest of the drawing process using the rectangle measured
in logical units of device is performed in GD+I. I think of two ways -
computing coordinates by myself or changing Grpahics PageUnit property
- which seems to be perfectly suited to the problem. Do you agree?
 
B

Bob Powell [MVP]

Unfortunately, the GDI+ renderer and that of GDI are completely different.
There is little correlation between the text measurements of the two
systems.

From experiance I can say that if you try to measure with one and output
with the other you're moving into a world of pain.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
M

Marcin Rzeznicki

Bob Powell [MVP] napisal(a):
Unfortunately, the GDI+ renderer and that of GDI are completely different.
There is little correlation between the text measurements of the two
systems.

From experiance I can say that if you try to measure with one and output
with the other you're moving into a world of pain.

Actually, I would like to measure and output within single API but
"use" measurements across APIs' boundaries. For example: text would be
rendered and its bounding rectangle would be computed in GDI, the
rectangle would be passed to GDI+ and there used, for example, text
would be underscored. I suppose that setting GDI mapping mode to
MM_TEXT would resolve problem of different coordinate systems.
 
B

Bob Powell [MVP]

The GDI+ rendering pipeline is sane and sensible whereas the GDI system of
viewport and window extents isn't.

Measurements in GDI+ will render nice floating point values and it's
difficult, well almost impossible, to use these in the GDI system.

For a comparison of the two systems see the GDI+ FAQ.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
M

marcin.rzeznicki

Bob Powell [MVP] napisal(a):
The GDI+ rendering pipeline is sane and sensible whereas the GDI system of
viewport and window extents isn't.

Measurements in GDI+ will render nice floating point values and it's
difficult, well almost impossible, to use these in the GDI system.

For a comparison of the two systems see the GDI+ FAQ.

Hello Bob,
I've read it and I must assume that I quite don't catch it. What is
wrong with setting GDI mapping mode to MM_TEXT, which gives us logical
coordinates expressed in pixels, and setting viewport origin to (0,0)
which gives us GDI+ like coordinate system. Then assuming GDI
measurments give us rectangle (0,0,10,10) - we are able to use that
rectangle in GDI+ (no need for floats) as well as in GDI, just because
we have set up correct coordinate system (pixel-based and with origin
located at viewport upper left corner)/ Could you explain that?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top