惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
B
Blog RSS Feed
The GitHub Blog
The GitHub Blog
爱范儿
爱范儿
博客园 - 司徒正美
J
Java Code Geeks
酷 壳 – CoolShell
酷 壳 – CoolShell
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
D
Docker
Blog — PlanetScale
Blog — PlanetScale
Recent Announcements
Recent Announcements
罗磊的独立博客
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
Stack Overflow Blog
Stack Overflow Blog
M
MIT News - Artificial intelligence
腾讯CDC
T
The Blog of Author Tim Ferriss
小众软件
小众软件
U
Unit 42
T
Tailwind CSS Blog

博客园 - ahdung

[转载备份]Transparent windows in WPF CorelDRAW的shell扩展ShellXP.dll导致资源管理器explorer.exe卡死/冻结/无响应/挂起 Windows开的热点手机能连上但上不了网 【手记】桌面变成英文desktop的解决办法 【手记】翻新显卡安装驱动程序 [SQLCLR]跑起unsafe程序集的前提备忘 【手记】让Fiddler捕获到SQLCLR中的网络请求 .Net程序连接SQL Server默认会话选项备查 【手记】Reflexil直接让方法返回true或false 【组件分享】自定义窗口标题菜单 DLL/OCX文件的注册与数据执行保护DEP 【SQL】用SSMS连接Oracle手记 偶尔要用的git命令备忘 似乎是VS2017的一个BUG 【SQL】在数据库中发起http请求的小改进 【SQL】从待选项中随机选一个 【手记】解决Intel Management Engine Interface黄色感叹号 【手记】如果Idx/Sub字幕导不进MKVToolNix,看看是否这个原因 【手记】解决涉及office的程序报“Unable to cast COM object of type System._ComObject...”的问题
【手记】解决Graphics.DrawImage带ImageAttributes在XP报内存...
ahdung · 2019-09-03 · via 博客园 - ahdung

异常信息:

System.OutOfMemoryException: 内存不足。
   在 System.Drawing.Graphics.CheckErrorStatus(Int32 status)
   在 System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr callbackData)
   在 System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
   在 System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr)
   ...

这个问题在外网也有一些讨论,我倾向的说法是,XP的GDI+组件存在问题,对于像素格式PixelFormat有点特别的图像,把它绘制到其它地方的时候处理不好ImageAttributes,于是引发异常。

解决思路,既然同时满足这两者会报错:

g.DrawImage(PixelFormat特别的Image, xxx, imageAttributes)

那么只要错开其一就行,比如这两种就不会报:

g.DrawImage(常规Image, xxx, imageAttributes); //方法一
g.DrawImage(PixelFormat特别的Image, xxx); //方法二,不使用imageAttributes

所以可以用方法二从原图得到一张像素格式正常的新图,然后用方法一把它画出去,就是弄个副本。

-END-

posted on 2019-09-03 12:42  ahdung  阅读(1210)  评论()    收藏  举报