Ejemplo n.º 1
0
        private void HandleApply(object sender, EventArgs args)
        {
            BrowsablePointer item   = view.Item;
            EditTarget       target = new EditTarget(item);

            try {
                using (ImageFile img = ImageFile.Create(item.Current.DefaultVersionUri)) {
                    Cairo.Format format = view.CompletePixbuf().HasAlpha ? Cairo.Format.Argb32 : Cairo.Format.Rgb24;

                    MemorySurface dest = new MemorySurface(format,
                                                           info.Bounds.Width,
                                                           info.Bounds.Height);

                    Context ctx = new Context(dest);
                    effect.OnExpose(ctx, info.Bounds);
                    ((IDisposable)ctx).Dispose();

                    string tmp = ImageFile.TempPath(item.Current.DefaultVersionUri.LocalPath);
                    using (Gdk.Pixbuf output = Widgets.CairoUtils.CreatePixbuf(dest)) {
                        using (System.IO.Stream stream = System.IO.File.OpenWrite(tmp)) {
                            img.Save(output, stream);
                        }
                    }

                    dest.Destroy();

                    // FIXME Not this again. I need to imlplement a real version of the transfer
                    // function that shows progress in the main window and allows for all the
                    // goodies we'll need.
                    Gnome.Vfs.Result result = Gnome.Vfs.Result.Ok;
                    result = Gnome.Vfs.Xfer.XferUri(new Gnome.Vfs.Uri(UriList.PathToFileUri(tmp).ToString()),
                                                    new Gnome.Vfs.Uri(target.Uri.ToString()),
                                                    Gnome.Vfs.XferOptions.Default,
                                                    Gnome.Vfs.XferErrorMode.Abort,
                                                    Gnome.Vfs.XferOverwriteMode.Replace,
                                                    delegate {
                        System.Console.Write(".");
                        return(1);
                    });

                    target.Commit();
                }
            } catch (System.Exception e) {
                System.Console.WriteLine(e);
                target.Delete();
                Dialog d = new EditExceptionDialog((Gtk.Window)view.Toplevel, e, view.Item.Current);
                d.Show();
                d.Run();
                d.Destroy();
            }
            Destroy();
        }
Ejemplo n.º 2
0
        public static Cairo.ImageSurface PixbufToImageSurface(Gdk.Pixbuf pixbuf)
        {
            Cairo.Format format = Cairo.Format.RGB24;
            if (pixbuf.HasAlpha)
            {
                format = Cairo.Format.ARGB32;
            }

            Cairo.ImageSurface surface = new ImageSurface(format, pixbuf.Width, pixbuf.Height);
            using (Cairo.Context context = new Cairo.Context(surface)) {
                Gdk.CairoHelper.SetSourcePixbuf(context, pixbuf, 0.0, 0.0);
                context.Paint();
            }

            return(surface);
        }
 public QuartzSurface(Cairo.Format format, int width, int height)
     : base(cairo_quartz_surface_create(format, (uint)width, (uint)height), true)
 {
 }
 public static extern IntPtr cairo_quartz_surface_create(Cairo.Format format, uint width, uint height);
Ejemplo n.º 5
0
 public MemorySurface(Cairo.Format format, int width, int height)
     : this(f_image_surface_create(format, width, height))
 {
 }
Ejemplo n.º 6
0
 static extern IntPtr f_image_surface_create(Cairo.Format format, int width, int height);