Reputation: 41
I have the following code:
Bitmap mutableBitmap = result.bitmap.copy(Bitmap.Config.ARGB_8888, true);
Matrix matrix = new Matrix();
matrix.postRotate(-result.rotationDegrees);
Bitmap rotatedBitmap = Bitmap.createBitmap(mutableBitmap, 0, 0, mutableBitmap.getWidth(), mutableBitmap.getHeight(), matrix, true);
int[] intValues = new int[INPUT_SIZE*INPUT_SIZE];
rotatedBitmap.getPixels(intValues, 0, rotatedBitmap.getWidth(), 0, 0, rotatedBitmap.getWidth(), rotatedBitmap.getHeight());
An IllegalStateException
is thrown in the eraseColor
method with the message cannot erase immutable bitmaps when rotatedBitmap.getPixels
is called. Obviously, both mutableBitmap
and rotatedBitmap
are mutable bitmaps, that's why they exist, and the debugger confirms this as well. For completeness, INPUT_SIZE
is the screen width and result
is a PhotoResult
object from FotoApparat
.
So why is this exception thrown?
Upvotes: 0
Views: 106
Reputation: 12300
I think your specific createBitmap
method does not create a mutable bitmap:
"Returns an immutable bitmap from subset of the source bitmap, transformed by the optional matrix."
Upvotes: 2