mirror of
https://github.com/status-im/react-native-camera.git
synced 2025-02-24 09:48:17 +00:00
Merge pull request #1563 from taiste/master
Fix java.lang.ArrayIndexOutOfBoundsException with image rotation on Android
This commit is contained in:
commit
ef362a2d57
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user