1

I have already done an application where the user can draw lines with a finger. For this I extend a View and call

Canvas.drawPath(path)

where path is updated every time the user touches and moves the finger. However now I need to be able to save such drawing, but the output file should be larger in resolution than the drawing view. I think that this is more or less like the other image editing apps that show you a scaled-down version of a picture, but in the end you save your edits to the original size.
I guess that if I draw on the scaled-down view and then simply scale-up for saving, it will look bad (pixelated) because the output image will be like twice bigger than shown on the view.

So how do the image editors handle this? I have not been able to find (yet) the source code of such image editor.

Thanks in advance!

JohnMark13
  • 3,709
  • 1
  • 15
  • 26
dragi
  • 3,385
  • 5
  • 22
  • 40

1 Answers1

0

I ended up creating a second drawing view that is invisible but with the correct width and height. Every time a drawSomething() call is made on the visible view, the invisible view is updated with the same call, but with coordinates scaled by the correct factor. The factor is calculated like:

factor = visibleView.width / invisibleView.width;

I am keeping the width to height ratio the same for the visible and invisible view, so I need only one factor here.
It didn't work the usual way to get the bitmap of a view that is invisible, so I used this answer https://stackoverflow.com/a/16501007/2160877.
For me this solution worked, but I couldn't find any other solution, so I'd appreciate if anyone shares a better solution.

Community
  • 1
  • 1
dragi
  • 3,385
  • 5
  • 22
  • 40