轉自智慧光原文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;