Convert immutable Bitmap file to mutable Bitmap

Alex picture Alex · May 24, 2015 · Viewed 13.9k times · Source

A:

 Bitmap immutableBmp= BitmapFactory.decodeResource(getApplicationContext().getResources(),R.drawable.sample);
 mutableBitmap=immutableBmp.copy(Bitmap.Config.ARGB_8888, true);

B:

Bitmap immutableBmp= BitmapFactory.decodeFile(filePath);
mutableBitmap=immutableBmp.copy(Bitmap.Config.ARGB_8888, true);

C:

BitmapFactory.Options options = new BitmapFactory.Options();
options.inMutable=true;
myBitmap=BitmapFactory.decodeFile(filePath,options);

A works but B and C don't. I am trying to convert an immutable bitmap to mutable. It works on resource images but not file images. What's the problem?

Answer

Florian Erwig picture Florian Erwig · Apr 17, 2018

Found this:

Bitmap bmp_Copy = bmp_Base.copy(Bitmap.Config.ARGB_8888,true);