有助于在调用DrawImage时解决“内存不足”异常

问题描述 投票:7回答:1

[大约有百分之一的用户在使用我们的应用程序时遇到突然崩溃。日志显示以下异常,到目前为止,我唯一看到的共同点是它们都具有XP SP3。

提前感谢

记不清。在System.Drawing.Graphics.CheckErrorStatus(Int32状态)在System.Drawing.Graphics.DrawImage(图像图像,矩形destRect,Int32 srcX,Int32 srcY,Int32 srcWidth,Int32 srcHeight,GraphicsUnit srcUnit,ImageAttributes imageAttrs,DrawImageAbort回调,IntPtr回调数据)在System.Drawing.Graphics.DrawImage处(图像图像,矩形destRect,Int32 srcX,Int32 srcY,Int32 srcWidth,Int32 srcHeight,GraphicsUnit srcUnit,ImageAttributes imageAttr,DrawImageAbort回调)在System.Drawing.Graphics.DrawImage(图像图像,矩形destRect,Int32 srcX,Int32 srcY,Int32 srcWidth,Int32 srcHeight,GraphicsUnit srcUnit,ImageAttributes imageAttr)在System.Windows.Forms.ControlPaint.DrawBackgroundImage(Graphics g,Image backgroundImage,Color backColor,ImageLayout backgroundImageLayout,Rectangle bounds,Rectangle clipRect,Point scrollOffset,RightToLeft rightToLeft)在System.Windows.Forms.Control.PaintBackground(PaintEventArgs e,Rectangle矩形,Color backColor,Point scrollOffset)在System.Windows.Forms.Control.PaintBackground(PaintEventArgs e,矩形矩形)在System.Windows.Forms.Control.OnPaintBackground(PaintEventArgs pevent)在System.Windows.Forms.ScrollableControl.OnPaintBackground(PaintEventArgs e)在System.Windows.Forms.Control.PaintTransparentBackground(PaintEventArgs e,矩形矩形,区域transparentRegion)在System.Windows.Forms.Control.PaintBackground(PaintEventArgs e,Rectangle矩形,Color backColor,Point scrollOffset)在System.Windows.Forms.Control.PaintBackground(PaintEventArgs e,矩形矩形)在System.Windows.Forms.Control.OnPaintBackground(PaintEventArgs pevent)在System.Windows.Forms.ScrollableControl.OnPaintBackground(PaintEventArgs e)在System.Windows.Forms.Control.PaintTransparentBackground(PaintEventArgs e,矩形矩形,区域transparentRegion)在System.Windows.Forms.Control.PaintBackground(PaintEventArgs e,Rectangle矩形,Color backColor,Point scrollOffset)在System.Windows.Forms.Control.PaintBackground(PaintEventArgs e,矩形矩形)在System.Windows.Forms.Control.OnPaintBackground(PaintEventArgs pevent)在System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e,Int16层,布尔值disposeEventArgs)在System.Windows.Forms.Control.WmPaint(Message&m)在System.Windows.Forms.Control.WndProc(Message&m)在System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&m)在System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&m)在System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)操作系统信息----------------------------名称= Windows XP版本=主页Service Pack = Service Pack 3版本= 5.1.2600.196608位= 32
c# .net system.drawing
1个回答
4
投票
why,但是由于这些问题,我倾向于更关心它的固定性,而不是为什么要固定的原因。 ;)

image = image.GetThumbnailImage(image.Width, image.Height, null, IntPtr.Zero); 显然,该调用会调整PixelFormat并将图像放置为imagelist的DrawImage用法可以处理的格式。

发件人:https://siderite.dev/blog/outofmemoryexception-in.html
© www.soinside.com 2019 - 2024. All rights reserved.