Exemple #1
0
        // Grab thumbnail
        public Pixbuf Thumbnail()
        {
            string		existing;

            // Totaly ignore removed wps
            if (removed)
                return null;

            // Cached thumb nail? Just make sure it's current
            if (ThumbCache != null && HasCurrentThumbnail() == true)
                return ThumbCache;
            else
                ThumbCache = null;

            // Attempt to create a new thumbnail (or at least check if there is an old valid one)
            if (CreateThumnail() == false)
                return null;

            ThumbnailFactory t = new ThumbnailFactory(ThumbnailSize.Normal);

            // Grab the thumb
            existing = t.Lookup(filename, CurrentMtime);
            Pixbuf thumb = new Pixbuf(existing);

            // Figure out the scale for previews
            int x, y;
            switch (Res.ResolutionList.AspectType(w,h)) {
            case Res.Aspect.ASPECT_43:
                x = 64;
                y = 48;
                break;
            case Res.Aspect.ASPECT_WIDE:
                x = 64;
                y = 36;
                break;
            case Res.Aspect.ASPECT_OTHER:
            default:
                x = 64;
                y = 64;
                break;
            }

            // for really small images, do our own resizing; hopefully there won't be too many
            if (thumb.Width < x || thumb.Height < y) {
                ThumbCache = thumb.ScaleSimple(x, y, Gdk.InterpType.Bilinear);
            } else {
                ThumbCache = Gnome.Thumbnail.ScaleDownPixbuf(thumb, x, y);
            }

            thumb.Dispose();
            return ThumbCache;
        }