天天看點

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.

<a href="http://support.microsoft.com/?id=814675">http://support.microsoft.com/?id=814675</a>

解決方法:

 Image tmp = (Image)m_List[0];

   Bitmap tmpbitmap = new Bitmap(tmp);

   tmpbitmap.RotateFlip(RotateFlipType.Rotate90FlipNone);

 Image image1 = tmpbitmap;

沒有整理與歸納的知識,一文不值!高度概括與梳理的知識,才是自己真正的知識與技能。 永遠不要讓自己的自由、好奇、充滿創造力的想法被現實的架構所束縛,讓創造力自由成長吧! 多花時間,關心他(她)人,正如别人所關心你的。理想的騰飛與實作,沒有别人的支援與幫助,是萬萬不能的。

    本文轉自wenglabs部落格園部落格,原文連結:http://www.cnblogs.com/arxive/p/6275766.html,如需轉載請自行聯系原作者