本文介绍了如何填充颜色在图像中特定区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要填写的白色区域的色水性涂料的应用 所以请给我建议如何做这项工作。
I want to fill the color in white area for Paint based application so please give me suggestion for how to do this work..
推荐答案
我发现了洪水的解决方案填补algoritham
I found the Solution with Flood fill algoritham
private void FloodFill(Bitmap bmp, Point pt, int targetColor, int replacementColor){ Queue<Point> q = new LinkedList<Point>(); q.add(pt); while (q.size() > 0) { Point n = q.poll(); if (bmp.getPixel(n.x, n.y) != targetColor) continue; Point w = n, e = new Point(n.x + 1, n.y); while ((w.x > 0) && (bmp.getPixel(w.x, w.y) == targetColor)) { bmp.setPixel(w.x, w.y, replacementColor); if ((w.y > 0) && (bmp.getPixel(w.x, w.y - 1) == targetColor)) q.add(new Point(w.x, w.y - 1)); if ((w.y < bmp.getHeight() - 1) && (bmp.getPixel(w.x, w.y + 1) == targetColor)) q.add(new Point(w.x, w.y + 1)); w.x--; } while ((e.x < bmp.getWidth() - 1) && (bmp.getPixel(e.x, e.y) == targetColor)) { bmp.setPixel(e.x, e.y, replacementColor); if ((e.y > 0) && (bmp.getPixel(e.x, e.y - 1) == targetColor)) q.add(new Point(e.x, e.y - 1)); if ((e.y < bmp.getHeight() - 1) && (bmp.getPixel(e.x, e.y + 1) == targetColor)) q.add(new Point(e.x, e.y + 1)); e.x++; } }}
洪水填写的android:
flood fill in android:
请参阅此此时,floodFill
更多推荐
如何填充颜色在图像中特定区域?
发布评论