回复 5楼gaobowen的帖子
您好, 今早收到回复。原文如下:
I checked your code and I was able to see the same behavior when calling the RasterImageConverter.ChangeToImage method.
You can resolve this issue using one of the following approaches:
(1) Call the RasterImageConverter.ConvertToImage() method instead of RasterImageConverter.ChangeToImage() method. The difference between these two methods that the ConvertToImage() method creates a GDI+ System.Drawing.Image object that don't share the same image data with the Leadtools.RasterImage object.
The ChangeToImage() method creates a GDI+ System.Drawing.Image object that shares the same data with the Leadtools.RasterImage object, which might causing unexpected errors if the Leadtools.RasterImage object is not GDI+ compatible. The code will be something as follows:
+--------------------------------------------+
this.pictureBox1.Image = RasterImageConverter.ConvertToImage(rasterImageViewer1.Image,ConvertToImageOptions.None);
+--------------------------------------------+
(2) Make sure that the Leadtools.RasterImage object is GDI+ compatible before calling the ChangeToImage() method. You can do this as follows:
+--------------------------------------------+
if (RasterImageConverter.TestCompatible(rasterImageViewer1.Image,true) != ImageIncompatibleReason.Compatible)
{
RasterImageConverter.MakeCompatible(rasterImageViewer1.Image, System.Drawing.Imaging.PixelFormat.DontCare, true);
}
this.pictureBox1.Image = RasterImageConverter.ChangeToImage(rasterImageViewer1.Image, Leadtools.Drawing.ChangeToImageOptions.None);
+--------------------------------------------+
厂商给的回复跟我的一致,请您使用ConvertToImage方法替代ChangeToImage方法。
但由于图片有可能是压缩的,所以追加了一个判断,
if (RasterImageConverter.TestCompatible(rasterImageViewer1.Image,true) != ImageIncompatibleReason.Compatible)
{
RasterImageConverter.MakeCompatible(rasterImageViewer1.Image, System.Drawing.Imaging.PixelFormat.DontCare, true);
}
使得处理图片能够转换。请您将上面的代码追加到您的程序中去。
以上,谢谢。 |