The Bitmap
class has a method copy()
with the signature below:
public Bitmap copy(Bitmap.Config config, boolean isMutable)
Is there a performance difference between a mutable and an immutable Bitmap
?
Options options = new BitmapFactory. Options(); options. inMutable=true; myBitmap=BitmapFactory. decodeFile(filePath,options);
To create a bitmap from a resource, you use the BitmapFactory method decodeResource(): Bitmap bitmap = BitmapFactory. decodeResource(getResources(), R. drawable.
A bitmap is simply a rectangle of pixels. Each pixel can be set to a given color but exactly what color depends on the type of the pixel. The first two parameters give the width and the height in pixels. The third parameter specifies the type of pixel you want to use.
Romain Guy answered in the comments:
To answer the original question: no, there is no performance difference. There are some optimizations we could implement for mutable bitmaps though. Hopefully in a future release :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With