captureAsyncAndSave

suspend fun CaptureController.captureAsyncAndSave(contentResolver: ContentResolver, type: ImageType, fileName: String, addContentValues: (contentValues: ContentValues) -> Unit = {}): Result<Unit?>

Capture and save Image

capture and save Image use MediaStore

need permission android.Manifest.permission.WRITE_EXTERNAL_STORAGE if SDK < Q

also see CaptureController.captureAsync

Example usage:

val captureController = rememberCaptureController()
val uiScope = rememberCoroutineScope()
val context = LocalContext.current

// The content to be captured in to Bitmap
Column(
modifier = Modifier.capturable(captureController),
) {
// Composable content
}
Button(
onClick = {
scope.launch {
captureController.captureAsyncAndSave(
contentResolver = context.contentResolver,
fileName = "Ticket",
type = ImageType.PNG(100)
)
}
}) { ... }

Parameters

contentResolver

ContentResolver

type

Share Type PNG or JPEG ImageType

fileName

Do not add an extension with a dot ('.'), the appropriate extension will be automatically applied based on the ImageType.

addContentValues

add option if need for contentValues

suspend fun <Error class: unknown class>.captureAsyncAndSave(fileName: String = "capture_shared", type: ImageType = ImageType.PNG(100)): <Error class: unknown class>

Capture and save Image

capture and save Image use PHPhotoLibrary

also see CaptureController.captureAsync

Example usage:

val captureController = rememberCaptureController()
val uiScope = rememberCoroutineScope()
val context = LocalContext.current

// The content to be captured in to Bitmap
Column(
modifier = Modifier.capturable(captureController),
) {
// Composable content
}
Button(
onClick = {
scope.launch {
captureController.captureAsyncAndSave(
fileName = "Ticket",
type = ImageType.PNG(100)
)
}
}) { ... }

Parameters

type

Share Type PNG or JPEG ImageType

fileName

Do not add an extension with a dot ('.'), the appropriate extension will be automatically applied based on the ImageType.