如何从drawable资源创建位图

Man*_*ena -3 android bitmap

我想在另一个上添加一个图像(Bitmap).为此,我只使用位图(我绘制的图像和我添加的图像),但我使用的位图实际上是我的可绘制资源中的资源.那么有没有办法创建一个包含我的drawable的位图?

Anj*_*ali 9

要将drawable转换为以下代码的Bitmap,将有助于您:

Bitmap icon = BitmapFactory.decodeResource(context.getResources(),
                                           R.drawable.icon_resource);
Run Code Online (Sandbox Code Playgroud)