WPF图像与XAML [英] WPF Images vs. XAML

查看:125
本文介绍了WPF图像与XAML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们何时应该使用图片(jpg,png)以及我们何时应该在应用程序中使用XAML。

When should we use images (jpg, png) and when should we use XAML in an application.

图片

+ "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

我找不到任何比较资源使用情况的来源(图像与XAML之间的CPU,RAM。

I could not find any source, that compares the resource usage (CPU, RAM) between images and XAML.

我个人认为一切都应该是XAML,但我不想让应用程序运行缓慢。是否有使用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?

研究这个我读过你应该拥有XAML中的所有内容然后使用 RenderTargetBitmap 创建静态按需提供图像,但根据这个文章它将导致窗口在没有硬件加速的情况下呈现。所以我想知道它是否真的是对性能的改进。忽略这样一个事实,即编码员的工作要多得多。

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.

推荐答案

从你的评论中: -

From your comment:-


我只谈论图像和xaml可以互换的情况

I am only talking about the cases where image and xaml is interchangeable

使用PNG,句号。只有在您真正需要它提供的优势时才使用基于Xaml的图像。可能存在一些边缘情况例外,例如,可以由Xaml中的几个简单路径组成的大图像。但是,您还必须有充分的理由相信任何性能差异都是可观的并且值得消除。当两者都可以实现相同的结果时,最终会支持简单而不是复杂。

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.

这篇关于WPF图像与XAML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆