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

 

相关文章:

  • 2022-12-23
  • 2021-05-24
  • 2021-09-29
  • 2022-12-23
  • 2021-06-13
  • 2022-01-05
  • 2021-09-30
猜你喜欢
  • 2022-12-23
  • 2021-07-30
  • 2022-03-04
  • 2022-01-30
  • 2021-07-09
  • 2021-06-14
  • 2021-06-17
相关资源
相似解决方案