All Projects → PatilShreyas → Capturable

PatilShreyas / Capturable

Licence: MIT license
🚀Jetpack Compose utility library for capturing Composable content and transforming it into Bitmap Image🖼️

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Capturable

PlantShopUI-Android
Check out the new style for App Design aims for the Online Plant Shop Service using jetpack compose...😉😀😁😎
Stars: ✭ 29 (-92.05%)
Mutual labels:  android-app, jetpack-android, jetpack-compose
Kuberam
Kuberam is built on jetpack compose + Auth0 during Hashnode Hackathon.
Stars: ✭ 33 (-90.96%)
Mutual labels:  android-app, jetpack-compose
ComposeNotes
Notes app with full jetpack compose architecture (UI + navigation). Uses MVVM, Room, Kotlin Flows & LiveData
Stars: ✭ 32 (-91.23%)
Mutual labels:  jetpack-android, jetpack-compose
InstaSmart
A Flutter app to plan and beautify your Instagram feed
Stars: ✭ 18 (-95.07%)
Mutual labels:  photos, android-app
Multi-Module-Nextflix-Composable
Includes jetpack compose, navigation, paging, hilt, retrofit, coil, coroutines, flow..
Stars: ✭ 195 (-46.58%)
Mutual labels:  jetpack-android, jetpack-compose
Compose-ToDo
A fully functional Android TODO app built entirely with Kotlin and Jetpack Compose
Stars: ✭ 130 (-64.38%)
Mutual labels:  jetpack-android, jetpack-compose
Einsen
🎯 Einsen is a prioritization app that uses Eisenhower matrix technique as workflow to prioritize a list of tasks & built to Demonstrate use of Jetpack Compose with Modern Android Architecture Components & MVVM Architecture.
Stars: ✭ 821 (+124.93%)
Mutual labels:  jetpack-android, jetpack-compose
Compose-Settings
Android #JetpackCompose Settings library
Stars: ✭ 188 (-48.49%)
Mutual labels:  jetpack-android, jetpack-compose
ShaderShowcaseApp
A Jetpack Compose-based app to exhibit all the beautiful GLSL Fragment shaders I have ever written, where you can set them as Live Wallpaper.
Stars: ✭ 173 (-52.6%)
Mutual labels:  jetpack-android, jetpack-compose
ComposableSweetToast
Jetpack Compose, Custom Toast, Solid Principles, Kotlin
Stars: ✭ 60 (-83.56%)
Mutual labels:  composable, jetpack-compose
Paper
A minimal notes application in Jetpack Compose with MVVM architecture. Built with components like DataStore, Coroutines, ViewModel, LiveData, Room, Navigation-Compose, Coil, koin etc.
Stars: ✭ 122 (-66.58%)
Mutual labels:  jetpack-android, jetpack-compose
Awesome-Android-Open-Source-Projects
👓 A curated list of awesome android projects by open-source contributors.
Stars: ✭ 401 (+9.86%)
Mutual labels:  jetpack-android, jetpack-compose
NestedScrollView
NestedScrollView for Jetpack Compose
Stars: ✭ 57 (-84.38%)
Mutual labels:  jetpack-android, jetpack-compose
GitReposCompose
GitReposCompose is an Android application 📱 for showcasing Jetpack Compose for building declarative UI in Android. This demo app uses Github public API for fetching public repositories.
Stars: ✭ 32 (-91.23%)
Mutual labels:  jetpack-android, jetpack-compose
ThinkRchive
An app showing all details for various Lenovo Thinkpad models. Made to try out Jepack Compose for Android.
Stars: ✭ 84 (-76.99%)
Mutual labels:  jetpack-android, jetpack-compose
Biometric-Authentication-Android
A sample implementation of AndroidX biometrics API using Kotlin. Authenticate using biometrics or PIN/Password if biometrics isn't available on device. Fully implemented in Jetpack compose using Material 3 dynamic theming and also has a separate implementation in xml with MDC 3.
Stars: ✭ 29 (-92.05%)
Mutual labels:  android-app, jetpack-compose
RocketXDelight-Playground
Native Android application built with Kotlin and Jetpack Compose. This project also illustrates the usage of advanced libraries such as Ktor, SqlDelight, Hilt, etc with the recommended practices and Unit Tests.
Stars: ✭ 37 (-89.86%)
Mutual labels:  jetpack-android, jetpack-compose
Photok
Encrypted Photo Safe for Android
Stars: ✭ 83 (-77.26%)
Mutual labels:  photos, android-app
Insta Downloader
Video & Photo Downloader or Repost for Instagram.
Stars: ✭ 217 (-40.55%)
Mutual labels:  photos, android-app
BottomNavArchDemo
The demo project for Bottom Navigation with Navigation Architecture Components article
Stars: ✭ 53 (-85.48%)
Mutual labels:  android-app, jetpack-android

Capturable

Capturable

🚀A Jetpack Compose utility library for converting Composable content into Bitmap image 🖼️.
Made with ❤️ for Android Developers and Composers

Build Maven Central

Github Followers GitHub stars GitHub forks GitHub watchers Twitter Follow

💡Introduction

In the previous View system, drawing Bitmap Image from View 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. It's built upon the ComposeView and uses View's APIs to draw the Bitmap image.

🚀 Implementation

You can check /app directory which includes example application for demonstration.

Gradle setup

In build.gradle of app module, include this dependency

dependencies {
    implementation "dev.shreyaspatil:capturable:1.0.3"
}

You can find latest version and changelogs in the releases.

Usage

1. Setup the controller

To be able to capture Composable content, you need instance of CaptureController by which you can decide when to capture the content. You can get the instance as follow.

@Composable
fun TicketScreen() {
    val captureController = rememberCaptureController()
}

rememberCaptureController() is a Composable function.

2. Add the content

The component which needs to be captured should be placed inside Capturable composable as follows.

@Composable
fun TicketScreen() {
    val captureController = rememberCaptureController()
    
    Capturable(
        controller = captureController,
        onCaptured = { bitmap, error ->
           // This is captured bitmap of a content inside Capturable Composable.
           if (bitmap != null) {
               // Bitmap is captured successfully. Do something with it!
           }
            
            if (error != null) {
                // Error occurred. Handle it!
            }
        }
    ) {
        // Composable content to be captured.
        // Here, `MovieTicketContent()` will be get captured
        MovieTicketContent(...)
    }
}

3. Capture the content

To capture the content, use CaptureController#capture() as follows.

Button(onClick = { captureController.capture() }) { ... }

On calling this method, request for capturing the content will be sent and event will be received in callback onCaptured with ImageBitmap as a parameter in the Capturable function.

By default, it captures the Bitmap using Bitmap.Config ARGB_8888. If you want to modify, you can provide config from Bitmap.Config enum.

Example:

captureController.capture(Bitmap.Config.ALPHA_8)

Make sure to call this method as a part of callback function and not as a part of the Composable function itself. Otherwise, it'll lead to capture bitmaps unnecessarily in recompositions which can degrade the performance of the application.

That's all needed!

⚠️ Precaution

While capturing the content on the devices having Android OS version O and above (API 26+) and having network images like Coil, Picasso, Glide, etc it may throw error like java.lang.IllegalArgumentException: Software rendering doesn't support hardware bitmaps. To overcome such issues, this library uses PixelCopy API to capture Bitmap as a fallback mechanism. PixelCopy has some limitations such as it can't generate bitmap if composable content is clipped inside app's Window, beyond or above screen i.e. due to scrolling, etc. So make sure not to include any UI content inside Composable which uses hardware bitmaps.

📄 API Documentation

Visit the API documentation of this library to get more information in detail.


🙋‍♂️ Contribute

Read contribution guidelines for more information regarding contribution.

💬 Discuss?

Have any questions, doubts or want to present your opinions, views? You're always welcome. You can start discussions.

📝 License

MIT License

Copyright (c) 2022 Shreyas Patil

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].