
Utility library facilitates conversion of composable content into ImageBitmap, enabling asynchronous capture and sharing or saving of components. Ideal for modern UI frameworks.
Compose Multiplatform utility library for capturing Composable content as ImageBitmap.
Thanks to @PatilShreyas for the original inspiration.
Capturable makes it easy to capture Compose UI content into bitmap images across platforms.
io.github.jmseb3:capturable: core capture API (CaptureController, Modifier.capturable)io.github.jmseb3:capturableExtension: optional save/share helpers built on top of FileKit[versions]
capturable = "2.0.2"
[libraries]
capturable = { module = "io.github.jmseb3:capturable", version.ref = "capturable" }
capturable-extension = { module = "io.github.jmseb3:capturableExtension", version.ref = "capturable" }dependencies {
implementation(libs.capturable)
implementation(libs.capturable.extension)
}dependencies {
implementation("io.github.jmseb3:capturable:2.0.2")
implementation("io.github.jmseb3:capturableExtension:2.0.2")
}Latest versions and changelog: Releases
@Composable
fun TicketScreen() {
val captureController = rememberCaptureController()
}@Composable
fun TicketScreen() {
val captureController = rememberCaptureController()
Column(modifier = Modifier.capturable(captureController)) {
MovieTicketContent(...)
}
}val scope = rememberCoroutineScope()
Button(onClick = {
scope.launch {
runCatching { captureController.captureAsync().await() }
.onSuccess { bitmap -> /* use bitmap */ }
.onFailure { error -> error.printStackTrace() }
}
}) { ... }If you need captureAsyncAndSave or captureAsyncAndShare, use capturableExtension.
It depends on FileKit. Follow the FileKit setup guide.
Android initialization example:
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
FileKit.init(this)
}
}| Platform | captureAsyncAndSave | captureAsyncAndShare |
|---|---|---|
| Android | ✅ | ✅ |
| iOS | ✅ | ✅ |
| JVM | ✅ | ❎ |
| JS | ✅ | ❎ |
| WASM | ✅ | ❎ |
Example app source lives in sample/.
./gradlew :sample:desktopApp:run
./gradlew :sample:webApp:jsBrowserDevelopmentRun --continue
./gradlew :sample:webApp:wasmJsBrowserDevelopmentRun --continue
sample:androidApp from Android Studiosample/iosApp/iosApp.xcodeproj in Xcode and runRead contribution guidelines for details.
MIT License
Copyright (c) 2022 Shreyas Patil
Copyright (c) 2024 WonDDak
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Compose Multiplatform utility library for capturing Composable content as ImageBitmap.
Thanks to @PatilShreyas for the original inspiration.
Capturable makes it easy to capture Compose UI content into bitmap images across platforms.
io.github.jmseb3:capturable: core capture API (CaptureController, Modifier.capturable)io.github.jmseb3:capturableExtension: optional save/share helpers built on top of FileKit[versions]
capturable = "2.0.2"
[libraries]
capturable = { module = "io.github.jmseb3:capturable", version.ref = "capturable" }
capturable-extension = { module = "io.github.jmseb3:capturableExtension", version.ref = "capturable" }dependencies {
implementation(libs.capturable)
implementation(libs.capturable.extension)
}dependencies {
implementation("io.github.jmseb3:capturable:2.0.2")
implementation("io.github.jmseb3:capturableExtension:2.0.2")
}Latest versions and changelog: Releases
@Composable
fun TicketScreen() {
val captureController = rememberCaptureController()
}@Composable
fun TicketScreen() {
val captureController = rememberCaptureController()
Column(modifier = Modifier.capturable(captureController)) {
MovieTicketContent(...)
}
}val scope = rememberCoroutineScope()
Button(onClick = {
scope.launch {
runCatching { captureController.captureAsync().await() }
.onSuccess { bitmap -> /* use bitmap */ }
.onFailure { error -> error.printStackTrace() }
}
}) { ... }If you need captureAsyncAndSave or captureAsyncAndShare, use capturableExtension.
It depends on FileKit. Follow the FileKit setup guide.
Android initialization example:
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
FileKit.init(this)
}
}| Platform | captureAsyncAndSave | captureAsyncAndShare |
|---|---|---|
| Android | ✅ | ✅ |
| iOS | ✅ | ✅ |
| JVM | ✅ | ❎ |
| JS | ✅ | ❎ |
| WASM | ✅ | ❎ |
Example app source lives in sample/.
./gradlew :sample:desktopApp:run
./gradlew :sample:webApp:jsBrowserDevelopmentRun --continue
./gradlew :sample:webApp:wasmJsBrowserDevelopmentRun --continue
sample:androidApp from Android Studiosample/iosApp/iosApp.xcodeproj in Xcode and runRead contribution guidelines for details.
MIT License
Copyright (c) 2022 Shreyas Patil
Copyright (c) 2024 WonDDak
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.