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

前端 未结 1 901
灰色年华
灰色年华 2021-01-17 00:19

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

相关标签:
1条回答
  • 2021-01-17 00:52

    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.

    0 讨论(0)
提交回复
热议问题