How can I transform a Bitmap into a Uri?

前端 未结 6 2123
一向
一向 2020-12-30 19:34

I\'m trying to share images with Facebook, twitter, etc using SHARE INTENT from Android.

I found code to send a image to the share intent, but this code

6条回答
  •  青春惊慌失措
    2020-12-30 20:02

    pass bitmap and compressFormat like (PNG, JPG, etc...) and image quality in percentage

    public Uri getImageUri(Bitmap src, Bitmap.CompressFormat format, int quality) {
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        src.compress(format, quality, os);
    
        String path = MediaStore.Images.Media.insertImage(getContentResolver(), src, "title", null);
        return Uri.parse(path);
    }
    

提交回复
热议问题