Esempio n. 1
0
        private Pixbuf ProcessImpl(Pixbuf input, Cms.Profile input_profile, bool fast)
        {
            Pixbuf result;

            using (ImageInfo info = new ImageInfo(input)) {
                MemorySurface surface = new MemorySurface(Format.Argb32,
                                                          input.Width,
                                                          input.Height);

                Context ctx = new Context(surface);
                ctx.Matrix = info.Fill(info.Bounds, angle);
                SurfacePattern p = new SurfacePattern(info.Surface);
                if (fast)
                {
                    p.Filter = Filter.Fast;
                }
                ctx.Source = p;
                ctx.Paint();
                ((IDisposable)ctx).Dispose();
                p.Destroy();
                result = MemorySurface.CreatePixbuf(surface);
                surface.Flush();
            }
            return(result);
        }
Esempio n. 2
0
        private Pixbuf ProcessImpl(Pixbuf input, Cms.Profile input_profile, bool fast)
        {
            Pixbuf result;

            using (ImageInfo info = new ImageInfo(input)) {
                Widgets.SoftFocus soft = new Widgets.SoftFocus(info);
                soft.Radius = radius;

                MemorySurface surface = new MemorySurface(Format.Argb32,
                                                          input.Width,
                                                          input.Height);

                Context ctx = new Context(surface);
                soft.Apply(ctx, info.Bounds);
                ((IDisposable)ctx).Dispose();

                result = MemorySurface.CreatePixbuf(surface);
                surface.Flush();
            }
            return(result);
        }
Esempio n. 3
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));

            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);
        }