hey guys, I want to use jetpack compose to create an image file. I have an interface like that: `...
r
hey guys, I want to use jetpack compose to create an image file. I have an interface like that:
Copy code
interface AssetsFactory {
    fun createTextImage(text:String, padding: Int, backgroundColor: Color): File
}
With JavaFX I would simply create a layout and use
SwingFXUtils.fromFXImage
I want something like:
Copy code
fun createImageFile(size: IntSize, content: @Composable ()-> Unit): BufferedImage
Any ideas/suggestions?
k
You can use
ImageComposeScene
that has a
render
method. From there you can call
Image.encodeToData().bytes
that will give you the PNG content to save.
It’s what I’m using for capturing screenshots in Aurora as well