Ejemplo n.º 1
0
        public ImageInfo(ImageInfo info, Widget w, Gdk.Rectangle bounds)
        {
            using (var similar = CairoUtils.CreateSurface(w.GdkWindow)) {
                Bounds  = bounds;
                Surface = similar.CreateSimilar(Content.ColorAlpha, Bounds.Width, Bounds.Height);
                var ctx = new Context(Surface);

                ctx.Matrix = info.Fill(Bounds);
                Pattern p = new SurfacePattern(info.Surface);
                ctx.SetSource(p);
                ctx.Paint();
                ctx.Dispose();
                p.Dispose();
            }
        }
Ejemplo n.º 2
0
        public ImageInfo(ImageInfo info, Widget w, Gdk.Rectangle bounds)
        {
            Cairo.Surface similar = CairoUtils.CreateSurface(w.GdkWindow);
            Bounds  = bounds;
            Surface = similar.CreateSimilar(Content.ColorAlpha, Bounds.Width, Bounds.Height);
            Context ctx = new Context(Surface);

            ctx.Matrix = info.Fill(Bounds);
            Pattern p = new SurfacePattern(info.Surface);

            ctx.Source = p;
            ctx.Paint();
            ((IDisposable)ctx).Dispose();
            p.Destroy();
        }
        protected override bool OnExposeEvent(EventExpose args)
        {
            bool double_buffer = false;

            base.OnExposeEvent(args);

            Context ctx = CairoUtils.CreateContext(GdkWindow);

            //Surface glitz = CairoUtils.CreateGlitzSurface (GdkWindow);
            //Context ctx = new Context (glitz);
            if (double_buffer)
            {
                ImageSurface cim = new ImageSurface(Format.RGB24,
                                                    Allocation.Width,
                                                    Allocation.Height);

                Context buffer = new Context(cim);
                OnExpose(buffer, args.Region);

                SurfacePattern sur = new SurfacePattern(cim);
                sur.Filter = Filter.Fast;
                ctx.Source = sur;
                SetClip(ctx, args.Region);

                ctx.Paint();

                ((IDisposable)buffer).Dispose();
                ((IDisposable)cim).Dispose();
                sur.Destroy();
            }
            else
            {
                OnExpose(ctx, args.Region);
            }

            //glitz.Flush ();
            ((IDisposable)ctx).Dispose();
            return(true);
        }
Ejemplo n.º 4
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;
            Console.WriteLine(small);
            ctx.Paint();
            p.Destroy();
            ((IDisposable)ctx).Dispose();
            Gdk.Pixbuf normal  = CairoUtils.CreatePixbuf(image);
            Gdk.Pixbuf blur    = PixbufUtils.Blur(normal, 3);
            ImageInfo  overlay = new ImageInfo(blur);

            blur.Dispose();
            normal.Dispose();
            image.Destroy();
            return(overlay);
        }
Ejemplo n.º 5
0
 private void SetPixbuf(Pixbuf pixbuf)
 {
     Surface       = CairoUtils.CreateSurface(pixbuf);
     Bounds.Width  = pixbuf.Width;
     Bounds.Height = pixbuf.Height;
 }