Exemplo n.º 1
0
        // click on processing buttons
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string          buttonName = (sender as Button).Content.ToString();
            ImageProcessing process    = new ImageProcessing();

            byte[] processedImageBytes;
            //try
            //{
            processedImageBytes   = process.FindContours(originalImageBytes, originalImage.PixelHeight, originalImage.PixelWidth);
            grayscalePanel.Source = ImageConvertor.ByteArrayToImage(processedImageBytes, originalImage.PixelWidth, originalImage.PixelHeight, 1);
            //}
            //catch (Exception ex) {
            //MessageBox.Show("Smth went so wrong...");
            //}
        }
        // click on processing buttons
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string          buttonName = (sender as Button).Content.ToString();
            ImageProcessing process    = new ImageProcessing();

            byte[] processedImageBytes;
            try
            {
                switch (buttonName[0])
                {
                // if the button is "Red filter"
                case 'R':
                    processedImageBytes   = process.setRedFilter(originalImageBytes);
                    grayscalePanel.Source = ImageConvertor.ByteArrayToImage(processedImageBytes, originalImage.PixelWidth, originalImage.PixelHeight, 4);
                    break;

                // if the button is "Invert"
                case 'I':
                    processedImageBytes   = process.setInvert(originalImageBytes);
                    grayscalePanel.Source = ImageConvertor.ByteArrayToImage(processedImageBytes, originalImage.PixelWidth, originalImage.PixelHeight, 4);
                    break;

                // if the button is "Gray-scale"
                case 'G':
                    processedImageBytes   = process.setGrayscale(originalImageBytes);
                    grayscalePanel.Source = ImageConvertor.ByteArrayToImage(processedImageBytes, originalImage.PixelWidth, originalImage.PixelHeight, 1);
                    break;

                // if smth stupid happend
                default:
                    break;
                }
            }
            catch (Exception ex) {
                MessageBox.Show("Smth went so wrong...");
            }
        }