- Notifications
You must be signed in to change notification settings - Fork0
🚀Jetpack Compose utility library for capturing Composable content and transforming it into Bitmap Image🖼️
License
androiddevnotesforks/Capturable
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
🚀A Jetpack Compose utility library for converting Composable content into Bitmap image 🖼️.
Made with ❤️ for Android Developers and Composers
In the previous View system, drawing Bitmap Image fromView was very straightforward. But that's not the case with Jetpack Compose since it's different in many aspects from previous system. This library helps easy way to achieve the same results.
You can check/app directory which includes example application for demonstration.
Inbuild.gradle of app module, include this dependency
dependencies { implementation"dev.shreyaspatil:capturable:2.1.0"}
You can find latest version and changelogs in thereleases.
To be able to capture Composable content, you need instance ofCaptureController by which you can decide when to capture the content. You can get the instance as follow.
@ComposablefunTicketScreen() {val captureController= rememberCaptureController()}
rememberCaptureController() is a Composable function.
The component which needs to be captured, acapturable() Modifier should be applied on that @Composable component as follows.
@ComposablefunTicketScreen() {val captureController= rememberCaptureController()// Composable content to be captured.// Here, everything inside below Column will be get capturedColumn(modifier=Modifier.capturable(captureController)) {MovieTicketContent(...) }}
To capture the content, useCaptureController#captureAsync() as follows.
// Example: Capture the content when button is clickedval scope= rememberCoroutineScope()Button(onClick= {// Capture content scope.launch {val bitmapAsync= captureController.captureAsync()try {val bitmap= bitmapAsync.await()// Do something with `bitmap`. }catch (error:Throwable) {// Error occurred, do something. } }}) {... }
On calling this method, request for capturing the content will be sent andImageBitmap will bereturned asynchronously.This method is safe to be called from Main thread.
Visit the API documentation of this library to get more information in detail.
Readcontribution guidelines for more information regarding contribution.
Have any questions, doubts or want to present your opinions, views? You're always welcome. You canstart discussions.
MIT LicenseCopyright (c) 2022 Shreyas PatilPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, 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 THESOFTWARE.About
🚀Jetpack Compose utility library for capturing Composable content and transforming it into Bitmap Image🖼️
Resources
License
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Languages
- Kotlin100.0%
