NativeScript / nativescript-camera

NativeScript plugin to empower using device camera.
Apache License 2.0
92 stars 47 forks source link

Bitmap rotation is very slow on XCover4, add a config option to bypass rotation? #232

Open SpurguX opened 4 years ago

SpurguX commented 4 years ago

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

Please, tell us how to recreate the issue in as much detail as possible.

Taking a picture with nativescript-camera takes between 5-10 seconds on average on XCover4 which I found out was because of the call to rotateBitmap. The camera works nice and quick when I comment out the the part where orientation is checked and rotation handled, that is, the following section:

var orientation_1 = exif.getAttributeInt(android.media.ExifInterface.TAG_ORIENTATION, android.media.ExifInterface.ORIENTATION_NORMAL);
if (orientation_1 === android.media.ExifInterface.ORIENTATION_ROTATE_90) {
  rotateBitmap(picturePath_1, 90);
} else if (orientation_1 === android.media.ExifInterface.ORIENTATION_ROTATE_180) {
  rotateBitmap(picturePath_1, 180);
}
else if (orientation_1 === android.media.ExifInterface.ORIENTATION_ROTATE_270) {
  rotateBitmap(picturePath_1, 270);
}

On Samsung Galaxy S9+ taking a picture is considerably faster but still a bit laggy. I'm wondering if there is something wrong with my project settings or if it's just that XCover4 is not that high performance.

I was thinking that it could be useful to have a config flag called something like bypassRotation that defaults to false or rotateBitmap that defaults to true. The rotation isn't even necessary in my case since the captured image seems to have the correct exif tag set.