0

I am developing a peer to peer collaborative drawing app on android using alljoyn framework like chalkboard .

I am able to implement collaborative chat among peers. Now i want to implement canvas sharing where in a single canvas everyone will be able to draw in real time.

How can i start with canvas, what would be its data structure,is there any specific image object i need to handle,do i need to use json,do i have to store the pixel values in a 2D array.

I need only a black & white screen with white background and black as drawing part.

I just want to know the approach behind it. Any reference will be helpful.

thanks...

1 Answers1

1

Canvas is really a bitmap.

You add/change pixels on the bitmap using drawing commands.

To do collaborative drawing, you wouldn't share the pixel values between all users with each change.

That would create bottlenecks in serializing, transport and deserializing. It would be too slow to work.

Instead, share the latest drawing commands between all users with each change.

If user#1 draws a line from [20,20] to [100,100], just serialize that command that drew the line and share that with all users.

Perhaps the serialization might look like this: "L 20,20 100,100".

If you want an efficient serialization structure, take a look at the way SVG does it's path data--very efficient for transportation to many users.

All other users would listen for incoming commands. Upon receipt, they would deserialize user#1's line and have it automatically drawn on their own canvas.

markE
  • 102,905
  • 11
  • 164
  • 176