0
到目前为止,我有:是否可以将byte []转换为bitmapsource?
using (MemoryStream ms = new MemoryStream(imageData))
{
Bitmap img = (Bitmap)Image.FromStream(ms);
}
然后,我会想象我将能够得到IMG不知何故的BitmapSource?如果这是完全错误的,请随时纠正我。
到目前为止,我有:是否可以将byte []转换为bitmapsource?
using (MemoryStream ms = new MemoryStream(imageData))
{
Bitmap img = (Bitmap)Image.FromStream(ms);
}
然后,我会想象我将能够得到IMG不知何故的BitmapSource?如果这是完全错误的,请随时纠正我。
得到了最简单的方法:
using (MemoryStream ms = new MemoryStream(imageData))
{
BitmapDecoder bitmapDecoder = BitmapDecoder.Create(ms, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad);
BitmapSource photo = new WriteableBitmap(bitmapDecoder.Frames.Single());
}
没有测试过,但还没有我的代码从被采取:HTTP:本Here
尝试使用BitmapSource.Create()。但是,你需要首先创建的调色板:
var colors = new List<Color>();
colors.Add(Colors.Red);
colors.Add(Colors.Blue);
colors.Add(Colors.Green);
var palette = new BitmapPalette(colors);
也许是: //stackoverflow.com/questions/2284353/ – Bridge 2014-09-02 15:15:49