Loading a resource to a mutable bitmap

浪尽此生 提交于 2019-11-27 20:05:42

There are several ways to create a copy of it. This thread might help you: http://www.anddev.org/how_to_modify_the_image_file-t513.html

Use decodeResource(Resources res, int id, BitmapFactory.Options opts) and specify inMutable in the options.

http://developer.android.com/reference/android/graphics/BitmapFactory.html

You'd better use RapidDecoder.

import rapid.decoder.BitmapDecoder;

Bitmap mBackground = BitmapDecoder.from(res, R.drawable.image)
        .mutable().decode();

Works for API level 8.

android developer

in case you need to handle all API levels, check out this post:

https://stackoverflow.com/a/16314940/878126

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!