Exemple #1
0
        // Manage the combo box for the filters
        // Apply the filter when one is selected
        private void ComboBoxFilter_SelectedIndexChanged(object sender, EventArgs e)
        {
            // If the combobox is selected > 0 It means that one filter was selected
            // So the user can choose a Edge to apply (enable the combobox edge)
            if (comboBoxFilter.SelectedIndex > 0)
            {
                SetComboboxEdgeActive(true);
            }

            // If the combobox is selected < 0 It means that no filter was selected
            // So the user cannot choose an Edge until he hasn't chose a filter (disable the combobox edge)
            else
            {
                SetComboboxEdgeActive(false);
            }

            // Once a filter/no filter was choosen by the user it will be applied on the bitmap loaded
            try
            {
                // Get the original bitmap to apply the filter
                currentBitmapFilter = inputManager.GetOriginalImageFromFile().CopyToSquareCanvas(pictureBoxForImageLoaded.Width);
                // Get the name of the filter selected by the user and add it to the interface filter
                filter.SetFilterName(comboBoxFilter.SelectedItem.ToString());
                // Apply the filter selected on the bitmap through the manager
                currentBitmapFilter = filterManager.ApplyFilter(currentBitmapFilter, filter);
                // Put the bimtap with the applied filter on the picture box
                pictureBoxForImageLoaded.Image = currentBitmapFilter;
            }
            // If there is any exception it will be catch and set the bitmap to null
            catch (Exception ex)
            {
                Console.WriteLine(e);
                pictureBoxForImageLoaded.Image = null;
            }
        }
Exemple #2
0
        public void TestFilter_NoneFilterManager()
        {
            // Create the bitmap with No filter applied using the correct path
            Bitmap bitmapNone = new Bitmap(pathIceland);

            // Set filter name 'None'
            iFilter.SetFilterName("None");

            // Create a bitmap with the path of the original image
            Bitmap bitmapResult = new Bitmap(pathIceland);

            // Apply the filter directly on the bitmap
            bitmapResult = filterManager.ApplyFilter(bitmapResult, iFilter);

            // Compare the pixels of the 2 bitamps to check if they are the same
            comparePixelImages(bitmapNone, bitmapResult);
        }