我尝试过搜索这个但我最终只保存为不包含透明度的jpg。
using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
if (myIsolatedStorage.FileExists("Shared/ShellContent/logo.jpg"))
{
return;
}
IsolatedStorageFileStream fileStream1 = myIsolatedStorage.CreateFile("Shared/ShellContent/logo.jpg");
Uri uri = new Uri("home.png", UriKind.Relative);
StreamResourceInfo sri = null;
sri = Application.GetResourceStream(uri);
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.SetSource(sri.Stream);
WriteableBitmap wb = new WriteableBitmap(bitmapImage);
Extensions.SaveJpeg(wb, fileStream1, wb.PixelWidth, wb.PixelHeight, 0, 95);
fileStream1.Close();
}
如何保存图像,而不编码jpg格式?
答案 0 :(得分:1)
我这样做了 http://toolstack.com/libraries/pngwriter
最终守则
using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
if (myIsolatedStorage.FileExists("Shared/ShellContent/logo.png"))
{
return;
}
IsolatedStorageFileStream fileStream1 = myIsolatedStorage.CreateFile("Shared/ShellContent/logo.png");
Uri uri = new Uri("home.png", UriKind.Relative);
StreamResourceInfo sri = null;
sri = Application.GetResourceStream(uri);
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.SetSource(sri.Stream);
WriteableBitmap wb = new WriteableBitmap(bitmapImage);
wb.WritePNG( fileStream1 as System.IO.Stream);
//wb.SaveJpeg(fileStream, wb.PixelWidth, wb.PixelHeight, 0, 85);
fileStream1.Close();
}