3

I'm new to Android. Forgive me if I'm missing something really basic or my question is unclear. I'll happy to edit and update based on comments.

I am building an application where 2 people can simultaneously draw on a canvas. So far, I have been able to get a canvas running where a user can draw and the drawing persists i.e. no collaboration. I plan to use Firebase to save the canvas state at one application instance and then get the updated value at other instance and then draw the delta.

How can I store the entire canvas and then redraw it later?

  • I've looked at Canvas.save() and restore(), but they are only for undoing things like rotation and transformations. Also, these calls save to private stack and hence don't solve my purpose.

  • I have also looked at various BitmapCompress functions, but they only allow saving the bitmap in ByteOrdered form or PNG files. How do I recreate the bitmap once I have access the saved copy on another application instance?

For now, we can assume that both users don't draw simultaneously, such that there are no conflicts. If they do, the updated value for the pixel is chosen to be the correct value.

The devices communicate via Internet i.e. 3G and the Firebase communication channel is setup. I can save the Bitmap's height, width, config on the Firebase server and retrieve these values.

Let me know if I am missing something basic here. Please share pointers if something similar has been done before. Also, let me know if I should post my code, if it helps.

Community
  • 1
  • 1
Jatin Ganhotra
  • 6,825
  • 6
  • 48
  • 71

0 Answers0