[英]Pass “transparent” image between pages
如何在具有透明背景,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();
您似乎將圖像編碼/解碼為JPEG,無法處理透明度。
嘗試按原樣(位圖)或PNG保存它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.