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