mirror of
https://github.com/status-im/react-native-camera.git
synced 2026-08-31 13:41:08 +00:00
feat(mirror): add option to give "mirrorImage" flag to takePicture.
This commit is contained in:
@@ -73,6 +73,10 @@ public class ResolveTakenPictureAsyncTask extends AsyncTask<Void, Void, Writable
|
||||
mBitmap = rotateBitmap(mBitmap, getImageRotation(orientation));
|
||||
}
|
||||
|
||||
if (mOptions.hasKey("mirrorImage") && mOptions.getBoolean("mirrorImage")) {
|
||||
mBitmap = flipHorizontally(mBitmap);
|
||||
}
|
||||
|
||||
// Write Exif data to the response if requested
|
||||
if (mOptions.hasKey("exif") && mOptions.getBoolean("exif")) {
|
||||
WritableMap exifData = RNCameraViewHelper.getExifData(exifInterface);
|
||||
@@ -133,6 +137,12 @@ public class ResolveTakenPictureAsyncTask extends AsyncTask<Void, Void, Writable
|
||||
return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
|
||||
}
|
||||
|
||||
private Bitmap flipHorizontally(Bitmap source) {
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.preScale(-1.0f, 1.0f);
|
||||
return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
|
||||
}
|
||||
|
||||
// Get rotation degrees from Exif orientation enum
|
||||
|
||||
private int getImageRotation(int orientation) {
|
||||
|
||||
Reference in New Issue
Block a user