Adding undo redo feature to the FingerPaint application ( one of the google's sample application )

StackOverflow https://stackoverflow.com/questions/4580644

Pergunta

I want to modify FingerPaint application and add undo and redo features to it. It basically draws Path's to the canvas at onDraw method and draws same paths to a bitmap too. Anyway my first thought was to save bitmaps as files but there might be some more efficient way . I am waiting for suggestions.

Foi útil?

Solução

You can create a new canvas, push it onto a stack, set it to the same width and height, and then use drawImage() with the main canvas as the first image to copy the contents over. To undo, walk down the stack and use drawImage() in reverse. (Don't pop off the stack, or you won't be able to redo.)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top