How to set a bitmap from resource

前端 未结 6 1248
温柔的废话
温柔的废话 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:11

    If you have declare a bitmap object and you want to display it or store this bitmap object. but first you have to assign any image , and you may use the button click event, this code will only demonstrate that how to store the drawable image in bitmap Object.

    Bitmap contact_pic = BitmapFactory.decodeResource(
                               v.getContext().getResources(),
                               R.drawable.android_logo
                         );
    

    Now you can use this bitmap object, whether you want to store it, or to use it in google maps while drawing a pic on fixed latitude and longitude, or to use some where else

提交回复
热议问题