Example #1
0
        //Reset the server to the new channel info if the properties are changed
        private void ResetServer()
        {
            if (server != null)
            {
                server.Dispose();
            }

            if (sendTestPattern)
            {
                if (isColorPattern && isAlphaPattern)
                {
                    server = new ImagerServer(serverName, vrpnConnection, width, height);
                    server.AddChannel("red", channelDepth);
                    server.AddChannel("green", channelDepth);
                    server.AddChannel("blue", channelDepth);
                    server.AddChannel("alpha", channelDepth);
                    server.SetResolution(width, height);
                    //server.ResendDescription();
                    server.Update();
                    vrpnConnection.Update();
                }
                else if (isColorPattern)
                {
                    server = new ImagerServer(serverName, vrpnConnection, width, height);
                    server.AddChannel("red", channelDepth);
                    server.AddChannel("green", channelDepth);
                    server.AddChannel("blue", channelDepth);
                    server.SetResolution(width, height);
                    //server.ResendDescription();
                    server.Update();
                    vrpnConnection.Update();
                }
                else
                {
                    server = new ImagerServer(serverName, vrpnConnection, width, height);
                    server.AddChannel("gray", channelDepth);
                    server.SetResolution(width, height);
                    //server.ResendDescription();
                    server.Update();
                    vrpnConnection.Update();
                }
            }
            else //Sending an image file will always use 8-bit RGB (it doesn't have to, we just will for simplicity)
            {
                server = new ImagerServer(serverName, vrpnConnection, width, height);
                server.AddChannel("red", ImageBitDepth.unsigned8bit);
                server.AddChannel("green", ImageBitDepth.unsigned8bit);
                server.AddChannel("blue", ImageBitDepth.unsigned8bit);
                server.SetResolution(width, height);
                //server.ResendDescription();
                server.Update();
                vrpnConnection.Update();
            }
        }
Example #2
0
        public MainWindow()
        {
            InitializeComponent();

            vrpnConnection = Connection.CreateServerConnection();
            server         = new ImagerServer(serverName, vrpnConnection, width, height);
            server.AddChannel("gray", ImageBitDepth.unsigned8bit);
            //server.ResendDescription();
            server.Update();
            vrpnConnection.Update();

            ServerNameLabel.Content = "The server name is: " + serverName;

            //Use a timer to update the server
            timer          = new DispatcherTimer();
            timer.Tick    += timer_Tick;
            timer.Interval = new TimeSpan(0, 0, 0, 0, 10);
            timer.Start();
        }
Example #3
0
        public MainWindow()
        {
            InitializeComponent();

            vrpnConnection = Connection.CreateServerConnection();
            server = new ImagerServer(serverName, vrpnConnection, width, height);
            server.AddChannel("gray", ImageBitDepth.unsigned8bit);
            //server.ResendDescription();
            server.Update();
            vrpnConnection.Update();

            ServerNameLabel.Content = "The server name is: " + serverName;

            //Use a timer to update the server
            timer = new DispatcherTimer();
            timer.Tick += timer_Tick;
            timer.Interval = new TimeSpan(0, 0, 0, 0, 10);
            timer.Start();
        }
Example #4
0
        void timer_Tick(object sender, EventArgs e)
        {
            if (server != null)
            {
                if (sendTestPattern)
                {
                    if (isColorPattern && isAlphaPattern)
                    {
                        if (channelDepth == ImageBitDepth.unsigned8bit)
                        {
                            byte[] image = CreateBGRA8TestImage(width, height, frames);
                            server.SendImage(0, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 4, (uint)(width * 4), image, 2); //Send the blue channel
                            server.SendImage(1, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 4, (uint)(width * 4), image, 1); //Send the green channel
                            server.SendImage(2, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 4, (uint)(width * 4), image, 0); //Send the red channel
                            server.SendImage(3, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 4, (uint)(width * 4), image, 3); //Send the alpha channel
                            frames++;
                        }
                        else if (channelDepth == ImageBitDepth.unsigned16bit)
                        {
                            UInt16[] image = CreateRGBA16TestImage(width, height, frames);
                            server.SendImage(0, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 8, (uint)(width * 8), image, 0); //Send the blue channel
                            server.SendImage(1, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 8, (uint)(width * 8), image, 2); //Send the green channel
                            server.SendImage(2, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 8, (uint)(width * 8), image, 4); //Send the red channel
                            server.SendImage(3, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 8, (uint)(width * 8), image, 6); //Send the alpha channel
                            frames++;
                        }
                        else
                        {
                            //We can also send using a array of the base type of the image
                            float[] image = CreateRGBA32TestImage(width, height, frames);
                            server.SendImage(0, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 16, (uint)(width * 16), image, 0);  //Send the red channel
                            server.SendImage(1, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 16, (uint)(width * 16), image, 4);  //Send the green channel
                            server.SendImage(2, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 16, (uint)(width * 16), image, 8);  //Send the blue channel
                            server.SendImage(3, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 16, (uint)(width * 16), image, 12); //Send the alpha channel
                        }
                    }
                    else if (isColorPattern)
                    {
                        if (channelDepth == ImageBitDepth.unsigned8bit)
                        {
                            byte[] image = CreateRGB8TestImage(width, height, frames);
                            server.SendImage(0, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 3, (uint)width * 3, image, 0); //Send the red channel
                            server.SendImage(1, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 3, (uint)width * 3, image, 1); //Send the green channel
                            server.SendImage(2, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 3, (uint)width * 3, image, 2); //Send the blue channel
                            frames++;
                        }
                        else if (channelDepth == ImageBitDepth.unsigned16bit)
                        {
                            //This one sends a 16-bit int stored in a byte array.  The server can figure out how to convert this based on the bit depth we gave it when we created the channel.
                            UInt16[] image = CreateRGB16TestImage(width, height, frames);
                            server.SendImage(0, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 6, (uint)width * 6, image, 0); //Send the red channel
                            server.SendImage(1, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 6, (uint)width * 6, image, 2); //Send the green channel
                            server.SendImage(2, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 6, (uint)width * 6, image, 4); //Send the blue channel
                            frames++;
                        }
                    }
                    else
                    {
                        if (channelDepth == ImageBitDepth.unsigned8bit)
                        {
                            byte[] image   = CreateGray8TestImage(width, height, frames);
                            bool   success = server.SendImage(0, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 1, (uint)width, image);
                            frames++;
                        }
                        else if (channelDepth == ImageBitDepth.unsigned16bit)
                        {
                            //This one sends a 16-bit int stored in a byte array.  The server can figure out how to convert this based on the bit depth we gave it when we created the channel.
                            byte[] image = CreateGray16TestImage(width, height, frames);
                            server.SendImage(0, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 2, (uint)(width * 2), image);
                            //UInt16[] image = CreateGray16TestImage2(width, height, frames);
                            //server.SendImage(0, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 2, (uint)(width * 2), image);
                            frames++;
                        }
                        else
                        {
                            //We can also send using a array of the base type of the image
                            //float[] image = CreateGray32TestImage(width, height, frames);
                            //server.SendImage(0, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 4, (uint)(width * 4), image); //Notice that even though this uses a float array, the strides are still in bytes
                            byte[] image = CreateGray32TestImage2(width, height, frames);
                            server.SendImage(0, 0, (ushort)(width - 1), 0, (ushort)(height - 1), 4, (uint)(width * 4), image);
                            frames++;
                        }
                    }
                }

                server.Update();
                vrpnConnection.Update();
            }
        }
Example #5
0
        //Reset the server to the new channel info if the properties are changed
        private void ResetServer()
        {
            if (server != null)
            {
                server.Dispose();
            }

            if (sendTestPattern)
            {
                if (isColorPattern && isAlphaPattern)
                {
                    server = new ImagerServer(serverName, vrpnConnection, width, height);
                    server.AddChannel("red", channelDepth);
                    server.AddChannel("green", channelDepth);
                    server.AddChannel("blue", channelDepth);
                    server.AddChannel("alpha", channelDepth);
                    server.SetResolution(width, height);
                    //server.ResendDescription();
                    server.Update();
                    vrpnConnection.Update();
                }
                else if (isColorPattern)
                {
                    server = new ImagerServer(serverName, vrpnConnection, width, height);
                    server.AddChannel("red", channelDepth);
                    server.AddChannel("green", channelDepth);
                    server.AddChannel("blue", channelDepth);
                    server.SetResolution(width, height);
                    //server.ResendDescription();
                    server.Update();
                    vrpnConnection.Update();
                }
                else
                {
                    server = new ImagerServer(serverName, vrpnConnection, width, height);
                    server.AddChannel("gray", channelDepth);
                    server.SetResolution(width, height);
                    //server.ResendDescription();
                    server.Update();
                    vrpnConnection.Update();
                }
            }
            else //Sending an image file will always use 8-bit RGB (it doesn't have to, we just will for simplicity)
            {
                server = new ImagerServer(serverName, vrpnConnection, width, height);
                server.AddChannel("red", ImageBitDepth.unsigned8bit);
                server.AddChannel("green", ImageBitDepth.unsigned8bit);
                server.AddChannel("blue", ImageBitDepth.unsigned8bit);
                server.SetResolution(width, height);
                //server.ResendDescription();
                server.Update();
                vrpnConnection.Update();
            }
        }