Esempio n. 1
0
        public System.Drawing.Bitmap ApplyFilter(Image image, EFilter filtro, Color color = default(Color), int brightness = 0, int noise = 60,
                                                 RotateFlipType RFT = RotateFlipType.RotateNoneFlipNone)
        {
            switch (filtro)
            {
            case EFilter.AutomaticAdjustmentFilter:
                AutomaticAdjustmentFilter AAF = new AutomaticAdjustmentFilter();
                return(AAF.ApplyFilter(image.BitmapImage));

            case EFilter.BlackNWhiteFilter:
                BlackNWhiteFilter BNWF = new BlackNWhiteFilter();
                return(BNWF.ApplyFilter(image.BitmapImage));

            case EFilter.BrightnessFilter:
                BrightnessFilter BF = new BrightnessFilter();
                return(BF.ApplyFilter(image.BitmapImage, brightness));

            case EFilter.ColorFilter:
                ColorFilter CF = new ColorFilter();
                return(CF.ApplyFilter(image.BitmapImage, color));

            case EFilter.InvertFilter:
                InvertFilter IF = new InvertFilter();
                return(IF.ApplyFilter(image.BitmapImage));

            case EFilter.MirrorFilter:
                MirrorFilter MF = new MirrorFilter();
                return(MF.ApplyFilter(image.BitmapImage));

            case EFilter.OldFilmFilter:
                OldFilmFilter OFF = new OldFilmFilter();
                return(OFF.ApplyFilter(image.BitmapImage, noise));

            case EFilter.RotateFlipFilter:
                RotateFlipFilter RFF = new RotateFlipFilter();
                return(RFF.RotateFlip(image.BitmapImage, RFT));

            case EFilter.SepiaFilter:
                SepiaFilter SF = new SepiaFilter();
                return(SF.ApplyFilter(image.BitmapImage));

            case EFilter.WindowsFilter:
                WindowsFilter WF = new WindowsFilter();
                return(WF.ApplyFilter(image.BitmapImage));
            }
            return(image.BitmapImage);
        }
Esempio n. 2
0
        public Bitmap ApplyFilter(Bitmap image)
        {
            Bitmap           copy        = (Bitmap)image.Clone();
            RotateFlipFilter filter      = new RotateFlipFilter();
            Bitmap           rotated     = filter.RotateFlip(copy, RotateFlipType.RotateNoneFlipX);
            Bitmap           whiteCanvas = new Bitmap(image.Width * 2, image.Height);

            for (int i = 0; i < image.Height; i++)
            {
                for (int x = 0; x < image.Width; x++)
                {
                    whiteCanvas.SetPixel(x, i, copy.GetPixel(x, i));
                }
            }

            for (int i = 0; i < image.Height; i++)
            {
                for (int x = 0; x < image.Width; x++)
                {
                    whiteCanvas.SetPixel(x + image.Width, i, rotated.GetPixel(x, i));
                }
            }
            return(whiteCanvas);
        }