如何保存调整大小的BitmapImage?我无法在Windows Phone 8.1中找到这样做的方法。这是我的代码:
BitmapImage bitm = new BitmapImage();
await bitm.SetSourceAsync(stream);
bitm.DecodePixelWidth = 200;
bitm.DecodePixelHeight = 250;
myImage.ImageSource= bitm;
(现在我想存储在一个文件中,因为保存的图像太大了)
答案 0 :(得分:0)
您可以使用WriteableBitmap保存图像。
private async void SaveImage(object sender, RoutedEventArgs e)
{
BitmapImage bitm = new BitmapImage();
await bitm.SetSourceAsync(stream);
bitm.DecodePixelWidth = 200;
bitm.DecodePixelHeight = 250;
WriteableBitmap wb = new WriteableBitmap(bitm);
wb.Invalidate();
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream imageStream = new IsolatedStorageFileStream("/Shared/ShellContent/hello.jpg", System.IO.FileMode.Create, isf))
{
wb.SaveJpeg(imageStream, wb.PixelWidth, wb.PixelHeight, 0, 100);
}
}
}