public static Bitmap getMutableBitmap(Bitmap bitmap)
{
if(bitmap == null || bitmap.isMutable())
{
return bitmap;
}
try {
File file = new File(AppConstants.SDCARD_PATH+"/mutable.txt");
file.getParentFile().mkdirs();
RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
int width = bitmap.getWidth();
int height = bitmap.getHeight();
FileChannel channel = randomAccessFile.getChannel();
MappedByteBuffer map = channel.map(MapMode.READ_WRITE, 0, width*height*4);
bitmap.copyPixelsToBuffer(map);
bitmap.recycle();
bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
map.position(0);
bitmap.copyPixelsFromBuffer(map); channel.close();
randomAccessFile.close();
} catch (Exception e) {
return bitmap.copy(Bitmap.Config.ARGB_8888, true);
}
return bitmap;
}