如何在透明背景,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();
答案 0 :(得分:0)
您似乎将图像编码/解码为JPEG,但不处理透明度。
尝试按原样保存(位图)或PNG。