I\'m trying to figure out how to draw on a bitmap in android, and keep a copy of these changed bitmaps for an undo function.
Bitmap b = ...
Paint p = new Pai
Use new Canvas(Bitmap bitmap) to provide a Canvas
with a Bitmap
which will contain the result of your drawing operations.
The original Bitmap
that you draw on your Canvas
with drawBitmap
will never be modified.
After each operation done by the user you might:
Another approach could be to use a LayerDrawable to stack successive drawing operations on top of each other. You can imagine allowing the user to disable each individual operation done.
You can see complete guide how to draw text here:
https://www.skoumal.net/en/android-how-draw-text-bitmap/
Long story short:
Copy your bitmap to make it mutable and create Canvas based on it.