Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


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

merged 1 commit into from

2 participants


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.


By the way, this could fix Issue #69


Any reason you did not use sameAs?


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.
5 core/src/main/java/com/novoda/imageloader/core/bitmap/
@@ -176,7 +176,10 @@ public Bitmap scaleBitmap(Bitmap b, int width, int height, boolean upsampling) {
// 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.