Can someone please explain开发者_运维百科 to me what a mutable bitmap is? What advantages/disadvantages or what limitations do mutable and immutable bitmaps have?
It's about the same difference as with String vs StringBuilder - String is immutable so you can't change its content (well at least not without any hacks), while for StringBuilder you can change its content.
In order to convert an immutable bitmap to a mutable one, check out this post: https://stackoverflow.com/a/16314940/878126.
If your bitmap include mutable flag, its pixels can be change, if doesn't, pixel changings throw an error. It's the difference between them.
And here is Android: convert Immutable Bitmap into Mutable
Not sure if there is any performance gain for using immutable bitmaps. Often immutable is just for being thread safe (or if you are going to share the image with another process, process safe)
Tries to make a new bitmap based on the dimensions of this bitmap, setting the new bitmap's config to the one specified, and then copying this bitmap's pixels into the new bitmap. and you can set config of image.
精彩评论