Commit 17961941 authored by Michael Natterer's avatar Michael Natterer 😴

app: use gegl:scale for scaling if use-gegl is TRUE

parent 301b990a
......@@ -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),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment