且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

调用DrawImage时解决“内存不足"异常

更新时间:2023-01-14 14:55:43

我确定您现在已经解决了这个问题,但是如果您还没有遇到同样的问题.这是GDI +中的错误,可以作为解决方法.不幸的是,我不知道为什么为什么,但是由于这些问题,我倾向于更关心它是否已解决,而不是为什么要解决. ;)

I'm sure you've figured this out by now, but in case you haven't we hit the same issue. It's a bug in GDI+ and this works as a workaround. Unfortunately I don't know why but with these sorts of issues I tend to care more that it's fixed and less why it's fixed. ;)

image = image.GetThumbnailImage(image.Width, image.Height, null, IntPtr.Zero);

显然,该调用会调整PixelFormat并将图像放置为imagelist的DrawImage用法可以处理的格式.

Apparently that call adjusts the PixelFormat and puts the image in a format that the imagelist's usage of DrawImage can handle.

发件人: https://siderite.dev/blog/outofmemoryexception-in.html