Monday, 27 September 2021

Create a bitmap from an offscreen layout generated by Jetpack Compose

I would like to generate a bitmap from a view but using Jetpack Compose and the view has to be such that it is not attached to any window. There are posts on how to create offscreen views using the old view model (xml based) and even generate a bitmap from that. But I was not able to find any way of creating a view using Jetpack compose.

Ultimately a composable does get drawn to a canvas, but I am not aware of any way to access that canvas. Another issue I need to avoid is that newer versions of Android attempt to use hardware bitmaps and my experience with these hasn't been good when trying to generate them from a canvas.



from Create a bitmap from an offscreen layout generated by Jetpack Compose

No comments:

Post a Comment