Read an Image/file from External storage Android

前端 未结 5 1912
借酒劲吻你
借酒劲吻你 2020-12-03 12:32

I\'m trying to load an image from external storage. I set the permissions, I tried different ways, but none of them works.

BitmapFactory.Options options =          


        
5条回答
  •  被撕碎了的回忆
    2020-12-03 13:03

    If you have a file path, just use BitmapFactory directly, but tell it to use a format that preserves alpha:

    BitmapFactory.Options options = new BitmapFactory.Options();
    
    options.inPreferredConfig = Bitmap.Config.ARGB_8888;
    
    Bitmap bitmap = BitmapFactory.decodeFile(photoPath, options);
    selected_photo.setImageBitmap(bitmap);
    

提交回复
热议问题