Android: Immutable Bitmap and IllegalStateExpetion

I was trying to call Bitmap.setPixel(...) on a Bitmap. But all I got was an IllegalStateException. This was due to the Bitmap being immutable. I found a way to convert an immutable Bitmap into a mutable mitmap:

Bitmap immutable = ...;
Bitmap mutable = immutable.copy(immutable.getConfig(), true);

That's it. Source:
http://stackoverflow.com/questions/6764839/error-with-setpixels

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

2 Responses to “Android: Immutable Bitmap and IllegalStateExpetion”

  1. Martin Becker says:

    Thanks. I clarified this in my original post.

    VN:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

  2. Bala says:

    I thing your bitmap is immutable one.
    So we can not change that bitmap.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

Leave a Reply