Is there an equivalent for the Compose/Desktop `Im...
# compose-web
s
Is there an equivalent for the Compose/Desktop
ImageComposeScene
API but for Compose/Web? It would be great for generating images out of Composables in a headless way.
2
a
Check out SingleLayerComposeScene :)
Copy code
val scene = SingleLayerComposeScene()
    scene.setContent(content)
    val bmp = ImageBitmap(size.width, size.height)
    val canvas = Canvas(bmp)
    scene.render(canvas, 0L)
    val result = ImageIO.write(bmp.toAwtImage(), "png", File("C:\\Users\\your-user\\Desktop\\test.jpg"))
    scene.close()
❤️ 3
s
Super neat, thanks a lot!