GDI+中发生一般性错误 Bitmap Save 异常解决

 时间:2024-10-26 06:34:00

1、先看报错时的源代码,此代码已经让用户用了很长时间,都是没有问题的,突然有一点,客户反馈说软件报错“GDI+中发生一般性错误”;我调试了一下,的确这样报错的,那为什么之前一直没有报错呢?

GDI+中发生一般性错误 Bitmap Save 异常解决

2、SolidBrush brush = new SolidBrush(Color.White); StringFormat format = new StringFormat(StringFormatFlags.NoClip); Bitmap image = new Bitmap(w, h); Graphics g = Graphics.FromImage(image); g.Clear(Color.White);//透明 image.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg); g.Dispose(); image.Dispose(); image = null;

3、修正后的代码,主要是加了这段,using (Bitmap image = new Bitmap(w, h)),让系统自动释放掉资源,这个问题就解决了。

GDI+中发生一般性错误 Bitmap Save 异常解决

4、SolidBrush brush = new SolidBrush(Color.White); StringFormat format = new StringFormat(StringFormatFlags.NoClip); using (Bitmap image = new Bitmap(w, h)) { Graphics g = Graphics.FromImage(image); g.Clear(Color.White);//透明 image.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg); g.Dispose(); }

  • 欧姆龙触摸屏备份NS数据到CF卡
  • 我们如何在电脑中添加Windows凭据?
  • 电脑图标文件左下角有一个锁的样式怎么解决
  • win10系统如何设置家庭组
  • .net3.5安装错误解决办法(附快速安装办法)
  • 热门搜索
    淘宝宝贝描述怎么写 来月经腰酸怎么回事 如何保护眼睛 河童哪里多 驾照到期了如何换新驾照 钱塘江在哪里 西沙群岛在哪里 电动旅游观光车 fast路由器 红米note怎么刷机