Skip to content

Commit

Permalink
Performance improvement for Camera plugin.
Browse files Browse the repository at this point in the history
Rotating the bitmap is expensive on some devices. Doing the resize before the rotation reduces notably the delay on these devices.
  • Loading branch information
KirillBorunov authored Jan 30, 2025
1 parent f45a9ee commit 6adfbe1
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -746,16 +746,17 @@ private Uri getTempImage(Uri u, ByteArrayOutputStream bitmapOutputStream) {
* @return
*/
private Bitmap prepareBitmap(Bitmap bitmap, Uri imageUri, ExifWrapper exif) throws IOException {
if (settings.isShouldCorrectOrientation()) {
final Bitmap newBitmap = ImageUtils.correctOrientation(getContext(), bitmap, imageUri, exif);
bitmap = replaceBitmap(bitmap, newBitmap);
}

if (settings.isShouldResize()) {
final Bitmap newBitmap = ImageUtils.resize(bitmap, settings.getWidth(), settings.getHeight());
bitmap = replaceBitmap(bitmap, newBitmap);
}

if (settings.isShouldCorrectOrientation()) {
final Bitmap newBitmap = ImageUtils.correctOrientation(getContext(), bitmap, imageUri, exif);
bitmap = replaceBitmap(bitmap, newBitmap);
}

return bitmap;
}

Expand Down

0 comments on commit 6adfbe1

Please sign in to comment.