在UWP 将BitmapImage转换为 WriteableBitmap
本站寻求有缘人接手,详细了解请联系站长QQ1493399855
原文: How to convert BitmapImage to WriteableBitmap in Universal application for windows 10?
您可以直接从文件将图像加载到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库。