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

推荐订阅源

aimingoo的专栏
aimingoo的专栏
腾讯CDC
Y
Y Combinator Blog
L
LangChain Blog
B
Blog
U
Unit 42
P
Proofpoint News Feed
G
Google Developers Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 【当耐特】
WordPress大学
WordPress大学
月光博客
月光博客
Vercel News
Vercel News
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
酷 壳 – CoolShell
酷 壳 – CoolShell
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
云风的 BLOG
云风的 BLOG
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 叶小钗

博客园 - 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)  评论()    收藏  举报