Gdiplus.dll的访问异常

64 views
Skip to first unread message

hu dot

unread,
Feb 10, 2011, 9:45:30 PM2/10/11
to pongba

我的程序用到了Gdi+,在调试的时候可以看到VS的output窗口有大量以下内容:

First-chance exception at 0x4aee65a7 (GdiPlus.dll) in SkinMgr.exe: 0xC0000005: Access violation writing location 0x014a1044.

直接运行的时候不管是Debug还是Release版都没有问题。

这个问题初步定为在调用Gdiplus::Bitmap::SelectActiveFrame,

网上也没有什么说明方法,只有MS针对2008或者Vista的一个HotFix,但是不能要求用户装这个Hotfix。

 

开发及运行环境如下:

Windows Xp Sp3

Microsoft Visual Studio 2008 Team Suite

Gdiplus.dll版本:5.2.6001.22319

程序为MFC Application


不知道有没有人遇到过这个问题没有。


问题重现程序代码如下:

int _tmain(int argc, _TCHAR* argv[]) { ULONG_PTR dwToken = 0; Gdiplus::GdiplusStartupInput _input; Gdiplus::GdiplusStartup(&dwToken, &_input, NULL); GUID pageGuid = Gdiplus::FrameDimensionTime; HBITMAP hBitmap[10] = {0}; Bitmap* pBitmap = Bitmap::FromFile(_T("D:\\Projects\\SkinMgr\\Image\\checkingassist.gif")); for(int i=0; i<10; ++ i) { pBitmap->SelectActiveFrame(&pageGuid, i); pBitmap->GetHBITMAP(Color(0, 0, 0, 0), &hBitmap[i]); DeleteObject(hBitmap[i]); } Gdiplus::GdiplusShutdown(dwToken); return 0; }

机械唯物主义 : linjunhalida

unread,
Feb 10, 2011, 11:05:27 PM2/10/11
to pon...@googlegroups.com
发到stackoverflow去吧, 那里是解决这种技术问题的好地方.

2011/2/11 hu dot <huha...@gmail.com>:

Xuefeng Chang

unread,
Feb 10, 2011, 11:28:27 PM2/10/11
to pon...@googlegroups.com
在 2011年2月11日 上午10:45,hu dot <huha...@gmail.com>写道:

我的程序用到了Gdi+,在调试的时候可以看到VS的output窗口有大量以下内容:

First-chance exception at 0x4aee65a7 (GdiPlus.dll) in SkinMgr.exe: 0xC0000005: Access violation writing location 0x014a1044.

直接运行的时候不管是Debug还是Release版都没有问题。


这个异常有可能是Gdiplus内部处理了。
 

这个问题初步定为在调用Gdiplus::Bitmap::SelectActiveFrame,

网上也没有什么说明方法,只有MS针对2008或者Vista的一个HotFix,但是不能要求用户装这个Hotfix。

 

开发及运行环境如下:

Windows Xp Sp3

Microsoft Visual Studio 2008 Team Suite

Gdiplus.dll版本:5.2.6001.22319

程序为MFC Application


如果Hotfix提供更新的GdiPlus.dll,试试可不可以在程序中直接替换。

hu dot

unread,
Feb 11, 2011, 12:29:46 AM2/11/11
to pon...@googlegroups.com
 linjunhalida
请问stackoverflow的地址是什么?



Xuefeng Chang

 :
直接替换这个方法不太行得通啊,我们希望软件发布的时候,不自带Gdiplus,就使用系统的。

机械唯物主义 : linjunhalida

unread,
Feb 11, 2011, 12:39:07 AM2/11/11
to pon...@googlegroups.com
恩, 真的不知道stackoverflow吗? 俺们程序员遇到问题都往上面发的. google一下就知道了.

2011/2/11 hu dot <huha...@gmail.com>:
> stackoverflow

open audio

unread,
Feb 11, 2011, 2:01:30 AM2/11/11
to pon...@googlegroups.com
在google的时代,看到stackoverflow这个词还要问别人地址是可耻的:)

hu dot

unread,
Feb 11, 2011, 1:33:01 AM2/11/11
to pon...@googlegroups.com
谢谢linjunhalida,已经在上面发问题了。

在 2011年2月11日 下午1:39,机械唯物主义 : linjunhalida <linjun...@gmail.com>写道:

hu dot

unread,
Feb 11, 2011, 2:02:48 AM2/11/11
to pon...@googlegroups.com
我的错。。。

朱金灿

unread,
Feb 11, 2011, 6:46:00 AM2/11/11
to pon...@googlegroups.com

        SelectActiveFrame问题如何解决?

        http://topic.csdn.net/u/20090824/17/01be9af4-f62c-4ff0-a5a5-27599f3818ab.html

http://topic.csdn.net/u/20090114/18/07ac1cb8-d5c1-4845-b947-d95d2047b08a.html

http://dotnet.itags.org/dotnet-tech/73250/

      

This does look like a bug in GDI+. The problem is with the interaction
between the ImageAttributes and the active frame. It appears that any
changes to the ImageAttributes cause the DrawImage() call to use frame 0.

So, one workaround would be to not use the DrawImage() call which uses
ImageAttributes. Another, as you've noted, would be to extract the frame
into another Bitmap and use that instead.

 

        上面提到的,不使用ImageAttributes,我试验了一下,不行。至于说,先解码GIF的帧到新的Bitmap,从而绕过SelectActiveFrame,我想应该是可以的,但是,这会直接导致内存耗用过多!一幅二十帧、160×120的GIF动画,解码到新的Bitmap,需要耗用20×160×120×32/8=约1.5MB内存,这显然是没法接受的。

 

        这个问题也只能是保留。后面可能采用IPicture接口代替GDI+的Gif动画接口。

hu dot

unread,
Feb 11, 2011, 9:13:14 PM2/11/11
to pon...@googlegroups.com
我尝试了一下,只有部分GIF会出现这个问题,可能跟图片也有一定关系。
但是这个图片是用PS做出来的,按说不应该有这个问题。
我现在的做法就是把GIF的每一帧都抽取成32位透明位图,
虽然说内存占用大了,但是因为GIF绘制得都比较频繁,我觉得这个性价比应该也还可以的。
Reply all
Reply to author
Forward
0 new messages