//Send an image from a file private void sendImageButton_Click(object sender, RoutedEventArgs e) { OpenFileDialog openDlg = new OpenFileDialog(); openDlg.Filter = "Image File (*.bmp, *.gif, *.jpg, *.png, *.tif)|*.bmp;*.gif;*.jpg;*.jpeg;*.png;*.tif;*.tiff"; openDlg.Multiselect = false; if ((bool)openDlg.ShowDialog()) { BitmapImage image = new BitmapImage(new Uri(openDlg.FileName)); server.SetResolution(image.PixelWidth, image.PixelHeight); server.SendImageWPF((BitmapSource)image, 0, 1, 2); server.Update(); } }
//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(); } }