Skip to content
This repository has been archived by the owner on Jun 16, 2023. It is now read-only.

Commit

Permalink
Android: Fix java.lang.ArrayIndexOutOfBoundsException with image rota…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
Ville Ahti committed May 17, 2018
1 parent a459909 commit 6ce014d
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ private byte[] rotateImage(byte[] imageData, int height, int width) {
byte[] rotated = new byte[imageData.length];
for (int y = 0; y < width; y++) {
for (int x = 0; x < height; x++) {
rotated[x * width + width - y - 1] = imageData[x + y * height];
int sourceIx = x + y * height;
int destIx = x * width + width - y - 1;
if (sourceIx >= 0 && sourceIx < imageData.length && destIx >= 0 && destIx < imageData.length) {
rotated[destIx] = imageData[sourceIx];
}
}
}
return rotated;
Expand Down

0 comments on commit 6ce014d

Please sign in to comment.