我有一个问题。我正在尝试从资源中加载png图像到我的viewModel的BitmapImage属性中,代码如下:
Bitmap bmp = Resource1.ResourceManager.GetObject(String.Format("_{0}",i)) as Bitmap;
MemoryStream ms = new MemoryStream();
bmp.Save(ms, ImageFormat.Bmp);
BitmapImage bImg = new BitmapImage();
bImg.BeginInit();
bImg.StreamSource = new MemoryStream(ms.ToArray());
bImg.EndInit();
this.Image = bImg;
但是当我这样做时,图片的透明度会丢失。所以问题是如何从资源中加载png图像而不丢失透明度呢?谢谢,Pavel。