【发布时间】:2011-12-18 15:54:02
【问题描述】:
我有一个 WPF 应用程序,我在其中上传 AutoCAD 绘图文件 (.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 数据。