简体   繁体   English

如何在不损失质量的情况下从StorageFile设置Image.Source?

[英]How can I set an Image.Source from a StorageFile without losing quality?

Here is a way that I found and it works, but if my image becomes bigger than the values here it loses quality. 是我发现并起作用的一种方法,但是如果我的图像变得大于此处的值,则会失去质量。 My image also doesn't have a fixed size, so I would prefer to get it with the original quality. 我的图像也没有固定尺寸,因此我希望以原始质量获得它。

using (IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
{
    BitmapImage bitmapImage = new BitmapImage();
    await bitmapImage.SetSourceAsync(fileStream);
    myImage.Source = bitmapImage;
}

Leaving out height and width will get me the full image! 不考虑高度和宽度,我将获得完整的图像!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM