0
如何在具有透明背景,png格式的頁面之間傳遞圖像?現在我通過了圖像,但背景是黑色的。在頁面之間傳遞「透明」圖像
這裏是我的代碼:
第一頁:
WriteableBitmap wb = new WriteableBitmap(logoQrCodeImage, null);
Byte[] array = ConvertImage.ConvertToBytes(wb);
if (!IsolatedStorageSettings.ApplicationSettings.Contains("State"))
{
IsolatedStorageSettings.ApplicationSettings["State"] = array;
IsolatedStorageSettings.ApplicationSettings.Save();
}
第二頁:
Byte[] array = IsolatedStorageSettings.ApplicationSettings["State"] as Byte[];
MemoryStream stream = new MemoryStream(array);
WriteableBitmap wb = new WriteableBitmap(50, 50);
//wb.LoadJpeg(stream);
var encoder = new PngEncoder();
ExtendedImage myImage;
myImage = wb.ToImage();
encoder.Encode(myImage, stream);
icon.Source = myImage.ToBitmap();
IsolatedStorageSettings.ApplicationSettings.Remove("State");
IsolatedStorageSettings.ApplicationSettings.Save();
但是如何將此圖像另存爲PNG?任何線索? – user2962457
您需要使用第三方庫,例如ImageTools(http://imagetools.codeplex.com/)。 –
好吧,我要試試。但我不知道如何在頁面之間傳遞此圖像,因爲它應該以字節爲單位。 – user2962457