SaveVersion() public method

public SaveVersion ( Gdk buffer, bool create_version ) : uint
buffer Gdk
create_version bool
return uint
Ejemplo n.º 1
0
        private void HandleOkClicked(object sender, EventArgs args)
        {
            Photo photo = view.Item.Current as Photo;

            if (photo == null)
            {
                return;
            }

            try {
                Gdk.Pixbuf orig  = view.Pixbuf;
                Gdk.Pixbuf final = PixbufUtils.UnsharpMask(orig,
                                                           radius_spin.Value,
                                                           amount_spin.Value,
                                                           threshold_spin.Value);

                bool create_version = photo.DefaultVersion.IsProtected;

                photo.SaveVersion(final, create_version);
            } catch (System.Exception e) {
                string msg  = Catalog.GetString("Error saving sharpened photo");
                string desc = String.Format(Catalog.GetString("Received exception \"{0}\". Unable to save photo {1}"),
                                            e.Message, photo.Name);

                HigMessageDialog md = new HigMessageDialog(this, DialogFlags.DestroyWithParent,
                                                           Gtk.MessageType.Error,
                                                           ButtonsType.Ok,
                                                           msg,
                                                           desc);
                md.Run();
                md.Destroy();
            }

            Destroy();
        }
Ejemplo n.º 2
0
        public void Save()
        {
            if (!Changed)
            {
                this.Dialog.Destroy();
                return;
            }

            if (!view.Item.IsValid)
            {
                return;
            }

            Console.WriteLine("Saving....");

            Photo photo = (Photo)view.Item.Current;

            try {
                bool create_version = photo.DefaultVersionId == Photo.OriginalVersionId;

                Gdk.Pixbuf orig  = view.CompletePixbuf();
                Gdk.Pixbuf final = new Gdk.Pixbuf(Gdk.Colorspace.Rgb,
                                                  false, 8,
                                                  orig.Width,
                                                  orig.Height);

                Cms.Profile abs = AdjustmentProfile();

                // FIXME this shouldn't use the screen as the destination profile.
                Cms.Profile destination = Cms.Profile.GetScreenProfile(view.Screen);
                if (destination == null)
                {
                    destination = Cms.Profile.CreateStandardRgb();
                }

                Cms.Profile [] list      = new Cms.Profile [] { image_profile, abs, destination };
                Cms.Transform  transform = new Cms.Transform(list,
                                                             PixbufUtils.PixbufCmsFormat(orig),
                                                             PixbufUtils.PixbufCmsFormat(final),
                                                             Cms.Intent.Perceptual, 0x0000);

                PixbufUtils.ColorAdjust(orig,
                                        final,
                                        transform);

                photo.SaveVersion(final, create_version);
                ((PhotoQuery)view.Query).Commit(view.Item.Index);
                final.Dispose();
            } catch (System.Exception e) {
                string msg  = Catalog.GetString("Error saving adjusted photo");
                string desc = String.Format(Catalog.GetString("Received exception \"{0}\". Unable to save photo {1}"),
                                            e.Message, photo.Name);

                HigMessageDialog md = new HigMessageDialog((Gtk.Window)Dialog.Toplevel,
                                                           DialogFlags.DestroyWithParent,
                                                           Gtk.MessageType.Error, ButtonsType.Ok,
                                                           msg,
                                                           desc);
                md.Run();
                md.Destroy();
            }

            this.Dialog.Sensitive = false;
            this.Dialog.Destroy();
        }
Ejemplo n.º 3
0
        // FIXME this design sucks, I'm just doing it this way while
        // I redesign the editing system.
        private void ProcessImage(bool redeye)
        {
            int x, y, width, height;

            if (!photo_view.GetSelection(out x, out y, out width, out height))
            {
                string msg  = Catalog.GetString("No selection available");
                string desc = Catalog.GetString("This tool requires an active selection. Please select a region of the photo and try the operation again");

                HigMessageDialog md = new HigMessageDialog((Gtk.Window) this.Toplevel, DialogFlags.DestroyWithParent,
                                                           Gtk.MessageType.Error, ButtonsType.Ok,
                                                           msg,
                                                           desc);

                md.Run();
                md.Destroy();
                return;
            }

            Photo photo = (Photo)Item.Current;

            try {
                Pixbuf original_pixbuf = photo_view.CompletePixbuf();
                if (original_pixbuf == null)
                {
                    return;
                }

                Pixbuf edited;
                if (redeye)
                {
                    Gdk.Rectangle area = new Gdk.Rectangle(x, y, width, height);
                    edited = PixbufUtils.RemoveRedeye(original_pixbuf,
                                                      area,
                                                      (int)Preferences.Get(Preferences.EDIT_REDEYE_THRESHOLD));
                }
                else             // Crop (I told you it was ugly)
                {
                    edited = new Pixbuf(original_pixbuf.Colorspace,
                                        original_pixbuf.HasAlpha, original_pixbuf.BitsPerSample,
                                        width, height);

                    original_pixbuf.CopyArea(x, y, width, height, edited, 0, 0);
                }

                bool create_version = photo.DefaultVersionId == Photo.OriginalVersionId;
                photo.SaveVersion(edited, create_version);
                ((PhotoQuery)query).Commit(Item.Index);

                // FIXME the fact that the selection doesn't go away is a bug in ImageView, it should
                // be fixed there.
                photo_view.Pixbuf = edited;
                original_pixbuf.Dispose();
                photo_view.UnsetSelection();

                photo_view.Fit = true;

                if (PhotoChanged != null)
                {
                    PhotoChanged(this);
                }
            } catch (System.Exception e) {
                ShowError(e, photo);
            }
        }