-3

Create Canvas with multiple tools like Pencil,eraser,Line,oval,triangle,square ,undo,redo etc.

Undo,Redo not working.

  @Override
        protected void onSizeChanged(int w, int h, int oldw, int oldh) {
            super.onSizeChanged(w, h, oldw, oldh);

            mBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
            mCanvas = new Canvas(mBitmap);

}
Tech
  • 59
  • 1
  • 6

2 Answers2

1

I disagree with the first answer, store a bitmap is very expensive.

what you should store is action itself.you can create a new class call Action, and store the drawing path, Paint style,etc.and when user click the redo button, perform the action on the bitmap.

I wrote a demo about paintboard, it currently support only undo action,but with the actions store in a List,you can easily add redo feature to it.the address is PaintView.

7heaven
  • 797
  • 7
  • 16
-1

One of variants of using undo - redo is store bitmap after each action (for example using HashMap), and then replace current bitmap to preview bitmap (if is undo action) or next bitmap (if this redo action). As I know android sdk not have default api to do what you want.

Konstantin
  • 174
  • 7