loading

Add to this Thread


Steven Gentner from United States 7 year
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;
        }

Pick Avatar
* Question/Comment - Only <b>, <i>, <u> tags are allowed. All others will be escaped.
Use the tags [image1], [image2], etc. to place the images within your question/comment.
Upload Images (.jpg, .png, .gif) < 300K, robofiles (.robo) or Zip files (.zip) < 300K.

If you have any questions/issues about RoboRealm or image processing this is your chance to ask a question. Your question and any responses will be posted to the forum section of the website for others to read and learn from.

Note that any submission will be considered property of RoboRealm. If you do not wish your images to be displayed as part of the RoboRealm site please do not submit those images. Any submission may be removed from the website at the discretion of RoboRealm personnel.