Bug 663955 - Instead of decoding twice, use gdk_pixbuf_get_file_info to get the image width and height; then if either is larger than 180, call gdk_pixbuf_new_from_file_at_size, otherwise call gdk_pixbuf_new_from_file. r=roc

--HG--
extra : transplant_source : n%B2%BC%C2Ov%21%EC%8B%ADF6%DC%DD%19v%B6%E1%97%B8
This commit is contained in:
Rodd Zurcher 2011-06-14 05:56:32 +02:00
Родитель a52bb595df
Коммит f7ee7f3c8b
1 изменённых файлов: 17 добавлений и 6 удалений

Просмотреть файл

@ -136,19 +136,30 @@ UpdateFilePreviewWidget(GtkFileChooser *file_chooser,
return;
}
// We do this so GTK scales down images that are too big, but not scale up images that are too small
GdkPixbuf *preview_pixbuf = gdk_pixbuf_new_from_file(image_filename, NULL);
if (!preview_pixbuf) {
gint preview_width = 0;
gint preview_height = 0;
GdkPixbufFormat *preview_format = gdk_pixbuf_get_file_info(image_filename,
&preview_width,
&preview_height);
if (!preview_format) {
g_free(image_filename);
gtk_file_chooser_set_preview_widget_active(file_chooser, FALSE);
return;
}
if (gdk_pixbuf_get_width(preview_pixbuf) > MAX_PREVIEW_SIZE || gdk_pixbuf_get_height(preview_pixbuf) > MAX_PREVIEW_SIZE) {
g_object_unref(preview_pixbuf);
preview_pixbuf = gdk_pixbuf_new_from_file_at_size(image_filename, MAX_PREVIEW_SIZE, MAX_PREVIEW_SIZE, NULL);
GdkPixbuf *preview_pixbuf;
// Only scale down images that are too big
if (preview_width > MAX_PREVIEW_SIZE || preview_height > MAX_PREVIEW_SIZE) {
preview_pixbuf = gdk_pixbuf_new_from_file_at_size(image_filename,
MAX_PREVIEW_SIZE,
MAX_PREVIEW_SIZE, NULL);
}
else {
preview_pixbuf = gdk_pixbuf_new_from_file(image_filename, NULL);
}
g_free(image_filename);
if (!preview_pixbuf) {
gtk_file_chooser_set_preview_widget_active(file_chooser, FALSE);
return;