在UWP 将BitmapImage转换为 WriteableBitmap
2021-05-07 12:27
标签:lte dom wan window hub ica type lan async 原文: How to convert BitmapImage to WriteableBitmap in Universal application for windows 10? 在UWP 将BitmapImage转换为 WriteableBitmap 标签:lte dom wan window hub ica type lan async 原文地址:http://www.cnblogs.com/lonelyxmas/p/7643923.html您可以直接从文件将图像加载到WriteableBitmap对象。
var filePicker = new FileOpenPicker();
filePicker.FileTypeFilter.Add(".jpg");
var result = await filePicker.PickSingleFileAsync();
if (result != null)
{
using (IRandomAccessStream stream = await result.OpenAsync(FileAccessMode.Read))
{
BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream);
WriteableBitmap bmp = new WriteableBitmap((int)decoder.PixelWidth, (int)decoder.PixelHeight);
bmp.SetSource(stream);
// show the image in the UI if you want.
MyImage.Source = bmp;
}
}
这样你可以使用WriteableBitmap,你可以使用WriteableBitmapEx库。
文章标题:在UWP 将BitmapImage转换为 WriteableBitmap
文章链接:http://soscw.com/index.php/essay/83675.html