How to create multi scaled image assets for a WP 8.1 Store app

一笑奈何 提交于 2019-12-01 12:08:40

问题


How to create specific image assets for different scale factors? For example, I have a button which uses an image. So, how to create that image for Scale 100, Scale 140 and Scale 240?


回答1:


You create original image for 96dpi device, let's say 40x40, then you should provide 56x56 (140%), 72x72 (180%) and so on. If you don't provide the image, the image will be resized and loose its quality.

You can provide images for every scale and place them in the same folder, like this:

Images/name.scale-100.png
Images/name.scale-140.png
Images/name.scale-180.png
Images/name.scale-240.png

Then you can refer to the image in XAML like this:

<Image Source="Images/name.png"/>

and in the code by its URI:

Uri imageUri = new Uri("ms-appx:///Images/name.png");

The OS should take the image with the apropriate scale. More about this you will find at MSDN.

Note also that you can set this way also images for high-contrast and/or different languages.



来源:https://stackoverflow.com/questions/27055226/how-to-create-multi-scaled-image-assets-for-a-wp-8-1-store-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!