Josh,
Added to docs:
RGB - Image data is 3 byte RGB (red, green, blue) triplet.
BGR - Image data is 3 byte BGR (blue, green, red) triplet.
BGRA - Image data is 3 byte BGR with 1 alpha byte (blue, green, red, alpha) quad.
FBGR - Image data a vertically flipped is 3 byte BGR (blue, green, red) triplet.
FBGRA - Image data a vertically flipped is 3 byte BGR with 1 alpha byte (blue, green, red, alpha) quad.
They are simple formats and were quickly added for convenience. FBGR is the quickest since that's how RR stores images in memory.
What do you have so far for sending an image? Is the DLL SetBitmap not working? Perhaps the code below will prove useful:
public bool connect(String hostname)
{
connected = false;
try
{
handle = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
handle.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, DEFAULT_TIMEOUT);
handle.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, DEFAULT_TIMEOUT);
handle.Connect(hostname, SERVER_PORTNUM);
NetworkStream networkStream = new NetworkStream(handle);
binaryWriter = new BinaryWriter(networkStream);
binaryReader = new BinaryReader(networkStream);
}
catch (SocketException e2)
{
//Unable to open connection to RoboRealm port 6060
Console.WriteLine(e2.ToString());
return false;
}
connected = true;
return true;
}
// sends a String over the socket port to RoboRealm
private bool send(String txt)
{
try
{
binaryWriter.Write(Encoding.ASCII.GetBytes(txt));
}
catch (IOException e)
{
Console.WriteLine(e.ToString());
return false;
}
return true;
}
public bool setImage(String name, byte[] pixels, int width, int height)
{
if (!connected) return false;
if (name == null) name = "";
// setup the message request
if (send("<request><set_image><source>" + escape(name) + "</source><width>" + width + "</width><height>" + height + "</height></set_image></request>"))
{
// send the RGB triplet pixels after message
try
{
binaryWriter.Write(pixels, 0, width * height * 3);
}
catch (IOException e)
{
Console.WriteLine(e.ToString());
return false;
}
// read message response
String buffer;
if ((buffer = readMessage()) != null)
{
if (buffer.Equals("<response>ok</response>"))
return true;
}
}
return false;
}
|
|