Hey guys :wave:, I am trying to save a canvas as b...
# compose
n
Hey guys 👋, I am trying to save a canvas as bitmap in my external drive. Is it at all possible in Compose to use something like:
Copy code
val b:Bitmap = canvas.drawToBitmap(Bitmap.Config.ARGB_8888)
Or is there an alternative to save a canvas?
n
You can create your own ImageBitmap and create a DrawScope to issue drawing commands into it with the following: fun drawScopeWithImageBitmap(width: Int, height: Int) { val imageBitmap = ImageBitmap(width, height) val imageBitmapCanvas = Canvas(imageBitmap) CanvasDrawScope().draw(imageBitmapCanvas, Size(width, height) { // DrawScope drawRect(Color.Red) } }
🙏 1