2
如何從字節數組創建System.Windows.Media.ImageSource?如何從字節數組創建System.Windows.Media.ImageSource?
我有一個字節數組,包含TIFF圖像文件的確切和完整的文件內容。我需要在屏幕上顯示它,我不知道哪裏可以開始。
據說可以這樣做(根據我的老闆,我們的開發團隊過去做過,但沒人會記得)。
有沒有人曾經做過這樣的事情?
如何從字節數組創建System.Windows.Media.ImageSource?如何從字節數組創建System.Windows.Media.ImageSource?
我有一個字節數組,包含TIFF圖像文件的確切和完整的文件內容。我需要在屏幕上顯示它,我不知道哪裏可以開始。
據說可以這樣做(根據我的老闆,我們的開發團隊過去做過,但沒人會記得)。
有沒有人曾經做過這樣的事情?
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.StreamSource = new MemoryStream(ByteArray);
bi.EndInit();
另見Load a WPF BitmapImage from a System.Drawing.Bitmap和Using Image control in WPF to display System.Drawing.Bitmap
確實ImageSource的有一個構造函數流? – MusiGenesis 2009-07-24 20:39:11
ImageSource是抽象的。我不確定它是否有任何的derrived類... BitmapImage類的構造函數需要一個URI。 – Giffyguy 2009-07-24 20:42:14