How to set a bitmap from resource

前端 未结 6 1246
温柔的废话
温柔的废话 2020-12-22 15:52

This seems simple, I am trying to set a bitmap image but from the resources, I have within the application in the drawable folder.

bm = BitmapFactory.decodeR         


        
6条回答
  •  北海茫月
    2020-12-22 16:10

    Assuming you are calling this in an Activity class

    Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.image);
    

    The first parameter, Resources, is required. It is normally obtainable in any Context (and subclasses like Activity).

提交回复
热议问题