rename variables and add check

This commit is contained in:
Simon Ermler 2018-06-30 17:00:35 +02:00
parent 236758147d
commit 56c807bdeb

View File

@ -363,10 +363,14 @@ class RCTCameraViewFinder extends TextureView implements TextureView.SurfaceText
private void rotateImage(int width, int height) {
byte[] rotated = new byte[imageData.length];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
rotated[x * height + height - y - 1] = imageData[x + y * width];
}
for (int y = 0; y < width; y++) {
for (int x = 0; x < height; x++) {
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];
}
}
}
imageData = rotated;
}