How to get a Uri object from Bitmap

后端 未结 7 1638
醉话见心
醉话见心 2020-12-09 15:55

On a certain tap event, I ask the user to add an image. So I provide two options:

  1. To add from gallery.
  2. To click a new image from camera.
7条回答
  •  不知归路
    2020-12-09 16:42

    This is what worked for me. For example getting thumbnail from a video in the form of a bitmap. Then we can convert the bitmap object to uri object.

    String videoPath = mVideoUri.getEncodedPath();
    System.out.println(videoPath); //prints to console the path of the saved video
    Bitmap thumb = ThumbnailUtils.createVideoThumbnail(videoPath, MediaStore.Images.Thumbnails.MINI_KIND);
    
     Uri thumbUri = getImageUri(this, thumb);
    

提交回复
热议问题