コード例 #1
0
        public static Bitmap MegaFilterCustom(this Bitmap sourceBitmap, Color customColor)
        {
            Color  c            = customColor;
            Bitmap resultBitmap = ImageFilters.ApplyFilterMega(new Bitmap(sourceBitmap), 230, 110, c);

            return(resultBitmap);
        }
コード例 #2
0
        public static Bitmap CrazyFilter(this Bitmap sourceBitmap)
        {
            System.Drawing.Image te = ImageFilters.ApplyFilterSwapDivide(sourceBitmap, 1, 1, 2, 1);
            Bitmap resultBitmap     = ImageFilters.ApplyFilterSwap(new Bitmap(te));

            return(resultBitmap);
        }
コード例 #3
0
        public static Bitmap MegaFilterPink(this Bitmap sourceBitmap)
        {
            Color  c            = Color.Pink;
            Bitmap resultBitmap = ImageFilters.ApplyFilterMega(new Bitmap(sourceBitmap), 230, 110, c);

            return(resultBitmap);
        }
コード例 #4
0
        //Method simplified, because once a filter is applied the filters are disabled
        private void ApplyFilter()
        {
            //cmbFilter instead of cmbEdgeDetection
            if (previewBitmap == null || cmbFilter.SelectedIndex == -1)
            {
                return;
            }

            Bitmap selectedSource = null;
            Bitmap bitmapResult   = null;


            selectedSource = originalBitmap;


            if (selectedSource != null)
            {
                bitmapResult = ImageFilters.ApplyRegistredFilter(selectedSource, cmbFilter.SelectedItem.ToString());
            }

            if (bitmapResult != null)
            {
                picPreview.Image   = bitmapResult;
                intermediateBitmap = bitmapResult;
            }

            //Disabling the filters and enabling the edge detection
            cmbEdgeDetection.Enabled = true;
            cmbFilter.Enabled        = false;

            //From here, saving the image is possible, not loading a new one
            btnSaveNewImage.Enabled = true;
            btnOpenOriginal.Enabled = false;
        }
コード例 #5
0
        public static Bitmap SwapFilter(this Bitmap sourceBitmap)
        {
            //Test added to avoid the use of a null image
            if (sourceBitmap == null)
            {
                return(null);
            }

            Bitmap resultBitmap = ImageFilters.ApplyFilterSwap(sourceBitmap);

            return(resultBitmap);
        }
コード例 #6
0
        // apply an image filter
        private void ApplyImageFilter(bool preview)
        {
            if (previewBitmap == null || cmbEdgeDetection.SelectedIndex == -1)
            {
                return;
            }

            if (preview == true)
            {
                selectedSource = previewBitmap;
            }
            else
            {
                selectedSource = originalBitmap;
            }
            // retrieve selected image filter
            if (selectedSource != null)
            {
                switch (cmbFilters.SelectedItem.ToString())
                {
                case "None":
                    imageFilterResult = selectedSource;
                    imageFilter       = false;
                    break;

                case "Rainbow":
                    imageFilterResult = ImageFilters.RainbowFilter(new Bitmap(selectedSource));
                    imageFilter       = true;
                    break;

                case "Black & white":
                    imageFilterResult = ImageFilters.BlackWhite(new Bitmap(selectedSource));
                    imageFilter       = true;
                    break;
                }
            }

            if (bitmapResult != null)
            {
                if (preview == true)
                {
                    picPreview.Image = imageFilterResult;
                }
                else
                {
                    resultBitmap = imageFilterResult;
                }
            }
        }
コード例 #7
0
ファイル: MainForm.cs プロジェクト: amaran7/TP1-OrgDevLog
 private void cmbFilterList_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cmbFilterList.SelectedItem.ToString() == "None")
     {
         previewBitmap    = originalBitmap;
         picPreview.Image = originalBitmap;
         isImageFiltered  = false;
     }
     else
     {
         previewBitmap    = ImageFilters.ApplyImageFilter(originalBitmap, cmbFilterList.SelectedItem.ToString());
         picPreview.Image = previewBitmap;
         isImageFiltered  = true;
     }
 }
コード例 #8
0
        /// <summary>
        /// Checks for the selected filters and apply them
        /// one by one (if many).
        /// It creates a temporary bitmap and sets the preview
        /// and the result image accordind to the filters modifications.
        /// </summary>
        private void applyfilters()
        {
            Bitmap temp = originalBitmap;

            if (temp != null)
            {
                if (swapFilterCheckBox.Checked)
                {
                    temp = ImageFilters.ApplyFilterSwap(new Bitmap(temp));
                }
                if (crazyFilterCheckBox.Checked)
                {
                    temp = ImageFilters.ApplyFilterSwapDivide(new Bitmap(temp), 1, 1, 2, 1);
                    temp = ImageFilters.ApplyFilterSwap(new Bitmap(temp));
                }

                setPreviewPic(temp);
                resultBitmap  = temp;
                previewBitmap = temp;
            }
        }
コード例 #9
0
        public static Bitmap Rainbow(this Bitmap sourceBitmap)
        {
            Bitmap resultBitmap = ImageFilters.RainbowFilter(new Bitmap(sourceBitmap));

            return(resultBitmap);
        }
コード例 #10
0
        public static Bitmap BlackNWhite(this Bitmap sourceBitmap)
        {
            Bitmap resultBitmap = ImageFilters.BlackWhite(sourceBitmap);

            return(resultBitmap);
        }
コード例 #11
0
        public static Bitmap ZenFilter(this Bitmap sourceBitmap)
        {
            Bitmap resultBitmap = ImageFilters.ApplyFilter(sourceBitmap, 1, 10, 1, 1);

            return(resultBitmap);
        }
コード例 #12
0
        //Addition of color filters based on Pixel_Manipulation software

        public static Bitmap NightFilter(this Bitmap sourceBitmap)
        {
            Bitmap resultBitmap = ImageFilters.ApplyFilter(sourceBitmap, 1, 1, 1, 25);

            return(resultBitmap);
        }
コード例 #13
0
ファイル: MainForm.cs プロジェクト: Husnet/UnitTestingTP
        private void ApplyFilter(bool preview)
        {
            if (previewBitmap == null || cmbEdgeDetection.SelectedIndex == -1)
            {
                return;
            }

            Bitmap selectedSource = null;
            Bitmap bitmapResult   = null;
            Bitmap tempImage      = null;

            if (preview == true)
            {
                selectedSource = previewBitmap;
            }
            else
            {
                selectedSource = originalBitmap;
            }

            switch (cmbImageFilter.SelectedItem.ToString())
            {
            case "None":
                tempImage = selectedSource;
                break;

            case "Night Filter":
                tempImage = ImageFilters.ApplyFilter(selectedSource, 1, 1, 1, 25);
                break;

            case "Hell Filter":
                tempImage = ImageFilters.ApplyFilter(selectedSource, 1, 1, 10, 15);
                break;

            case "Miami Filter":
                tempImage = ImageFilters.ApplyFilter(selectedSource, 1, 1, 10, 1);
                break;

            case "Zen Filter":
                tempImage = ImageFilters.ApplyFilter(selectedSource, 1, 10, 1, 1);
                break;

            case "Black and White":
                tempImage = ImageFilters.BlackWhite(selectedSource);
                break;

            case "Swap Filter":
                tempImage = ImageFilters.ApplyFilterSwap(selectedSource);
                break;

            case "Crazy Filter":
                System.Drawing.Image te = ImageFilters.ApplyFilterSwapDivide(selectedSource, 1, 1, 2, 1);
                tempImage = ImageFilters.ApplyFilterSwap(new Bitmap(te));
                break;

            case "Mega Filter Green":
                tempImage = ImageFilters.ApplyFilterMega(selectedSource, 230, 110, Color.Green);
                break;

            case "Mega Filter Orange":
                tempImage = ImageFilters.ApplyFilterMega(selectedSource, 230, 110, Color.Orange);
                break;

            case "Mega Filter Pink":
                tempImage = ImageFilters.ApplyFilterMega(selectedSource, 230, 110, Color.Pink);
                break;

            case "Mega Filter Custom":
                tempImage = ImageFilters.ApplyFilterMega(selectedSource, 230, 110, Color.Blue);
                break;

            case "Rainbow Filter":
                tempImage = ImageFilters.RainbowFilter(selectedSource);
                break;
            }


            switch (cmbEdgeDetection.SelectedItem.ToString())
            {
            case "None":
                bitmapResult = tempImage;
                break;

            case "Laplacian 3x3":
                bitmapResult = tempImage.Laplacian3x3Filter(false);
                break;

            case "Laplacian 3x3 Grayscale":
                bitmapResult = tempImage.Laplacian3x3Filter(true);
                break;

            case "Laplacian 5x5":
                bitmapResult = tempImage.Laplacian5x5Filter(false);
                break;

            case "Laplacian 5x5 Grayscale":
                bitmapResult = tempImage.Laplacian5x5Filter(true);
                break;

            case "Laplacian of Gaussian":
                bitmapResult = tempImage.LaplacianOfGaussianFilter();
                break;

            case "Laplacian 3x3 of Gaussian 3x3":
                bitmapResult = tempImage.Laplacian3x3OfGaussian3x3Filter();
                break;

            case "Laplacian 3x3 of Gaussian 5x5 - 1":
                bitmapResult = tempImage.Laplacian3x3OfGaussian5x5Filter1();
                break;

            case "Laplacian 3x3 of Gaussian 5x5 - 2":
                bitmapResult = tempImage.Laplacian3x3OfGaussian5x5Filter2();
                break;

            case "Laplacian 5x5 of Gaussian 3x3":
                bitmapResult = tempImage.Laplacian5x5OfGaussian3x3Filter();
                break;

            case "Laplacian 5x5 of Gaussian 5x5 - 1":
                bitmapResult = tempImage.Laplacian5x5OfGaussian5x5Filter1();
                break;

            case "Laplacian 5x5 of Gaussian 5x5 - 2":
                bitmapResult = tempImage.Laplacian5x5OfGaussian5x5Filter2();
                break;

            case "Sobel 3x3":
                bitmapResult = tempImage.Sobel3x3Filter(false);
                break;

            case "Sobel 3x3 Grayscale":
                bitmapResult = tempImage.Sobel3x3Filter();
                break;

            case "Prewitt":
                bitmapResult = tempImage.PrewittFilter(false);
                break;

            case "Prewitt Grayscale":
                bitmapResult = tempImage.PrewittFilter();
                break;

            case "Kirsch":
                bitmapResult = tempImage.KirschFilter(false);
                break;

            case "Kirsch Grayscale":
                bitmapResult = tempImage.KirschFilter();
                break;
            }


            if (bitmapResult != null)
            {
                if (preview == true)
                {
                    picPreview.Image = bitmapResult;
                }
                else
                {
                    resultBitmap = bitmapResult;
                }
            }
        }