Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix java.lang.IllegalArgumentException when not scaled. #83

Merged
merged 1 commit into from

2 participants

@addie9000

Bitmap.createScaledBitmap doesn't return new instance when scaling is not needed. This recycles the returning Bitmap object and causes java.lang.IllegalArgumentException.
I fixed this by recycling original Bitmap only when scaled Bitmap is a new instance.

@addie9000

By the way, this could fix Issue #69

@charroch
Owner

Any reason you did not use sameAs?

@addie9000

I want to compare that the instances are the same or not. I believe that sameAs will return true when Bitmap A and Bitmap B which is a copied of A. At that time, still need to recycle.
(Bitmap.createScaledBitmap may not returns a copied instance, but no guarantee.)

@charroch charroch merged commit 109a7be into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 26, 2012
  1. @addie9000

    Fix needless recycle.

    addie9000 authored
This page is out of date. Refresh to see the latest.
View
5 core/src/main/java/com/novoda/imageloader/core/bitmap/BitmapUtil.java
@@ -176,7 +176,10 @@ public Bitmap scaleBitmap(Bitmap b, int width, int height, boolean upsampling) {
// http://code.google.com/p/android/issues/detail?id=8488#c80
// System.gc();
}
- recycle(b);
+ // recycle b only if createScaledBitmap returned a new instance.
+ if (scaled != b) {
+ recycle(b);
+ }
return scaled;
}
Something went wrong with that request. Please try again.