Fix : Floodfill infinite recursion due to same color (#4359)

Fix : Floodfill infinite recursion due to same color
This commit is contained in:
Manan Solanki
2023-09-09 23:37:59 +05:30
committed by GitHub
parent 81f38174a6
commit a88abb7ac2
2 changed files with 11 additions and 0 deletions

View File

@ -39,6 +39,7 @@ public class FloodFill {
* @param oldColor The old color which is to be replaced in the image
*/
public static void floodFill(int[][] image, int x, int y, int newColor, int oldColor) {
if (newColor == oldColor) return;
if (x < 0 || x >= image.length) return;
if (y < 0 || y >= image[x].length) return;
if (getPixel(image, x, y) != oldColor) return;