Merge pull request #1672 from SimonErm/feature/requestedChanges

rename variables and add check
This commit is contained in:
João Guilherme Fidelis 2018-07-04 08:29:17 -03:00 committed by GitHub
commit 228239baf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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;
}