DrawingCanvas-Library icon indicating copy to clipboard operation
DrawingCanvas-Library copied to clipboard

Saving the image.

Open AleksaDjordjevic opened this issue 1 year ago • 1 comments

Hi, thank you for this library it is very useful. I have one question, how can we create bitmap drawable from this drawing ? Thank you.

AleksaDjordjevic avatar Aug 17 '23 10:08 AleksaDjordjevic

Hey, Gald to know that you found this helpful. This is the code for getting:

private fun getBitmapFromView(view: View):Bitmap{
        val bitmapUsed = Bitmap.createBitmap(view.width,view.height,Bitmap.Config.ARGB_8888)
        val canvas = Canvas(bitmapUsed)
        canvas.drawColor(Color.WHITE) // adding a Background color, can be anything
        view.draw(canvas)
        return bitmapUsed

Here view can be a parent view to the library view. In my use case I had a parent Frame Layout.

PS: This is an old code and not sure if it works,

Miihir79 avatar Aug 17 '23 13:08 Miihir79