private void HandlePixbufLoaded(FSpot.PixbufCache Cache, FSpot.PixbufCache.CacheEntry entry)
        {
            Gdk.Pixbuf result = entry.ShallowCopyPixbuf();
            int        order  = (int)entry.Data;

            if (result == null)
            {
                return;
            }

            // We have to do the scaling here rather than on load because we need to preserve the
            // Pixbuf option iformation to verify the thumbnail validity later
            int width, height;

            PixbufUtils.Fit(result, ThumbnailWidth, ThumbnailHeight, false, out width, out height);
            if (result.Width > width && result.Height > height)
            {
                //  Log.Debug ("scaling");
                Gdk.Pixbuf temp = PixbufUtils.ScaleDown(result, width, height);
                result.Dispose();
                result = temp;
            }
            else if (result.Width < ThumbnailWidth && result.Height < ThumbnailHeight)
            {
                // FIXME this is a workaround to handle images whose actual size is smaller than
                // the thumbnail size, it needs to be fixed at a different level.
                Gdk.Pixbuf temp = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, true, 8, ThumbnailWidth, ThumbnailHeight);
                temp.Fill(0x00000000);
                result.CopyArea(0, 0,
                                result.Width, result.Height,
                                temp,
                                (temp.Width - result.Width) / 2,
                                temp.Height - result.Height);

                result.Dispose();
                result = temp;
            }

            Cache.Update(entry, result);
            InvalidateCell(order);
        }
예제 #2
0
 void HandleEditableTagSelected(Tag tag)
 {
     options.EditableTag   = tag;
     tag_edit_button.Label = tag.Name;
     tag_edit_button.Image = tag.Icon != null ? new Gtk.Image(PixbufUtils.ScaleDown(tag.Icon, 16, 16)) : null;
 }