Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 通行证;透明的;页面之间的图像_C#_.net_Oop_Windows Phone 7_Windows Phone 8 - Fatal编程技术网

C# 通行证;透明的;页面之间的图像

C# 通行证;透明的;页面之间的图像,c#,.net,oop,windows-phone-7,windows-phone-8,C#,.net,Oop,Windows Phone 7,Windows Phone 8,如何在具有透明背景(png格式)的页面之间传递图像?现在我通过了图片,但背景是黑色的 这是我的密码: 第一页: WriteableBitmap wb = new WriteableBitmap(logoQrCodeImage, null); Byte[] array = ConvertImage.ConvertToBytes(wb); if (!IsolatedStorageSettings.ApplicationSettings.Contains("State")) { Isolate

如何在具有透明背景(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,而JPEG不处理透明度


尝试将其保存为原样(位图)或PNG。

但如何将此图像保存为PNG?有什么线索吗?你需要使用第三方库,比如ImageTools()。好的,我来试试。但我不知道如何在页面之间传递此图像,因为它应该以字节为单位。我可以使用什么方法名称将图像保存为PNG格式?您不应该编辑您的问题,因为您基本上是在问一个新问题。我发现你的新代码有两个问题:你没有在第一页对图像进行编码(你的ConvertToBytes方法是做什么的?),也没有在第二页对图像进行解码。