Whats the best way to convert composables into bitmaps? Want to create custom bitmaps to add as map ...
n
Whats the best way to convert composables into bitmaps? Want to create custom bitmaps to add as map markers that include some text and layout depending on data. I know how to do it the “non-compose” way, but would like all my UI code to be compose.
n
I haven't used this library, but it might be worth giving it a try: https://github.com/PatilShreyas/Capturable
n
Seems like they are running into the same issue I was that you have to render it on the screen to capture it. Think for now ill just do it the View way, since I also need clustering which compose doesnt support. So have to do deal with the “old” stuff anyway 😞
k
I once also had to do this, I ended up using the code from the Capturable library for the "Compose" solution, I mean the idea is clever and works as of now, though you still have to render the component. I also looked for alternatives and dug into the Compose code, all composables are rendered using Nodes, I remember that one of those base classes had a "draw" method, where the composable gets actually rendered, so it could theoretically possible to render your Composables in for example an Android Canvas backed with a Bitmap, but sadly I it wasn't possible to do that because the API needed was internal/private