我有一個WPF應用程序,我在其中上傳autocad繪圖文件(.dwg),將其轉換爲字節數組並保存到數據庫。當我讀回的字節數組文件,我收到以下錯誤:如何從字節數組中讀取繪圖圖像(.dwg)
No imaging component suitable to complete this operation was found.
我的代碼以字節數組轉換爲如下:
FileStream fs = new FileStream(dlg.FileName, FileMode.Open, FileAccess.Read);
byte[] data = new byte[fs.Length];
fs.Read(data, 0, System.Convert.ToInt32(fs.Length));
fs.Close();
我試圖使用擺脫字節數組圖像以下代碼:
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.CreateOptions = BitmapCreateOptions.None;
bi.CacheOption = BitmapCacheOption.Default;
bi.StreamSource = new MemoryStream(data);
RenderOptions.SetBitmapScalingMode(bi, BitmapScalingMode.Linear);
bi.EndInit();
上面的代碼適用於其他圖像文件,如jpg,png,bmp,gif。但不適用於dwg文件。任何人都可以指導我的代碼有什麼問題嗎?
感謝
這個問題與它有關很少,或者你沒有把它作爲字節數組讀取,或者它沒有通過數據庫。您正試圖將dwg文件顯示爲圖像。這不是一個圖像。這是CAD數據。 – Tormod