예제 #1
0
        protected virtual Pixbuf GetPixbuf(int i, bool highlighted)
        {
            string thumb_path;
            Pixbuf current;

            try {
                thumb_path = FSpot.ThumbnailGenerator.ThumbnailPath((selection.Collection [i]).DefaultVersionUri);
                current    = PixbufUtils.ShallowCopy(thumb_cache.Get(thumb_path));
            } catch (IndexOutOfRangeException) {
                thumb_path = null;
                current    = null;
            }

            if (current == null)
            {
                try {
                    ThumbnailGenerator.Default.Request((selection.Collection [i]).DefaultVersionUri, 0, 256, 256);

                    if (SquaredThumbs)
                    {
                        current = new Pixbuf(thumb_path);
                        current = PixbufUtils.IconFromPixbuf(current, ThumbSize);
                    }
                    else
                    {
                        current = new Pixbuf(thumb_path, -1, ThumbSize);
                    }
                    thumb_cache.Add(thumb_path, current);
                } catch {
                    try {
                        current = FSpot.Global.IconTheme.LoadIcon("gtk-missing-image", ThumbSize, (Gtk.IconLookupFlags) 0);
                    } catch {
                        current = null;
                    }
                    thumb_cache.Add(thumb_path, null);
                }
            }

            //FIXME
            if (FSpot.ColorManagement.IsEnabled)
            {
                current = current.Copy();
                FSpot.ColorManagement.ApplyScreenProfile(current);
            }

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

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

            Gdk.Color color = Style.Background(StateType.Selected);
            uint      ucol  = (uint)((uint)color.Red / 256 << 24) + ((uint)color.Green / 256 << 16) + ((uint)color.Blue / 256 << 8) + 255;

            highlight.Fill(ucol);
            current.CopyArea(1, 1, current.Width - 2, current.Height - 2, highlight, 1, 1);
            return(highlight);
        }
예제 #2
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;
        }
예제 #3
0
        public Pixbuf GetThumbnailForPath(string path)
        {
            if (!pixbuf_hash.ContainsKey(path))
            {
                return(null);
            }

            Thumbnail item = pixbuf_hash [path] as Thumbnail;

            pixbuf_mru.Remove(item);
            pixbuf_mru.Insert(0, item);

            return(PixbufUtils.ShallowCopy(item.pixbuf));
        }
예제 #4
0
            public Gdk.Pixbuf ShallowCopyPixbuf()
            {
                lock (this) {
                    if (IsDisposed)
                    {
                        throw new System.Exception("I'm dead");
                    }

                    if (pixbuf == null)
                    {
                        return(null);
                    }

                    return(PixbufUtils.ShallowCopy(pixbuf));
                }
            }
예제 #5
0
            public Gdk.Pixbuf ShallowCopyPixbuf()
            {
                lock (this) {
                    if (IsDisposed)
                    {
                        return(null);
                    }

                    if (pixbuf == null)
                    {
                        return(null);
                    }

                    return(PixbufUtils.ShallowCopy(pixbuf));
                }
            }
예제 #6
0
        private bool PreloadNextImage(int idx)
        {
            try {
                if (idx < photos.Length && idx >= 0)
                {
                    if (next != null)
                    {
                        next.Dispose();
                    }

                    next = GetScaled(photos [idx]);
                    if (next == null)
                    {
                        next = GetScaled(PixbufUtils.ShallowCopy(PixbufUtils.ErrorPixbuf));
                    }

                    next_idx = idx;
                    StartTweenIdle();

                    return(true);
                }
                else
                {
                    if (next != null)
                    {
                        next.Dispose();
                    }

                    next = GetScaled(photos [0]);
                    if (next == null)
                    {
                        next = GetScaled(PixbufUtils.ShallowCopy(PixbufUtils.ErrorPixbuf));
                    }
                    next_idx = 0;
                    StartTweenIdle();

                    return(false);
                }
            } catch (GLib.GException e) {
                System.Console.WriteLine(e);
                idx = (idx + 1) % photos.Length;
                return(PreloadNextImage(idx));
            }
        }