Skip to content

Commit

Permalink
fix crash in image preview on very large images
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Aug 28, 2022
1 parent b01957a commit f29f841
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/src/main/java/co/tinode/tindroid/ImageViewFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
public class ImageViewFragment extends Fragment {
private static final String TAG = "ImageViewFragment";

// Bitmaps coming from the camera could be way too big.
// 1792 is roughly 3MP for square bitmaps.
private static final int MAX_BITMAP_DIM = 1792;

// Maximum count of pixels in a zoomed image: width * height * scale^2.
private static final int MAX_SCALED_PIXELS = 1024 * 1024 * 12;
// How much bigger any image dimension is allowed to be compare to the screen size.
Expand Down Expand Up @@ -242,6 +246,10 @@ public void onResume() {
}

if (bmp != null) {
// Must ensure the bitmap is not too big (some cameras can produce
// bigger bitmaps that the phone can render)
bmp = UiUtils.scaleBitmap(bmp, MAX_BITMAP_DIM, MAX_BITMAP_DIM);

mImageView.enableOverlay(mAvatarUpload);

activity.findViewById(R.id.metaPanel).setVisibility(View.VISIBLE);
Expand Down

0 comments on commit f29f841

Please sign in to comment.