0
我試圖製作一個填充圖片的android應用程序。這裏是洪水的白色區域中的代碼:Android Flood填充 - 適用於一個圖像,但不適用於不同的圖像
public class floodfill {
public void flood(Bitmap bitmap, int x, int y){
int color;
int red;
int green;
int blue;
color = bitmap.getPixel(x,y);
red = Color.red(color);
green = Color.green(color);
blue = Color.blue(color);
if(red == 255){
if(green == 255){
if(blue == 255){
bitmap.setPixel(x,y,Color.BLUE);
}
}
}else {
return;
}
flood(bitmap,x+1,y);
flood(bitmap,x-1,y);
flood(bitmap,x,y+1);
flood(bitmap,x,y-1);
}
}
使用this圖像,它只是罰款罷了(藍色是它在填寫。)
然而,當我使用this像它一樣。沒有填滿一切。
我怎麼能得到這個工作,所以它就像第一張照片一樣填充所有內容?謝謝!
謝謝!你幫了很多忙。 –