Groups | Blog | Home
all groups > dotnet drawing api > march 2005 >

dotnet drawing api : DrawImageUnscaled() or FillRectagle() + DrawRectangle() - Which is faster?


Phil Price
3/26/2005 10:38:52 AM
Hi,

I'm currently developing a set of custom controls for a client.
Everything is themeable, yadda yadda. I have my own
"PictureLargePreview" control which accepts a bunch of Pictures (a
threaded extension on top of munch of bitmaps for preview etc). And will
display them in a list. With a preview and information about the picture
(DPI, size etc).

Anyway to the point, each list item has a background which consists of a
FillRectangle() with a LinearGradientBrush, then two Outlines done via 2
x DrawRectangle(). I decided to cache the background of a listitem into
a bitmap, and only recreate the bitmap when the control is resized. Is
this worth it, which method is faster - Direct drawing or on screen
caching then drawing with DrawImageUnscaled()?

Thanks for your time

Alejandro Lapeyre
3/26/2005 1:04:18 PM
Let me add a 3rd method:
Cache the instructions needed to draw the background using a metafile.
Using this method all the .net wrapping functions will only be used once.
When you draw the metafile it will use the native instructions.

bitmap
faster
requires memory

metafile
small memory
faster than normal

normal
slower
no memory

Best Regards,
Alejandro Lapeyre

"Phil Price" <phil@philprice.net> escribió en el mensaje
news:FlCdnUXXrJwqptjfSa8jmw@karoo.co.uk...
[quoted text, click to view]

AddThis Social Bookmark Button