Exemple #1
0
        //FIXME: Won't work on non-file uris
        void WriteMetadataToImage(Photo photo)
        {
            string path = photo.DefaultVersionUri.LocalPath;

            using (FSpot.ImageFile img = FSpot.ImageFile.Create(photo.DefaultVersionUri)) {
                if (img is FSpot.JpegFile)
                {
                    FSpot.JpegFile jimg = img as FSpot.JpegFile;

                    jimg.SetDescription(photo.Description);
                    jimg.SetDateTimeOriginal(photo.Time.ToLocalTime());
                    jimg.SetXmp(UpdateXmp(photo, jimg.Header.GetXmp()));

                    jimg.SaveMetaData(path);
                }
                else if (img is FSpot.Png.PngFile)
                {
                    FSpot.Png.PngFile png = img as FSpot.Png.PngFile;

                    if (img.Description != photo.Description)
                    {
                        png.SetDescription(photo.Description);
                    }

                    png.SetXmp(UpdateXmp(photo, png.GetXmp()));

                    png.Save(path);
                }
            }
        }
Exemple #2
0
        private void HandlePhotoChanged(PhotoImageView view)
        {
            try {
                if (!view.Item.IsValid)
                {
                    throw new Exception("Invalid Image");
                }

                using (FSpot.ImageFile img = FSpot.ImageFile.Create(((Photo)view.Item.Current).DefaultVersionUri)) {
                    try {
                        image_profile = img.GetProfile();
                    } catch (System.Exception e) {
                        image_profile = null;
                        System.Console.WriteLine(e);
                    }

                    // FIXME fall back to rgb for now
                    if (image_profile == null)
                    {
                        image_profile = Cms.Profile.CreateStandardRgb();
                    }

                    AdjustedPixbuf = img.Load(256, 256);
                    ScaledPixbuf   = AdjustedPixbuf.Copy();
                }

                if (AdjustedPixbuf.HasAlpha)
                {
                    throw new Exception("Unsupported Alpha Channel");
                }

                control_vbox.Sensitive = true;
                ok_button.Sensitive    = true;

                RangeChanged(null, null);
            } catch (System.Exception) {
                control_vbox.Sensitive = false;
                ok_button.Sensitive    = false;
                AdjustedPixbuf         = null;
                ScaledPixbuf           = null;
                image_profile          = null;
            }
        }