tags:

views:

81

answers:

2

Idea: I want to make smth like real time electronic blackboard. Many users have one board at the screen and can draw smth at the same time, and board will update.

Implementation: I have multi user Socket server thats allow chatting (blackboard will be new feature), i need when one user drew smth the borad should update to other users(may be it should be serialized and sent or smth else).

Question: How can i send this image? I think i need send not whole image,but only coordinate, or your suggestions?

UPDATE: I found that in .net exists InkCanvas it is what i need, but how send image from it, is question

UPDATE: Image in InkCanvas are represented as Stroke objects, and StrokeCollection class has a Save() method that serializes image. One of solutions :)

+4  A: 

Yes you should only send the co ordinates of each line (as mouse drawing is a large number of point to point lines) therefore you should send each one of these to all the clients when a user draws something new.

LnDCobra
But user can draw not only line, if he drew curve what coordinates will be?
Sergey
in a simple way a curve can be a sequence of lines or bezier curves if want to be perfect.
kenny
a curve = a start point, end point, and how big the circle should be
LnDCobra
Good tutorial on curves: http://www.yevol.com/en/vcsharp/applicationdesign/Lesson14.htm
LnDCobra
+1  A: 

IMO, first you will need to use the Drawing namespace to let the user draw on perhaps a panel or something. I don't think that would be that difficult comparing to what is next. The transferring of the information. As you have figured on HOW to transfer the data (socket), your next problem is WHAT to transfer. Sending a complete image would work but will be a wastage of network bandwidth and would be completely inefficient. So coordinates are your best choice

http://www.bobpowell.net/coordinatesystems.htm

http://www.java2s.com/Tutorial/VB/0300__2D-Graphics/Drawlineusingfloatcoordinates.htm

The two links provided mention how to use coordinates to draw something. The way to transport the information is probably XML or your own encoding mechanism to encode X1,Y1 to X2,Y2 coordinates.

Capturing coordinates when drawing straight lines (or basic shapes) should be easy but i do not have an idea of how to do it when freehand drawing is used.

And finally, you should have a mechanism in making sure everyone in the chat room get the coordinates correctly as soon as something is drawn.

UPDATE: About your freehand drawing issue, these links will help you

http://www.codeproject.com/KB/GDI-plus/Freehand_Drawing.aspx

http://www.c-sharpcorner.com/forums/ShowMessages.aspx?ThreadID=88543

http://msdn.microsoft.com/en-us/library/system.drawing.drawing2d.graphicspath.aspx

This link looks very promising as it is a whiteboard application used by 2 users... With a little more effort, perhaps you can make it work for any amount of users :) http://www.codeproject.com/KB/dotnet/csharpwhiteboard.aspx

Ranhiru Cooray