Merge pull request #1563 from taiste/master

Fix java.lang.ArrayIndexOutOfBoundsException with image rotation on Android
This commit is contained in:
João Guilherme Fidelis 2018-05-17 10:45:18 -03:00 committed by GitHub
commit ef362a2d57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -108,7 +108,11 @@ public class RNCameraView extends CameraView implements LifecycleEventListener,
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;