Eilleen

One of our requirements is to display 200*200 rectangles in one panel and update all of them around every 20/30 seconds in real time. Each rectangle has a different color. The performance requirement for display is around 1-2 seconds.

I'm currently using DrawingContext in my WPF control and calling DrawRectangle API in a loop. Later I displayed it as an image on canvas. Something like this:

SolidColorBrush sb = new SolidColorBrush(color[0]);

using (DrawingContext drawingContext = dGroup.Open())
{
for (int ii = 0; ii < 200; ii++)
{
double x = width * ii / 200;

for (int jj = 0; jj < 200; jj++)
{
double y = height * jj / 200;
sb.Color = color[[ii * 200+ jj];
drawingContext.DrawRectangle(sb, null, new Rect(x, y, recWidth, recHeight));
}
}
}

Image theImage = new Image();
DrawingImage dImageSource = new DrawingImage(dGroup);
theImage.Source = dImageSource;

this.m_canvas.Children.Add(theImage);

The problem is the render performance seems slow, the CPU keeps 100% usage for nearly 10 seconds to complete the rendering. I heard WPF has hardware acceleration but only available under some circumstance. I'm using a laptop with Nvidia Quadro FX Go1000 graphic card of 128M memory. The Direct X version is 9.0. So in my case of using Canvas and rectangles in a 2D scenario, can better hardware speed my app up, or is there any other optimization I can do from my app side