0

I have an app which allows users to freehand draw over an image. I have achieved it by using canvas.drawPath(path, paint).

However, my problem is how to save the path, which the user just drew, as png in a app folder. Because a user might need to make a few freehand draws over the image, that user might want to delete one of the drawing block he made, so each of the freehand drawings should be displayed independently as a png image when the main image is reloaded. By doing this, I also need to know the most top left x and y to display the png over the image.

I thought there would be a method to convert the path to bitmap or to save the canvas only the part with coloured pixels. But after some research, I couldn't find any.

Can someone help please. Thank you in advance.

DtmG
  • 33
  • 1
  • 2
  • 9
  • Possible duplicate of [converting a canvas into bitmap image in android](https://stackoverflow.com/questions/4013725/converting-a-canvas-into-bitmap-image-in-android) – rckrd Apr 30 '18 at 13:59
  • @rckrd Sorry, the other post doesn't help, and this is not a duplicate of that one. My problem is that I can only use the onDraw canvas to draw the path of the move of a finger/pen, but there could be other elements on the canvas. I cannot create a separate bitmap because I would not know what a user will draw. The only way I can think of is to compare the points of the path to get the size during moving. But I wonder if there is a better solution. – DtmG May 04 '18 at 09:43
  • https://developer.android.com/reference/android/graphics/Picture ? – rckrd May 04 '18 at 09:55

0 Answers0