fix(images): java.lang.IllegalArgumentException: x must be < bitmap.width() in images.findMultiColors()

This commit is contained in:
hyb1996
2018-04-11 17:11:15 +08:00
parent 8b82a294d7
commit 51fa9bde49
2 changed files with 15 additions and 1 deletions

View File

@@ -110,7 +110,12 @@ public class ColorFinder {
int y = points[i + 1];
int color = points[i + 2];
ColorDetector colorDetector = new ColorDetector.DifferenceDetector(color, threshold);
int c = image.pixel((int) (x + startingPoint.x), (int) (y + startingPoint.y));
x += startingPoint.x;
y += startingPoint.y;
if (x >= image.getWidth() || y >= image.getHeight()) {
return false;
}
int c = image.pixel(x, y);
if (!colorDetector.detectsColor(Color.red(c), Color.green(c), Color.blue(c))) {
return false;
}