[gimp/soc-2010-cage] app: use gegl:scale for scaling if use-gegl is TRUE
- From: Michael Muré <mmure src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/soc-2010-cage] app: use gegl:scale for scaling if use-gegl is TRUE
- Date: Wed, 30 Jun 2010 22:07:12 +0000 (UTC)
commit 617a3064d04c7cc736b1379f58d7d8da579c0ef8
Author: Michael Natterer <mitch gimp org>
Date: Sun Jun 6 19:54:44 2010 +0200
app: use gegl:scale for scaling if use-gegl is TRUE
app/core/gimpdrawable.c | 75 +++++++++++++++++++++++++++++++++-------------
1 files changed, 54 insertions(+), 21 deletions(-)
---
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index 887769c..35db04c 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -33,10 +33,14 @@
#include "paint-funcs/paint-funcs.h"
#include "paint-funcs/scale-region.h"
+#include "gegl/gimp-gegl-utils.h"
+
+#include "gimp.h" /* temp for gimp_use_gegl() */
#include "gimpchannel.h"
#include "gimpcontext.h"
#include "gimpdrawable-combine.h"
#include "gimpdrawable-convert.h"
+#include "gimpdrawable-operation.h"
#include "gimpdrawable-preview.h"
#include "gimpdrawable-private.h"
#include "gimpdrawable-shadow.h"
@@ -453,30 +457,59 @@ gimp_drawable_scale (GimpItem *item,
{
GimpDrawable *drawable = GIMP_DRAWABLE (item);
TileManager *new_tiles;
- PixelRegion srcPR, destPR;
new_tiles = tile_manager_new (new_width, new_height, drawable->bytes);
- pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
- 0, 0,
- gimp_item_get_width (item),
- gimp_item_get_height (item),
- FALSE);
- pixel_region_init (&destPR, new_tiles,
- 0, 0,
- new_width, new_height,
- TRUE);
+ if (gimp_use_gegl (gimp_item_get_image (item)->gimp) &&
+ ! gimp_drawable_is_indexed (drawable) &&
+ interpolation_type != GIMP_INTERPOLATION_LANCZOS)
+ {
+ GeglNode *scale;
+
+ scale = g_object_new (GEGL_TYPE_NODE,
+ "operation", "gegl:scale",
+ NULL);
+
+ gegl_node_set (scale,
+ "origin-x", 0.0,
+ "origin-y", 0.0,
+ "filter", gimp_interpolation_to_gegl_filter (interpolation_type),
+ "hard-edges", FALSE,
+ "x", ((gdouble) new_width /
+ gimp_item_get_width (item)),
+ "y", ((gdouble) new_height /
+ gimp_item_get_height (item)),
+ NULL);
- /* Scale the drawable -
- * If the drawable is indexed, then we don't use pixel-value
- * resampling because that doesn't necessarily make sense for indexed
- * images.
- */
- scale_region (&srcPR, &destPR,
- gimp_drawable_is_indexed (drawable) ?
- GIMP_INTERPOLATION_NONE : interpolation_type,
- progress ? gimp_progress_update_and_flush : NULL,
- progress);
+ gimp_drawable_apply_operation_to_tiles (drawable, progress, _("Scale"),
+ scale, TRUE, new_tiles);
+ g_object_unref (scale);
+ }
+ else
+ {
+ PixelRegion srcPR, destPR;
+
+ pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
+ 0, 0,
+ gimp_item_get_width (item),
+ gimp_item_get_height (item),
+ FALSE);
+ pixel_region_init (&destPR, new_tiles,
+ 0, 0,
+ new_width, new_height,
+ TRUE);
+
+ /* Scale the drawable -
+ * If the drawable is indexed, then we don't use pixel-value
+ * resampling because that doesn't necessarily make sense for indexed
+ * images.
+ */
+ scale_region (&srcPR, &destPR,
+ gimp_drawable_is_indexed (drawable) ?
+ GIMP_INTERPOLATION_NONE : interpolation_type,
+ progress ? gimp_progress_update_and_flush : NULL,
+ progress);
+ }
gimp_drawable_set_tiles_full (drawable, gimp_item_is_attached (item), NULL,
new_tiles, gimp_drawable_type (drawable),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]