A generic error occurred in GDI+的解决方案


转自智慧光原文A generic error occurred in GDI+. 解决方法

 

使用image1.RotateFlip(RotateFlipType.Rotate90FlipNone)方法时候,出现错误:

An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in System.Drawing.dll


Additional information: A generic error occurred in GDI+.


但是如果我在生成这个image类型的image1后直接调用image1.RotateFlip方法就没有问题。


原因:To retain access to the source bits, GDI+ locks any source file, and forces the application to maintain the life of any source stream, for the life of the Bitmap or the Image object.


 

位图和图像的构造函数依赖项

http://support.microsoft.com/?id=814675


解决方法:

 Image tmp = (Image)m_List[0];

   Bitmap tmpbitmap = new Bitmap(tmp);
   tmpbitmap.RotateFlip(RotateFlipType.Rotate90FlipNone);
 Image image1 = tmpbitmap;

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM