Blur() public static method

public static Blur ( Pixbuf src, int radius, FSpot.UI.Dialog.ThreadProgressDialog dialog ) : Pixbuf
src Pixbuf
radius int
dialog FSpot.UI.Dialog.ThreadProgressDialog
return Pixbuf
コード例 #1
0
ファイル: SoftFocus.cs プロジェクト: neuroradiology/f-spot
        private ImageInfo CreateBlur(ImageInfo source)
        {
            double scale = Math.Max(256 / (double)source.Bounds.Width,
                                    256 / (double)source.Bounds.Height);

            Gdk.Rectangle small = new Gdk.Rectangle(0, 0,
                                                    (int)Math.Ceiling(source.Bounds.Width * scale),
                                                    (int)Math.Ceiling(source.Bounds.Height * scale));

            ImageSurface image = new ImageSurface(Format.Argb32,
                                                  small.Width,
                                                  small.Height);

            Context ctx = new Context(image);

            ctx.Matrix   = source.Fit(small);
            ctx.Operator = Operator.Source;
            Pattern p = new SurfacePattern(source.Surface);

            ctx.Source = p;

            ctx.Paint();
            p.Destroy();
            ((IDisposable)ctx).Dispose();
            Gdk.Pixbuf normal = image.ToPixbuf();

            Gdk.Pixbuf blur = PixbufUtils.Blur(normal, 3, null);

            ImageInfo overlay = new ImageInfo(blur);

            blur.Dispose();
            normal.Dispose();
            image.Destroy();
            return(overlay);
        }
コード例 #2
0
        ImageInfo CreateBlur(ImageInfo source)
        {
            double scale = Math.Max(256 / (double)source.Bounds.Width,
                                    256 / (double)source.Bounds.Height);

            var small = new Gdk.Rectangle(0, 0,
                                          (int)Math.Ceiling(source.Bounds.Width * scale),
                                          (int)Math.Ceiling(source.Bounds.Height * scale));

            var image = new ImageSurface(Format.Argb32,
                                         small.Width,
                                         small.Height);

            var ctx = new Context(image)
            {
                Matrix   = source.Fit(small),
                Operator = Operator.Source
            };
            Pattern p = new SurfacePattern(source.Surface);

            ctx.SetSource(p);

            ctx.Paint();
            p.Dispose();
            ctx.Dispose();

            ImageInfo overlay;

            using (var normal = image.ToPixbuf())
            {
                using (var pixbufBlur = PixbufUtils.Blur(normal, 3, null))
                {
                    overlay = new ImageInfo(pixbufBlur);
                }
            }

            image.Dispose();
            return(overlay);
        }