使用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.


 

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


解决方法:

 Image tmp = (Image)m_List[0];

   Bitmap tmpbitmap = new Bitmap(tmp);

   tmpbitmap.RotateFlip(RotateFlipType.Rotate90FlipNone);

 Image image1 = tmpbitmap;

 


你们的评论、反馈,及对你们有所用,是我整理材料和博文写作的最大的鼓励和唯一动力。欢迎讨论和关注!

没有整理与归纳的知识,一文不值!高度概括与梳理的知识,才是自己真正的知识与技能。 永远不要让自己的自由、好奇、充满创造力的想法被现实的框架所束缚,让创造力自由成长吧! 多花时间,关心他(她)人,正如别人所关心你的。理想的腾飞与实现,没有别人的支持与帮助,是万万不能的。