示例#1
0
        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
        public void Apply(Context ctx, Gdk.Rectangle allocation)
        {
            SurfacePattern p = new SurfacePattern(info.Surface);

            ctx.Matrix = new Matrix();
            Matrix m = info.Fit(allocation);

            ctx.Operator = Operator.Over;
            ctx.Matrix   = m;
            ctx.Source   = p;
            ctx.Paint();

            SurfacePattern overlay = new SurfacePattern(blur.Surface);

            ctx.Matrix   = new Matrix();
            ctx.Matrix   = blur.Fit(allocation);
            ctx.Operator = Operator.Over;
            ctx.Source   = overlay;

            // FIXME ouch this is ugly.
            if (mask == null)
            {
                Radius = Radius;
            }

            //ctx.Paint ();
            ctx.Mask(mask);
            overlay.Destroy();
            p.Destroy();
        }
		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));

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

			Context ctx = new Context (image);
			//Pattern solid = new SolidPattern (0, 0, 0, 0);
			//ctx.Source = solid;
			//ctx.Paint ();
			//solid.Destroy ();
			ctx.Matrix = source.Fit (small);
			ctx.Operator = Operator.Source;
			Pattern p = new SurfacePattern (source.Surface);
			ctx.Source = p;
			//Log.Debug (small);
			ctx.Paint ();
			p.Destroy ();
			((IDisposable)ctx).Dispose ();
			Gdk.Pixbuf normal = MemorySurface.CreatePixbuf (image);
			Gdk.Pixbuf blur = PixbufUtils.Blur (normal, 3);
			ImageInfo overlay = new ImageInfo (blur);
			blur.Dispose ();
			normal.Dispose ();
			image.Destroy ();
			return overlay;
		}
示例#4
0
        public void Apply(Context ctx, Gdk.Rectangle allocation)
        {
            var p = new SurfacePattern(info.Surface);

            ctx.Matrix = new Matrix();
            var m = info.Fit(allocation);

            ctx.Operator = Operator.Over;
            ctx.Matrix   = m;
            ctx.SetSource(p);
            ctx.Paint();

            var overlay = new SurfacePattern(blur.Surface);

            ctx.Matrix   = new Matrix();
            ctx.Matrix   = blur.Fit(allocation);
            ctx.Operator = Operator.Over;
            ctx.SetSource(overlay);

            // FIXME ouch this is ugly.
            if (mask == null)
            {
                Radius = Radius;
            }

            //ctx.Paint ();
            ctx.Mask(mask);
            overlay.Dispose();
            p.Dispose();
        }
示例#5
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);
        }
示例#6
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);

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

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

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

            image.Dispose ();
            return overlay;
        }