有谁知道如何创建从图像的BitmapImage?这里是code,我正在与:
Does anyone know how to create a BitmapImage from an Image? Here is the code that I'm working with:
MemoryStream memStream = new MemoryStream(bytes);
Image img = Image.FromStream(memStream);
现在我有机会获得这一形象在内存中。问题是我需要将其转换为BitmapImage的才能使用它在我的解决方案类型。
Now I have access to this image in memory. The thing is I need to convert this to type BitmapImage in order to use it in my solution.
注意:我需要将其转换为键入的BitmapImage 不输入位图。我一直没能因为类型的BitmapImage接受一个开放的为它的构造函数来弄明白。
NOTE: I need to convert it to type BitmapImage not type Bitmap. I haven't been able to figure it out because type BitmapImage takes in a Uri for it's constructor.
从这个帖子
public BitmapImage ImageFromBuffer(Byte[] bytes)
{
MemoryStream stream = new MemoryStream(bytes);
BitmapImage image = new BitmapImage();
image.BeginInit();
image.StreamSource = stream;
image.EndInit();
return image;
}