开发者

Android mutable bitmap

开发者 https://www.devze.com 2023-02-16 00:21 出处:网络
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 wit

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号