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