DrawImage Performance

My application has poor performance when displaying diagrams comprising of 500+ objects. Most time is spent by my overide of the ‘Paint’ method - specifically in a call to ‘Graphics.DrawImage’. I know this is a GDI+ problem, but does anyone have any hints for how to improve performance? Any special graphics settings, PixelFormat, or whatever?
Its quite a while since I did any graphics work but my impression is that GDI+ is really slow. Any comments?

I have not made such an experience so far. I override Paint for my node and edge classes. Nodes are drawn as shapes and an optional image and edges are drawn as semitransparent filled polygons. And this works fine for 1000+ elements.

If you post your Paint implementation and a guess of the time needed for redraw, we could possibly give some speed up hints.

Yes, GDI+ is “slow”, although I think it’s pretty good for what it’s trying to do. It’s also why Avalon (aka WPF) is coming.
Try setting GoView.InterpolationMode to different values. I think the default is “High quality”.
You might want to set it back just while printing (unless you have overridden GoView.PrintView to do this).

Dear jzifu - Thanks for the re-assurance and offer of hints. When I profile the code virtually all the time is taken up by the DrawImage call - so I don’t think there is much we can do in the Paint method to improve things other than prepare the bitmap so that DrawImage might work faster.
Dear Walter - Thanks for the hint. Using InterpolationMode.Low makes a perceptable difference. But I am curious - what does this property do?

I was guessing that much of the time in your application was being spent stretching or compressing your image to fit the GoImage’s size at the GoView’s scale. GoView.InterpolationMode is just the default value for Graphics.InterpolationMode.
I think you are right at suggesting that it might speed things up if you cached a Bitmap of the Image of the Size given by the GoImage. This is particularly true if you have very large images that are being shown as relatively small objects.
How much of a speed-up did you get by changing GoView.InterpolationMode? Do the lower quality images look good enough?

Images at InterpolationMode.Low look OK to me and well worth the approximate 50% speed improvement - some of our users are probably a bit fussier than me, but I could always make this a user configurable option.
I am mainly testing for large piping system diagrams when zoomed well out - so typically there is a lot of compression. I can certainly try experimenting by caching different versions of the Bitmaps to suit different zoom factors.