How to get Bitmap from an Uri?

前端 未结 16 1270
时光说笑
时光说笑 2020-11-22 10:41

How to get a Bitmap object from an Uri (if I succeed to store it in /data/data/MYFOLDER/myimage.png or file///data/data/MYFOLDER/myimage.png) to u

16条回答
  •  孤独总比滥情好
    2020-11-22 10:49

    you can do this structure:

    protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) {
        super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
        switch(requestCode) {
            case 0:
                if(resultCode == RESULT_OK){
                        Uri selectedImage = imageReturnedIntent.getData();
                        Bundle extras = imageReturnedIntent.getExtras();
                        bitmap = extras.getParcelable("data");
                }
                break;
       }
    

    by this you can easily convert a uri to bitmap. hope help u.

提交回复
热议问题