问题 是否有任何泛洪福彩12选5走势图函数返回福彩12选5走势图的色点?

锡普

活跃成员
已加入
2019年3月6日
留言内容
27
地点
班加罗尔
编程经验
Beginner
我想从洪水福彩12选5走势图算法中获取点,是否有任何洪水福彩12选5走势图方法返回已福彩12选5走势图的点?

  1. 我在圆中有一个矩形,并且该矩形被一条线分隔,并且如果用户单击该矩形的任何部分,我将获得单击的鼠标点,并且我想为该矩形的单击部分着色。图像
  2. 我也想保存福彩12选5走势图的色点以备将来使用。
  3. 我在C#中使用泛洪福彩12选5走势图算法实现了代码,但是它没有按预期运行,因为我遇到了内存不足异常,我无法找到代码的问题所在。
code:
void FillZone(Bitmap image,int initialX, int initialY,Color fillColor,Color boundaryColor,List<Point> savePoint)

{

Stack<Point> points=new Stack<Point>();

points.Push(new Point(initialX,initialY));

while(points.Count>0)

{

Point currentPoin=poins.Pop();

int x=currentPoin.X;

int y=currentPoin.Y;

if((x>0&& x<pictureBoxImage.Width)&&(y>0&&y<pictureBoxImage.Height))

{

Color current=image.GetPixel(x,y);

if((current!=boundaryColor))&&(current!=fillColor))

{

image.SetPixel(x,y,fillColor);

savePoints.Add(new Point(x,y));

points.Push(new Point(x+1,y));

points.Push(new Point(x-1,y));

points.Push(new Point(x,y-1));

points.Push(new Point(x,y+1));

}

}

}

}



private void MenuItem_Select_Click(object sender,EventArgs e)

{

Point p=new Point();

p.X=m_right_button_X1;

p.Y=m_right_button_Y1;

Bitmap pic=(Bitmap)pictureBoxImage.Image.Clone();

List<Point>regionPoints=new List<Point>();

FillZone(pic,p.X,p.Y,Color.Red,Color.Black,regionPoints);

}
 
Last edited:

跳伞

工作人员
已加入
2019年4月6日
留言内容
2,533
地点
弗吉尼亚州切萨皮克
编程经验
10+
How big is the area that you trying to flood fill? In general each Point take up at least 8 bytes due to it storing 2 32-bit integers. If you are running your code as a 32-bit application, then you are limited to only about 2GB of RAM to play with. Check your build settings. Even if you have "Any CPU" set, if the "Prefer 32-bits"被选中,然后您就可以了。

If whatever you are doing causes you to have an area that you'll end up with a lot of memory usage, consider looking at some the scan-line fill algorithms instead of the simple generic flood fill algorithms. If it's not obvious, the reason why the scan line algorithms will save you memory is because you only need to start the beginning and ending X coordinates for each scan line. Even if in the end you still need all the points, what you can do is create a method that returns an IEnumerable<Point> that generates the points on the fly. As long as you never call ToList() or ToArray() on the returned enumerable, any memory usage should be minimized.
 
Last edited:

锡普

活跃成员
已加入
2019年3月6日
留言内容
27
地点
班加罗尔
编程经验
Beginner
图片框使用的是640 * 480图片
How big is the area that you trying to flood fill? In general each Point take up at least 8 bytes due to it storing 2 32-bit integers. If you are running your code as a 32-bit application, then you are limited to only about 2GB of RAM to play with. Check your build settings. Even if you have "Any CPU" set, if the "Prefer 32-bits"被选中,然后您就可以了。

如果执行任何操作,最终都会占用大量内存,请考虑查看某些扫描线福彩12选5走势图算法,而不是简单的常规泛洪福彩12选5走势图算法。
 

跳伞

工作人员
已加入
2019年4月6日
留言内容
2,533
地点
弗吉尼亚州切萨皮克
编程经验
10+
图片框使用的是640 * 480图片
但是其中有多少实际上在边界颜色之内?无论如何,即使您有"leaks" in your boundary color pixels, you shouldn't be using more than 2.5MB of RAM for your savePoints.

On closer look, though, it looks like your points stack is growing geometrically because you are covering points that you have already done previously. Probably the root cause of your out of memory condition.
 
最佳 底部