예제 #1
0
파일: TiltEditor.cs 프로젝트: GNOME/f-spot
 private Pixbuf ProcessImpl(Pixbuf input, Cms.Profile input_profile, bool fast)
 {
     Pixbuf result;
     using (ImageInfo info = new ImageInfo (input)) {
         using (ImageSurface surface = new ImageSurface (Format.Argb32,
                                input.Width,
                                input.Height)) {
             using (Context ctx = new Context (surface)) {
                 ctx.Matrix = info.Fill (info.Bounds, angle);
                 using (SurfacePattern p = new SurfacePattern (info.Surface)) {
                     if (fast)
                         p.Filter =  Filter.Fast;
                     ctx.Source = p;
                     ctx.Paint ();
                 }
                 result = surface.ToPixbuf();
                 surface.Flush ();
             }
         }
     }
     return result;
 }
예제 #2
0
        private void HandlerPintaCoreActionsEditCopyActivated(object sender, EventArgs e)
        {
            PintaCore.Layers.FinishSelection ();

            ImageSurface src = PintaCore.Layers.GetClippedLayer (PintaCore.Layers.CurrentLayerIndex);

            Cairo.Rectangle rect = PintaCore.Layers.SelectionPath.GetBounds ();

            ImageSurface dest = new ImageSurface (Format.Argb32, (int)rect.Width, (int)rect.Height);

            using (Context g = new Context (dest)) {
                g.SetSourceSurface (src, -(int)rect.X, -(int)rect.Y);
                g.Paint ();
            }

            Gtk.Clipboard cb = Gtk.Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false));
            cb.Image = dest.ToPixbuf ();

            (src as IDisposable).Dispose ();
            (dest as IDisposable).Dispose ();
        }
예제 #3
0
        private void HandlerPintaCoreActionsEditCopyActivated(object sender, EventArgs e)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            PintaCore.Tools.Commit ();

            ImageSurface src = doc.GetClippedLayer (doc.CurrentLayerIndex);

            Gdk.Rectangle rect = doc.GetSelectedBounds (true);

            ImageSurface dest = new ImageSurface (Format.Argb32, rect.Width, rect.Height);

            using (Context g = new Context (dest)) {
                g.SetSourceSurface (src, -rect.X, -rect.Y);
                g.Paint ();
            }

            Gtk.Clipboard cb = Gtk.Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false));
            cb.Image = dest.ToPixbuf ();

            (src as IDisposable).Dispose ();
            (dest as IDisposable).Dispose ();
        }
예제 #4
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;
        }
예제 #5
0
        private void HandlerPintaCoreActionsEditCopyMergedActivated(object sender, EventArgs e)
        {
            var cb = Gtk.Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false));
            var doc = PintaCore.Workspace.ActiveDocument;

            PintaCore.Tools.Commit ();

            // Get our merged ("flattened") image
            using (var src = doc.GetFlattenedImage ()) {
                var rect = doc.GetSelectedBounds (true);

                // Copy it to a correctly sized surface
                using (var dest = new ImageSurface (Format.Argb32, rect.Width, rect.Height)) {
                    using (Context g = new Context (dest)) {
                        g.SetSourceSurface (src, -rect.X, -rect.Y);
                        g.Paint ();
                    }

                    // Give it to the clipboard
                    cb.Image = dest.ToPixbuf ();
                }
            }
        }
예제 #6
0
파일: PixbufUtils.cs 프로젝트: GNOME/f-spot
    public static Pixbuf Blur(Pixbuf src, int radius, ThreadProgressDialog dialog)
    {
        ImageSurface sourceSurface = Hyena.Gui.PixbufImageSurface.Create (src);
        ImageSurface destinationSurface = new ImageSurface (Format.Rgb24, src.Width, src.Height);

        // If we do it as a bunch of single lines (rectangles of one pixel) then we can give the progress
        // here instead of going deeper to provide the feedback
        for (int i=0; i < src.Height; i++) {
            GaussianBlurEffect.RenderBlurEffect (sourceSurface, destinationSurface, new[] { new Gdk.Rectangle (0, i, src.Width, 1) }, radius);

            if (dialog != null) {
                // This only half of the entire process
                double fraction = ((double)i / (double)(src.Height - 1)) * 0.75;
                dialog.Fraction = fraction;
            }
        }

        return destinationSurface.ToPixbuf ();
    }
        private Pixbuf ProcessImpl(Pixbuf input, Cms.Profile input_profile, bool fast)
        {
            Pixbuf result;
            using (ImageInfo info = new ImageInfo (input)) {
                using (Widgets.SoftFocus soft = new Widgets.SoftFocus (info)) {
                    soft.Radius = radius;

                    using (ImageSurface surface = new ImageSurface (Format.Argb32,
                                           input.Width,
                                           input.Height)) {

                        using (Context ctx = new Context (surface)) {
                            soft.Apply (ctx, info.Bounds);
                        }

                        result = surface.ToPixbuf();
                        surface.Flush ();
                    }
                }
            }
            return result;
        }
        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;
        }