Nat Strangerweather

    Nat Strangerweather

    1 year ago
    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:
    val b:Bitmap = canvas.drawToBitmap(Bitmap.Config.ARGB_8888)
    Or is there an alternative to save a canvas?
    Nader Jawad

    Nader Jawad

    1 year ago
    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) } }