Skip to content

Commit

Permalink
Fix index out of bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
YvesCheung committed Oct 22, 2020
1 parent 5c03fb2 commit a966690
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,15 @@ public static void setupColors(Bitmap bitmap, int bitmapWidth, int bitmapHeight,
for (Div yDiv : yRegions) {
for (Div xDiv : xRegions) {
int startX = xDiv.start + 1;
int stopX = Math.min(xDiv.stop + 1, bitmapWidth - 1);
int startY = yDiv.start + 1;
if (hasSameColor(bitmap, startX, xDiv.stop + 1, startY, yDiv.stop + 1)) {
int stopY = Math.min(yDiv.stop + 1, bitmapHeight - 1);

if (hasSameColor(bitmap, startX, stopX, startY, stopY)) {
int pixel = bitmap.getPixel(startX, startY);
if (isTransparent(pixel))
if (isTransparent(pixel)) {
pixel = TRANSPARENT_COLOR;
}
out.colors[colorIndex] = pixel;
} else {
out.colors[colorIndex] = NO_COLOR;
Expand Down

0 comments on commit a966690

Please # to comment.