Custom Control GDI+ Question

  • Thread starter Thread starter Phill
  • Start date Start date
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?
 
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
 
Back
Top