GDI+ PathGradientBrush OutOfMemoryException
2017-08-21 15:29
302 查看
最近做的项目,需要用GDI+来绘制一些三角网格。
其中需要用色标颜色来填充这些三角网格,所以用到了PathGradientBrush画刷,如下图:
![](https://img-blog.csdn.net/20170821152056210?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvd3lxMTE1Mw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
用PathGradientBrush填充的三角网格
但是在填充这些三角形的时候,总是抛出OutOfMemoryException(内存不足)的异常。
找来找去才发现是 new PathGradientBrush(pf)
这里的点集 pf 出了问题。
所以几番实验发现,这里的点集的面积不能为0。否则在新建画刷[b]PathGradientB
4000
rush[/b]的时候就会出错。
于是,我在绘制之前加入了面积判断就没问题了:
if (VisualTool.polygonArea(pf) < 1)
{
continue;
}
其中需要用色标颜色来填充这些三角网格,所以用到了PathGradientBrush画刷,如下图:
用PathGradientBrush填充的三角网格
但是在填充这些三角形的时候,总是抛出OutOfMemoryException(内存不足)的异常。
找来找去才发现是 new PathGradientBrush(pf)
这里的点集 pf 出了问题。
所以几番实验发现,这里的点集的面积不能为0。否则在新建画刷[b]PathGradientB
4000
rush[/b]的时候就会出错。
于是,我在绘制之前加入了面积判断就没问题了:
if (VisualTool.polygonArea(pf) < 1)
{
continue;
}
相关文章推荐
- Caused by: java.lang.RuntimeException: by java.lang.OutOfMemoryError: PermGen space(tomcat 启动时提示内存溢出)
- Exception in thread ""http-bio-80"exec-1" java.lang.OutOfMemoryError: PermGen s解决方案
- Worklight Console initialization failed.Logged Exception: java.lang.OutOfMemoryError: Java heap spac
- sqlserver,执行生成脚本时“引发类型为“System.OutOfMemoryException”的异常”
- Exception in thread "HSQLDB Connection @429be9" java.lang.OutOfMemoryError: Java heap space
- GridView输入Excel时出现"System.OutOfMemoryException: Out of memory"及其解决方案。
- android.view.InflateException: Binary XML file line #95: Error inflating class(out of memory)
- intellij IDE Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
- MyEclipse启动Tomcat出现Exception in thread "main" java.lang.OutOfMemoryError: PermGen space
- 运行的程序时,出现内存不足时的解决方式Exception in thread "main" java.lang.OutOfMemoryError: Java heap space(转)
- (WeakReference )弱引用解决OutOfMemoryException异常
- tomcat内存溢出的解决方法(java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError:)
- tomcat内存溢出的解决方法(java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError:)
- Eclipse 报 “Exception in thread "main" java.lang.OutOfMemoryError: Java heap space ”错误的解决
- 项目中遇到System.StackOverflowException和System.OutOfMemoryException
- Exception in thread "main" java.lang.OutOfMemoryError: PermGen space
- System.OutOfMemoryException
- Exception in thread "http-bio-8089-exec-8" java.lang.OutOfMemoryError: PermGen space
- Spark - ERROR Executor: Exception in tjava.lang.OutOfMemoryError: unable to create new native thread
- Exception in thread "http-8080-3" java.lang.OutOfMemoryError: PermGen space