bubuzzz wrote:
graphics.Dispose();
that is wrong. You should dispose of those objects that offer a Dispose() method if you created them (by calling new, or a method with "Create" in the name). you should not dispose of objects others created, such as the Graphics you borrowed from PaintEventArgs.
bubuzzz wrote:
return (Image)tmpBitmap;
is OK, however IMO you don't need the cast. One bad thing is you are loading and resizing all those images inside OnPaint(); OnPaint() should be fast (most of the time), so you would do better by keeping the small images in memory, maybe in a Dictionary (filename, smallImage), which you could load beforehand, or when necessary, but not every time the system decides it has to (re)paint. Warning: Dictionaries tend to grow all the time, depending on the nature of your app, you may want to take care of that. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).