LoadAtMaxSize() static public method

static public LoadAtMaxSize ( string path, int max_width, int max_height ) : Pixbuf
path string
max_width int
max_height int
return Pixbuf
コード例 #1
0
        private void UpdateImage()
        {
            FSpot.IBrowsableItem item = view.Collection.Items [Item];

            string orig_path = item.DefaultVersionUri.LocalPath;

            Gdk.Pixbuf pixbuf = preview_cache.GetThumbnailForPath(orig_path);
            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.AddThumbnail(orig_path, 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;
        }
コード例 #2
0
    public static void Resize(string orig_path, string dest_path, int size, bool copy_meta)
    {
        Exif.ExifData exif_data;
        if (copy_meta)
        {
            exif_data = new Exif.ExifData(orig_path);
        }
        else
        {
            exif_data = new Exif.ExifData();
        }

        Gdk.Pixbuf image = PixbufUtils.LoadAtMaxSize(orig_path, size, size);

        PixbufUtils.SaveJpeg(image, dest_path, 95, exif_data);
        image.Dispose();
    }