Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Image vs Rectangle & ImageBrush
4 replies. Latest Post by MarkMonster on July 23, 2009.
(0)
Grofit
Member
229 points
310 Posts
07-22-2009 5:52 PM |
Hey,
Just wondering if anyone knows off top of their head which is faster for bulk drawing... lets say you have 1000 on screen, would it be faster to have 1000 images, or 1000 rectangles with image brushes set. Im sure in Flash their image objects were fairly slow... not like the inside of SL is anything like flash...
ksleung
Contributor
5366 points
1,028 Posts
07-22-2009 6:02 PM |
Don't have any solid data but I'd imagine they are the same or about the same?
A rectangle with Image brush is for all practical purpose the same as an image in the following sense: (1) they are both UI elements, (2) from an image you read the pixels off its image source, and from a rectangle you get the pixel from the image brush which maps coordinates to pixel values... Perhaps imageBrush is slightly slower because there is this coordinate-to-pixel-value translation, and this translation is generic (like it must also work for fill, gradient, etc). But should be about the same?
But this is just my guess.
MarkMonster
5220 points
1,046 Posts
07-23-2009 4:22 AM |
I know the ImageBrush will be faster when you use Path, compared to Image with Clipping.
07-23-2009 4:26 AM |
Good to know, at the moment its just a LOT of stuff on screen alot of images are the same but they all have different translations.
Ive tested it myself with both but i didnt notice any performance difference, so was just wondering if anyone had tested and there was a slight difference with each?
07-23-2009 4:55 AM |
This kind of information about Performance tips can be found in Essential Silverlight 3: http://www.amazon.com/Essential-Silverlight-Microsoft-NET-Development/dp/0321554167