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

A generic error occurred in GDI+的解决方案的更多相关文章

  1. GDI+一般性错误(A generic error occurred in GDI+)

    1.GDI+的前世今生 GDI+全称图形设备接口,Graphics Device Interface (GDI) ,他的爸爸叫做GDI, 用C写的.Windows XP出来以后用C++重新写了一下,变 ...

  2. C# GDI+发生一般性错误(A generic error occurred in GDI+))

    解决思路: 1. 因为 .net GDI+ 是对底层 的封装. 所以可以尝试用 Marshal.GetLastWin32Error();函数获得底层错误代码. try{ image.Save(file ...

  3. Exception:A generic error occurred in GDI+

    分析: 一般出现这种问题都是GDI和原数据(比如Bitmap)是同一个实体,只不过是两个引用.换句话说就是这个路径的图片被GDI占用啦. 还有一种情况是路径有问题. 场景一: WPF的Image控件的 ...

  4. A generic error occurred in GDI+. 上传图片报错

    代码就不说了,因为本地测试 ok, 服务端 就不行 ,服务器 环境 阿里云 win2008 r2  64 位 原因 是我没有这是 文件加权限 : 左边 的 少了 权限~ 代码 :含义是 网络图片 裁剪 ...

  5. IAR FOR STM8S 错误 An error occurred while retrieving GDI features: gdi-error [40201]解决方法

    今早使用IAR调试编译调试一个工程,发现IAR竟然出现如下错误信息 An error occurred ]: Can't access configuration database 在网上查看了一下, ...

  6. Appium问题解决方案(8)- selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not sign with default certificate.

    背景 运行时代码报错: selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occ ...

  7. Genymotion出现unknown generic error和This may occur if you are using a proxy错误的解决方案

    今天在实验室希望在Genymotion上多下载几个模拟器,需要重新登录帐号,却发现一个错误,叫做unknown generic error.前几天还出现过一个很诡异的问题.截图如下: . (1)unk ...

  8. Eclipse启动时发生An internal error occurred during: "Initializing Java Tooling".错误的解决方法

    问题描述: Eclipse启动时发生An internal error occurred during: "Initializing JavaTooling".错误的解决方法 解决 ...

  9. 使用MyEclipse新建maven项目时报An internal error occurred during: "Retrieving archetypes:". GC overhead limit

    前几天在上手maven时,遇到了一个十分头疼的问题,我的myeclipse配置的是自己安装的插件 ,总是报 " An internal error occurred during: &quo ...

随机推荐

  1. NGUI动态给EventDelegate加参数

    示例代码如下: 响应的函数声明为: void OnChange(UIToggle toggle) { if(toggle.value) { // do something } }   添加响应的代码如 ...

  2. Jmeter-JDBC Connection Configuration和JDBC Request注释

    1.JDBC Connection Configuration Variable Name--变量名,唯一值不可重复,给JDBC Request确定使用哪个配置 Max Number of Conne ...

  3. appium python实例脚本1

    #coding=utf-8import os, time, unittestfrom appium import webdriver PATH = lambda p:os.path.abspath(o ...

  4. System.IO.Pipelines来对消息进行Buffer合并

    System.IO.Pipelines来对消息进行Buffer合并 https://www.cnblogs.com/smark/p/9927455.html .net core使用Pipelines进 ...

  5. MySQL 百万级分页优化(Mysql千万级快速分页)

    以下分享一点我的经验 一般刚开始学SQL的时候,会这样写 : SELECT * FROM table ORDER BY id LIMIT 1000, 10; 但在数据达到百万级的时候,这样写会慢死 : ...

  6. MySQL安装与操作总结

    安装MySQL 添加mysql源 # rpm -Uvh http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm 安装mysq ...

  7. python当前路径

    os.getcwd()获取系统路径 sys.path [0]获取当前路径

  8. json常用方法和本地存储方法

    1.JSON.parse()[把json字符串解析成json对象] 2.JSON.stringify()[把json对象中解析成json字符串] <script> let obj = '{ ...

  9. JavaScript:基本包装类型

    为了方便操作,JavaScript提供了3个特殊的引用类型:Boolean.Number和String.实际上,每当读取一个基本类型值的时候,后台就会创建一个对应的基本包装类型的对象,从而可以调用这些 ...

  10. UVA11401 Triangle Counting

    题意 输入\(n\),输出有多少种方法可以从\(1,2,3,\dots,n\)中选出3个不同的整数,使得以他们为三边长可以组成三角形. \(n \leq 10^6\) 分析 参照刘汝佳的题解. 按最大 ...