Resize image in xaml without losing quality

前端 未结 3 783
故里飘歌
故里飘歌 2020-12-23 13:44

I have this image (original size: 256x256)

\"enter

I made this xaml definition

3条回答
  •  [愿得一人]
    2020-12-23 14:08

    Set RenderOptions.BitmapScalingMode property for your Image through .xaml:

    
    

    Additional info:

    The RenderOptions.BitmapScalingMode is a property that scales the images based on the quality. WPF 4.0 defaults it to Unspecified, which refers to LowQuality image rendering.

    But to ensure that the image remains good quality when the size increases, BitmapScalingMode should be chosen as HighQuality.

    Here is BitmapScalingMode Enumeration members with their description from msdn:

    1.Fant - Use very high quality Fant bitmap scaling, which is slower than all other bitmap scaling modes, but produces higher quality output.

    2.HighQuality - Use high quality bitmap scaling, which is slower than LowQuality mode, but produces higher quality output. The HighQuality mode is the same as the Fant mode.

    3.Linear - Use linear bitmap scaling, which is faster than HighQuality mode, but produces lower quality output.

    4.LowQuality - Use bilinear bitmap scaling, which is faster than HighQuality mode, but produces lower quality output. The LowQuality mode is the same as the Linear mode.

    5.NearestNeighbor - Use nearest-neighbor bitmap scaling, which provides performance benefits over LowQuality mode when the software rasterizer is used. This mode is often used to magnify a bitmap.

    6.Unspecified - Use the default bitmap scaling mode, which is Linear.

提交回复
热议问题