如何保存调整大小的BitmapImage?我在Windows Phone 8.1中找不到这样做的方法这是我的代码:
BitmapImage bitm = new BitmapImage(); await bitm.SetSourceAsync(stream); bitm.DecodePixelWidth = 200; bitm.DecodePixelHeight = 250; myImage.ImageSource= bitm;
(现在我想存储在一个文件中,因为保存的图像太大了)
您可以使用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); } } }
1 回答
您可以使用WriteableBitmap来保存图像 .