prepareBitmapForSharing

suspend fun prepareBitmapForSharing(context: Context, bitmap: Bitmap): Uri

Writes bitmap to directory backed by DocumentSharingProvider.

Return

Uri that can be used for sharing the bitmap file to other apps.

Parameters

context

Context to use.

bitmap

Bitmap that should be compressed and saved into file.

Throws

if the bitmap could not be exported.


suspend fun prepareBitmapForSharing(context: Context, bitmap: Bitmap, compressFormat: Bitmap.CompressFormat, compressQuality: Int, fileName: String?): Uri

Writes bitmap to directory backed by DocumentSharingProvider.

Return

Uri that can be used for sharing the bitmap file to other apps.

Parameters

context

Context to use.

bitmap

Bitmap that should be compressed and saved into file.

compressFormat

The format of the compressed image.

compressQuality

The quality that compressor should use. Must be 0,100. 0 means compress for small size, 100 means compress for max quality. Some lossless formats (for example PNG), ignore the quality setting.

fileName

Optional file name used for sharing (this is the shared file name as seen by other apps).

Throws

if the bitmap could not be exported.