有没有一种简单的方法可以将变量 WriteableBitmap 的内容保存到 IsolatedStorageFile?我正在编写一个程序来处理 WriteableBitmap 中的像素,然后将处理后的位图保存为文件 *.bmp 并将其存储在“保存的图片”目录中。我有将 WriteableBitmap 保存为 jpeg 文件的代码,但正如我之前所说,我不想以任何方式压缩图形。请帮我解决我的问题。
private void Save_as_bmp(object sender, RoutedEventArgs e)
{
String temp = "photo.bmp";
using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
if (myIsolatedStorage.FileExists(temp))
{
myIsolatedStorage.DeleteFile(temp);
}
IsolatedStorageFileStream fileStream = myIsolatedStorage.CreateFile(tempJPEG);
//Writeable wb declared in another method
//JPEG compression
//wb.SaveJpeg(fileStream, wb.PixelWidth, wb.PixelHeight, 0, 100);
// In this place I need to save variable wb to file stream without any compression
// something like - fileStram = wb.content;
fileStream.Close();
}
using (IsolatedStorageFile myIsolatedStorage2 = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream fileStream2 = myIsolatedStorage2.OpenFile("photo.bmp", FileMode.Open, FileAccess.Read))
{
try
{
var mediaLibrary2 = new MediaLibrary();
mediaLibrary2.SavePicture("raster_graphic", fileStream2);
//mediaLibrary2.SavePictureToCameraRoll("raster_graphic", fileStream2);
MessageBox.Show("Image saved");
//fileStream2.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error, exception: " + ex.Message);
}
}
}
}