Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is an immutable Bitmap faster then a mutable one?

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?

like image 985
Adam Stelmaszczyk Avatar asked Mar 11 '13 18:03

Adam Stelmaszczyk


People also ask

How do you make a bitmap mutable?

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

How to create Bitmap in android?

To create a bitmap from a resource, you use the BitmapFactory method decodeResource(): Bitmap bitmap = BitmapFactory. decodeResource(getResources(), R. drawable.

What is the use of bitmap in Android?

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.


1 Answers

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 :)

like image 51
Adam Stelmaszczyk Avatar answered Oct 12 '22 22:10

Adam Stelmaszczyk