C#-GdiPlus OverflowException
作者:互联网
我最近在GDI中通过第三方工具遇到OverflowException,这给我带来了一些问题.我试图找出原因,然后确定是否有解决问题的方法.
该错误发生在SafeNativeMethods.Gdip.GdipFillPath()中,返回的错误代码为11,该代码等于GpStatus.ValueOverflow.我不知道这意味着什么,或者可能是什么原因.结果非常高,因为我有一个很大的屏幕区域无法绘制.
此错误的堆栈跟踪为:
System.OverflowException:溢出错误.
在System.Drawing.Graphics.CheckErrorStatus(Int32状态)
在System.Drawing.Graphics.FillPath(画笔,GraphicsPath路径)
在Northwoods.Go.GoShape.DrawPath(图形g,GoView视图,钢笔,画笔,GraphicsPath路径)
在Northwoods.Go.GoRoundedRectangle.Paint(Graphics g,GoView视图)
在Northwoods.Go.GoLayer.Paint处(图形g,GoView视图,RectangleF clipRect)
在Northwoods.Go.GoView.PaintObjects处(布尔文档,布尔视图,图形g,RectangleF clipRect)
在Northwoods.Go.GoView.PaintView(Graphics g,RectangleF clipRect)
在Northwoods.Go.GoView.onPaintCanvas(PaintEventArgs evt)
在Northwoods.Go.GoView.OnPaint(PaintEventArgs evt)
在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)
显然这里有两个参数.我无法控制的GraphicsPath和Brush.画笔是通过静态方法返回的,并且为了确保它不会被丢弃,我尝试了更改画笔属性以返回如下所示的克隆.但是,这似乎没有任何影响.
public Brush
{
get {
return MappingLinearGradient(this.Bounds).Clone();
}
}
解决方法:
在IIRC中,图形对象的最大平面面积为(1< 24)-1 =>. 1670万像素.
我不确定该区域本身是否有限制,但我会调查一下.