Perhaps a starter's question: Our compose applicat...
# compose
k
Perhaps a starter's question: Our compose application depends on a legacy library function which needs a android.graphics.BitMap as input parameter. This BitMap is just a text with a background color. The question is how we can create a BitMap object using the Text composable?
r
k
Thanks, I will have a look.
It appears that composable needs to be drawn at screen first, then to capture it in a bitmap. In my case, I only need to create the bitmap. It looks like I need to create the bitmap using the 'legacy' Android View system (missing all of the nice stuff of the Text composable) :(
r
you mean with views, you were able to capture a bitmap from a View even without the View being visible on screen?
k
No, just using Canvas and Paint
It seems that TextPaint would have some basic similar features of the Text composable
r
I'm partly interested in this. At work we need to create receipts and I was thnking of making the templates in Compose. But I also need a way to extract Bitmaps from them
and without showing them on screen 😄
k
This is how to draw a text in a bit map. But you can draw anything else you want. This is how to draw an empty bitmap (in case you need that)
a
The view system and Compose UI are both for rendering UI, not creating bitmaps. The Canvas and Paint APIs are all Android framework APIs and themselves have nothing to do with either the view system or Compose UI.
r
yap. But you know if I could describe my wanted Bitmap in Compose instead of using Paint APIs that would be much easier and maintainable 😄
coz if I use Text, then I'm using a well abstracted concept that does a lot for me.
k
Indeed I should have to mention to use the Composable system to create the bitmap. The bitmap could be created using the Android graphic system. I was just hoping that there would a way to create the bitmap similar to create a Text composable ;)