Пример #1
0
        public Image Create(Image img)
        {
            var    effect = new BlurEffect(25, true);
            Bitmap newImg = new Bitmap(img);

            newImg.ApplyEffect(effect, Rectangle.Empty);
            return(newImg);
        }
Пример #2
0
        public Image Create(Image img)
        {
            var    effect = new TintEffect(90, 30);
            Bitmap newImg = new Bitmap(img);

            newImg.ApplyEffect(effect, Rectangle.Empty);
            return(newImg);
        }
        public Image Create(Image img)
        {
            var    effect = new ColorMatrixEffect();
            Bitmap newImg = new Bitmap(img);

            newImg.ApplyEffect(effect, Rectangle.Empty);
            return(newImg);
        }
Пример #4
0
        /// <summary>
        ///     Make sure the content is also transformed.
        /// </summary>
        /// <param name="matrix"></param>
        public override void Transform(Matrix matrix)
        {
            var rotateAngle = CalculateAngle(matrix);

            // we currently assume only one transformation has been made.
            if (rotateAngle != 0)
            {
                Log.Debug().WriteLine("Rotating element with {0} degrees.", rotateAngle);
                DisposeShadow();
                using (var tmpMatrix = new Matrix())
                {
                    using (_bitmap)
                    {
                        _bitmap = _bitmap.ApplyEffect(new RotateEffect(rotateAngle), tmpMatrix);
                    }
                }
            }
            base.Transform(matrix);
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="image"></param>
        /// <returns></returns>
        public override Image Apply(Image image)
        {
            GetParams(fm);

            if (!(image is Image))
            {
                return(image);
            }

            Bitmap dst = AddinUtils.CloneImage(image) as Bitmap;

            BlurMode blurMode          = (BlurMode)Params["BlurMode"].Value;
            double   gaussianSigma     = (double)Params["GaussianSigma"].Value;
            int      gaussianSize      = (int)Params["GaussianSize"].Value;
            int      gaussianThreshold = (int)Params["GaussianThreshold"].Value;
            int      boxSize           = (int)Params["BoxSize"].Value;
            float    gdiRatio          = (float)Params["GdiRatio"].Value;

            Accord.Imaging.Filters.IFilter filter = null;
            switch (blurMode)
            {
            case BlurMode.Normal:
                filter = new Accord.Imaging.Filters.Blur();
                if (dst is Image)
                {
                    dst = (filter as Accord.Imaging.Filters.Blur).Apply(dst);
                }
                break;

            case BlurMode.Gaussian:
                filter = new Accord.Imaging.Filters.GaussianBlur();
                (filter as Accord.Imaging.Filters.GaussianBlur).Sigma     = gaussianSigma;
                (filter as Accord.Imaging.Filters.GaussianBlur).Size      = gaussianSize;
                (filter as Accord.Imaging.Filters.GaussianBlur).Threshold = gaussianThreshold;
                dst = filter.Apply(dst);
                break;

            case BlurMode.Box:
                filter = new Accord.Imaging.Filters.FastBoxBlur((byte)boxSize, (byte)boxSize);
                dst    = AddinUtils.ProcessImage(filter, dst, false);
                break;

            case BlurMode.GDI:
                var effect = new BlurEffect(gdiRatio, true);
                dst.ApplyEffect(effect, new Rectangle(0, 0, dst.Width, dst.Height));
                break;
            }
            AddinUtils.CloneExif(image, dst);
            return(dst);
        }
Пример #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="image"></param>
        /// <returns></returns>
        public override Image Apply(Image image)
        {
            GetParams(fm);

            if (!(image is Image))
            {
                return(image);
            }

            Bitmap dst = AddinUtils.CloneImage(image) as Bitmap;

            SharpenMode sharpenMode       = (SharpenMode)Params["SharpenMode"].Value;
            double      gaussianSigma     = (double)Params["GaussianSigma"].Value;
            int         gaussianSize      = (int)Params["GaussianSize"].Value;
            int         gaussianThreshold = (int)Params["GaussianThreshold"].Value;
            float       gdiRatio          = (float)Params["GdiRatio"].Value;
            float       gdiAmount         = (float)Params["GdiAmount"].Value;

            Accord.Imaging.Filters.IFilter filter = null;
            switch (sharpenMode)
            {
            case SharpenMode.Normal:
                filter = new Accord.Imaging.Filters.Sharpen();
                dst    = (filter as Accord.Imaging.Filters.Sharpen).Apply(dst);
                break;

            case SharpenMode.Gaussian:
                filter = new Accord.Imaging.Filters.GaussianSharpen();
                (filter as Accord.Imaging.Filters.GaussianSharpen).Sigma     = gaussianSigma;
                (filter as Accord.Imaging.Filters.GaussianSharpen).Size      = gaussianSize;
                (filter as Accord.Imaging.Filters.GaussianSharpen).Threshold = gaussianThreshold;
                dst = filter.Apply(dst);
                break;

            case SharpenMode.GDI:
                var effect = new SharpenEffect(gdiRatio, gdiAmount);
                dst.ApplyEffect(effect, new Rectangle(0, 0, dst.Width, dst.Height));
                break;
            }
            AddinUtils.CloneExif(image, dst);
            return(dst);
        }
Пример #7
0
        static void Main(string[] args)
        {
            using (var ofd = new OpenFileDialog())
            {
                ofd.ShowDialog();
                var          bmp    = new Bitmap(ofd.FileName);
                List <Color> pixels = GetAllPixels(bmp);

                //bmp.ApplyEffect(MakeThingsBlack);
                bmp.ApplyEffect(LightenUp);

                using (var fbd = new FolderBrowserDialog())
                {
                    fbd.ShowDialog();
                    fbd.ShowNewFolderButton = true;
                    bmp.Save(fbd.SelectedPath + "\\" + ofd.SafeFileName);
                }

                Console.WriteLine("Done, pixel count is " + pixels.Count);
                Console.ReadKey();
            }
        }
Пример #8
0
        /// <summary>
        /// Repaints the form's surface.  This is used to draw text onto the form's
        /// transparent surface, showing the desktop background behind the text.  A
        /// blur effect is used to slightly darken the background before the text is
        /// drawn.
        /// </summary>
        /// <param name="sender">The form (unused)</param>
        /// <param name="e">The paint event details (unused - we repaint everything)</param>
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            using (var font = new Font("Segoe UI", 14, FontStyle.Bold))
            {
                using (var format = new StringFormat())
                {
                    var bm          = new Bitmap(550, 60);
                    var effect      = new BlurEffect(4.0f, false);
                    var g           = Graphics.FromImage(bm);
                    var imgPoint    = new Point(140, 70);
                    var screenPoint = PointToScreen(imgPoint);
                    g.CopyFromScreen(screenPoint, new Point(0, 0), new Size(bm.Width, bm.Height));

                    g.DrawString(_title, font, Brushes.Black, 10, 10);
                    bm.ApplyEffect(effect, Rectangle.Empty);
                    g.DrawString(_title, font, Brushes.White, 10, 10);

                    e.Graphics.DrawImage(bm, 140, 70, bm.Width, bm.Height);
                    g.Dispose();
                    bm.Dispose();
                }
            }
        }