[gthumb] use the SCALE_FILTER_BOX filter to scale thumbails
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] use the SCALE_FILTER_BOX filter to scale thumbails
- Date: Sun, 30 Jun 2013 08:40:23 +0000 (UTC)
commit 8a38213a8e8ce23b404cd945ed586a3ee9fbbfb5
Author: Paolo Bacchilega <paobac src gnome org>
Date: Mon Jun 24 21:56:55 2013 +0200
use the SCALE_FILTER_BOX filter to scale thumbails
the box filter is fast and gives good quality when scaling big images to
thumbnails.
gthumb/gth-thumb-loader.c | 28 +++++++++++++++++++---------
1 files changed, 19 insertions(+), 9 deletions(-)
---
diff --git a/gthumb/gth-thumb-loader.c b/gthumb/gth-thumb-loader.c
index e8638c7..63d7ef2 100644
--- a/gthumb/gth-thumb-loader.c
+++ b/gthumb/gth-thumb-loader.c
@@ -29,6 +29,7 @@
#define GDK_PIXBUF_ENABLE_BACKEND
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
+#include "cairo-scale.h"
#include "cairo-utils.h"
#include "gio-utils.h"
#include "glib-utils.h"
@@ -419,6 +420,15 @@ normalize_thumb (int *width,
}
+static cairo_surface_t *
+_cairo_image_surface_scale_for_thumbnail (cairo_surface_t *image,
+ int new_width,
+ int new_height)
+{
+ return _cairo_image_surface_scale (image, new_width, new_height, SCALE_FILTER_BOX, NULL);
+}
+
+
static void
cache_image_ready_cb (GObject *source_object,
GAsyncResult *res,
@@ -468,9 +478,9 @@ cache_image_ready_cb (GObject *source_object,
self->priv->requested_size,
self->priv->cache_max_size);
if (modified) {
- GdkPixbuf *tmp = pixbuf;
- pixbuf = _gdk_pixbuf_scale_simple_safe (tmp, width, height, GDK_INTERP_BILINEAR);
- g_object_unref (tmp);
+ cairo_surface_t *tmp = surface;
+ surface = _cairo_image_surface_scale_for_thumbnail (tmp, width, height);
+ cairo_surface_destroy (tmp);
}
load_result = g_new0 (LoadResult, 1);
@@ -572,9 +582,9 @@ original_image_loaded_correctly (GthThumbLoader *self,
self->priv->cache_max_size,
FALSE);
if (modified) {
- GdkPixbuf *tmp = local_pixbuf;
- local_pixbuf = _gdk_pixbuf_scale_simple_safe (tmp, width, height,
GDK_INTERP_BILINEAR);
- g_object_unref (tmp);
+ cairo_surface_t *tmp = local_image;
+ local_image = _cairo_image_surface_scale_for_thumbnail (tmp, width, height);
+ cairo_surface_destroy (tmp);
}
_gth_thumb_loader_save_to_cache (self, load_data->file_data, local_image);
@@ -587,9 +597,9 @@ original_image_loaded_correctly (GthThumbLoader *self,
self->priv->requested_size,
self->priv->cache_max_size);
if (modified) {
- GdkPixbuf *tmp = local_pixbuf;
- local_pixbuf = _gdk_pixbuf_scale_simple_safe (tmp, width, height, GDK_INTERP_BILINEAR);
- g_object_unref (tmp);
+ cairo_surface_t *tmp = local_image;
+ local_image = _cairo_image_surface_scale_for_thumbnail (tmp, width, height);
+ cairo_surface_destroy (tmp);
}
load_result = g_new0 (LoadResult, 1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]