Esempio n. 1
0
        private void UpdateImage()
        {
            FSpot.IBrowsableItem item = view.Collection [Item];

            string orig_path = item.DefaultVersionUri.LocalPath;

            Gdk.Pixbuf pixbuf = PixbufUtils.ShallowCopy(preview_cache.Get(orig_path + show_histogram.ToString()));
            if (pixbuf == null)
            {
                // A bizarre pixbuf = hack to try to deal with cinematic displays, etc.
                int preview_size = ((this.Screen.Width + this.Screen.Height) / 2) / 3;
                try {
                    if (item is Photo)
                    {
                        pixbuf = FSpot.PhotoLoader.LoadAtMaxSize((Photo)item, preview_size, preview_size);
                    }
                    else
                    {
                        pixbuf = PixbufUtils.LoadAtMaxSize(orig_path, preview_size, preview_size);
                    }
                } catch (Exception) {
                    pixbuf = null;
                }

                if (pixbuf != null)
                {
                    preview_cache.Add(orig_path + show_histogram.ToString(), pixbuf);
                    AddHistogram(pixbuf);
                    image.Pixbuf = pixbuf;
                }
                else
                {
                    image.Pixbuf = PixbufUtils.ErrorPixbuf;
                }
            }
            else
            {
                image.Pixbuf = pixbuf;
                pixbuf.Dispose();
            }

            string desc = String.Empty;

            if (item.Description != null && item.Description.Length > 0)
            {
                desc = item.Description + Environment.NewLine;
            }

            desc      += item.Time.ToString() + "   " + item.Name;
            label.Text = desc;
        }
Esempio n. 2
0
        void UpdateImage()
        {
            var item = view.Collection [Item];

            string orig_path = item.DefaultVersion.Uri.LocalPath;

            var pixbuf = Utils.PixbufUtils.ShallowCopy(preview_cache.Get(orig_path + show_histogram));

            if (pixbuf == null)
            {
                // A bizarre pixbuf = hack to try to deal with cinematic displays, etc.
                int preview_size = ((Screen.Width + Screen.Height) / 2) / 3;
                try {
                    pixbuf = PhotoLoader.LoadAtMaxSize(item, preview_size, preview_size);
                } catch (Exception) {
                    pixbuf = null;
                }

                if (pixbuf != null)
                {
                    preview_cache.Add(orig_path + show_histogram, pixbuf);
                    AddHistogram(pixbuf);
                    image.Pixbuf = pixbuf;
                }
                else
                {
                    image.Pixbuf = PixbufUtils.ErrorPixbuf;
                }
            }
            else
            {
                image.Pixbuf = pixbuf;
                pixbuf.Dispose();
            }

            string desc = string.Empty;

            if (!string.IsNullOrEmpty(item.Description))
            {
                desc = item.Description + Environment.NewLine;
            }

            desc      += item.Time + "   " + item.Name;
            label.Text = desc;
        }
Esempio n. 3
0
        protected virtual Pixbuf GetPixbuf(int i, bool highlighted)
        {
            Pixbuf  current = null;
            SafeUri uri     = (selection.Collection [i]).DefaultVersion.Uri;

            try {
                var pixbuf = thumb_cache.Get(uri);
                if (pixbuf != null)
                {
                    current = pixbuf.ShallowCopy();
                }
            } catch (IndexOutOfRangeException) {
                current = null;
            }

            if (current == null)
            {
                var pixbuf = XdgThumbnailSpec.LoadThumbnail(uri, ThumbnailSize.Large, null);
                if (pixbuf == null)
                {
                    ThumbnailLoader.Default.Request(uri, ThumbnailSize.Large, 0);
                    current = FSpot.Core.Global.IconTheme.LoadIcon("gtk-missing-image", ThumbSize, (IconLookupFlags)0);
                }
                else
                {
                    if (SquaredThumbs)
                    {
                        current = PixbufUtils.IconFromPixbuf(pixbuf, ThumbSize);
                    }
                    else
                    {
                        current = pixbuf.ScaleSimple(ThumbSize, ThumbSize, InterpType.Nearest);
                    }
                    pixbuf.Dispose();
                    thumb_cache.Add(uri, current);
                }
            }

            //FIXME: we might end up leaking a pixbuf here
            Cms.Profile screen_profile;
            if (ColorManagement.Profiles.TryGetValue(Preferences.Get <string> (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE), out screen_profile))
            {
                Pixbuf t = current.Copy();
                current = t;
                ColorManagement.ApplyProfile(current, screen_profile);
            }

            // Add a four pixel white border around the thumbnail
            // for some reason we cannot use "using" here, it looks like the pixbuf copy is not done properly
            Pixbuf whiteBorder = new Pixbuf(Colorspace.Rgb, true, 8, current.Width, current.Height);

            whiteBorder.Fill(0);
            current.CopyArea(1, 1, current.Width - 8, current.Height - 8, whiteBorder, 4, 4);
            current = whiteBorder;

            if (!highlighted)
            {
                return(current);
            }

            Pixbuf highlight = new Pixbuf(Colorspace.Rgb, true, 8, current.Width, current.Height);

            highlight.Fill(ColorToInt(Style.Light(StateType.Selected)));

            // Add a two pixel highlight around the thumbnail
            current.CopyArea(2, 2, current.Width - 4, current.Height - 4, highlight, 2, 2);

            return(highlight);
        }