Custom Control GDI+ Question

P

Phill

For the drawing on my control would it be better to allocate all the
pens / brushes needed during painting as member variables instead of
a whole bunch of

using( Pen p = ... )
{

}

type blocks in my paint handler functions.

It seems like it would be faster. And the memory requirements of a
solid color pen/brush must be small. The only downside I can think of
is that somewhere the user of the control would need to call
dispose().

Any advice, thoughts?
 
F

Frank Hileman

If you profile cached brushes versus throwaway brushes, you will probably
find it makes no difference. Most of the drawing time is in the actual
rendering. If you do cache, make sure you override Dispose.

Regards,
Frank Hileman

check out VG.net: www.vgdotnet.com
Animated vector graphics system
Integrated Visual Studio .NET graphics editor
 

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