GdiPlus溢出异常

时间:2009-05-21 13:59:03

标签: c# gdi+

我最近在GDI +中通过第三方工具遇到了OverflowException,这导致了一些问题。我试图找出原因,然后决定是否有解决问题的方法。

SafeNativeMethods.Gdip.GdipFillPath()中发生错误,返回错误代码11,等于GpStatus.ValueOverflow。我不知道这意味着什么,或者可能导致它的原因。后果非常严重,因为我有一大块无法画出的画面。

此错误的堆栈跟踪是:

System.OverflowException:溢出错误。    在System.Drawing.Graphics.CheckErrorStatus(Int32 status)    在System.Drawing.Graphics.FillPath(画笔画笔,GraphicsPath路径)    在Northwoods.Go.GoShape.DrawPath(图形g,GoView视图,钢笔,画笔笔刷,GraphicsPath路径)    在Northwoods.Go.GoRoundedRectangle.Paint(图形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 layer,Boolean disposeEventArgs)    在System.Windows.Forms.Control.WmPaint(消息& m)    在System.Windows.Forms.Control.WndProc(消息& 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)

这里显然有2个参数被使用。我无法控制的GraphicsPath和Brush。刷子是通过静态方法返回的,只是为了确保它不是一个问题,它是Disposed我已经尝试更改Brush propety以返回如下的克隆。然而,这似乎没有产生任何影响。

public Brush 
{
   get {
         return MappingLinearGradient(this.Bounds).Clone();
       }
}

1 个答案:

答案 0 :(得分:3)

IIRC,Graphics对象的最大平面区域是(1 <&lt; 24)-1 =&gt; 1670万像素。

我不确定该区域本身是否有限制,但我会调查一下。