Reputation: 13242
When should we use images (jpg, png) and when should we use XAML in an application.
Image
+ "easy" for the designer to create what he wants
+ are displayed the same on every computer
- fixed resolution
XAML
+ vector format (resolution independent, resize able, ...)
+ can be animated
+/- rendered by the client
- not as many effects available as for images or are really complex to create
- complex visual tree
I could not find any source, that compares the resource usage (CPU, RAM) between images and XAML.
I personally think everything should be XAML, but I don't want to have an application that is slow as hell. Are there any good performance guidelines for using XAML drawings?
Researching this I've read that you should have everything in XAML and then use RenderTargetBitmap to create static images on demand, but according to this article it will cause the window to be rendered without hardware acceleration. So I'm wondering if it is really an improvement for performance. Ignoring the fact that it is much more work for the coder.
Upvotes: 5
Views: 1198
Reputation: 12849
If your artist/designer can create vector graphics and there are no complex gradients, then I would prefer vector graphics. You get all advantages and no disadvantages.
And if you are concerned about complex visual trees, then WPF offers bitmap caching specifically for these kind of cases.
Upvotes: 0
Reputation: 189487
From your comment:-
I am only talking about the cases where image and xaml is interchangeable
Use a PNG, period. Only use Xaml based imagery when you actually need the advantages it provides. There may be some edge case exceptions, for example, a large image that can be composed from a couple of simple paths in Xaml. However you would also have to have a good reason to believe that any performance difference is appreciable and worth eliminating. Ultimately favor simplicity over complexity when the same results are achievable from both.
Upvotes: 5