Bad performance of .NET drawing

  • Thread starter Thread starter Boni
  • Start date Start date
B

Boni

Dear all,
I have about 500 rectangles on the picturebox, and if I take one with the
move and move I MUST clear the whole picture and redraw, which takes about
1-2 second. The rectangles are drawen with FillRectangle(.). Is there a
better way to have the whole rendering much faster. (I have no problem with
flickers, because of rendering into memory).
Thanks in advance,
 
Try turning off the various anti-aliasing and alpha-blending options
on the Graphics object you're drawing to. If that doesn't help you'll
have to manually draw pixels to a locked bitmap. That would require
pointer arithmetic and C# "unsafe" mode. If that still doesn't help
you'll have to use interop calls to C/C++, or wait for Avalon.
 
Christoph Nahr said:
Try turning off the various anti-aliasing and alpha-blending options
on the Graphics object you're drawing to. If that doesn't help you'll

Hi there

How do you turn of anti-aliasing and alpha blending on a graph object ?
 
How do you turn of anti-aliasing and alpha blending on a graph object ?

There are a bunch of System.Drawing.Graphics properties with somewhat
obscure names for this purpose:

CompositingMode -> SourceCopy turns off alpha blending
CompositingQuality -> HighSpeed turns off compositing
PixelOffsetMode -> None turns off one anti-aliasing method
SmoothingMode -> None turns off another anti-aliasing method

There's also TextRenderingHint for text drawing but you probably don't
want to change that.
 
There are a bunch of System.Drawing.Graphics properties with somewhat
obscure names for this purpose:

CompositingMode -> SourceCopy turns off alpha blending
CompositingQuality -> HighSpeed turns off compositing
PixelOffsetMode -> None turns off one anti-aliasing method
SmoothingMode -> None turns off another anti-aliasing method

There's also TextRenderingHint for text drawing but you probably don't
want to change that.

Thanks for the tips, i'll to add it to see if my drawing will get speeded up
as well.
 
Sorry, made a stupid mistake here. Alpha blending and compositing is
the same thing. When you switch CompositingMode to SourceCopy it's
turned off altogether, so the CompositingQuality value is ignored.
 
Christoph Nahr said:
Sorry, made a stupid mistake here. Alpha blending and compositing is
the same thing. When you switch CompositingMode to SourceCopy it's
turned off altogether, so the CompositingQuality value is ignored.

Hehe, no problem.

Just shows you are human :)
 
Back
Top