Can you decode a mutable Bitmap from an InputStream?

Posted by Daniel Lew on Stack Overflow See other posts from Stack Overflow or by Daniel Lew
Published on 2010-04-30T18:48:15Z Indexed on 2010/04/30 18:57 UTC
Read the original article Hit count: 302

Filed under:

Right now I've got an Android application that:

  1. Downloads an image.
  2. Does some pre-processing to that image.
  3. Displays the image.

The dilemma is that I would like this process to use less memory, so that I can afford to download a higher-resolution image. However, when I download the image now, I use BitmapFactory.decodeStream(), which has the unfortunate side effect of returning an immutable Bitmap. As a result, I'm having to create a copy of the Bitmap before I can start operating on it, which means I have to have 2x the size of the Bitmap's memory allocated (at least for a brief period of time; once the copy is complete I can recycle the original).

Is there a way to decode an InputStream into a mutable Bitmap?

© Stack Overflow or respective owner

Related posts about android