2006-12-09 13:33:38 -08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-24 14:05:25 -08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
2009-01-17 14:28:01 -08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-24 14:05:25 -08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 14:28:01 -08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-24 14:05:25 -08:00
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-11 14:47:19 -07:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1997-11-24 14:05:25 -08:00
|
|
|
*/
|
2000-12-16 13:37:03 -08:00
|
|
|
|
2000-01-14 04:41:00 -08:00
|
|
|
#include "config.h"
|
|
|
|
|
|
1997-11-24 14:05:25 -08:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
2000-01-14 04:41:00 -08:00
|
|
|
|
2013-10-14 16:58:39 -07:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2008-10-09 13:24:04 -07:00
|
|
|
#include <gegl.h>
|
2000-12-16 13:37:03 -08:00
|
|
|
|
2006-03-30 06:04:53 -08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
|
|
2002-02-14 11:31:16 -08:00
|
|
|
#include "paint-types.h"
|
2000-12-16 13:37:03 -08:00
|
|
|
|
2018-05-24 07:21:21 -07:00
|
|
|
#include "gegl/gimp-gegl-loops.h"
|
|
|
|
|
|
2001-07-07 05:17:23 -07:00
|
|
|
#include "core/gimp.h"
|
2001-05-08 19:32:03 -07:00
|
|
|
#include "core/gimpdrawable.h"
|
2009-10-11 06:41:54 -07:00
|
|
|
#include "core/gimpdynamics.h"
|
2008-11-12 02:56:06 -08:00
|
|
|
#include "core/gimperror.h"
|
2001-05-08 19:32:03 -07:00
|
|
|
#include "core/gimpimage.h"
|
|
|
|
|
#include "core/gimppattern.h"
|
2005-08-28 12:17:44 -07:00
|
|
|
#include "core/gimppickable.h"
|
2016-01-27 10:13:17 -08:00
|
|
|
#include "core/gimpsymmetry.h"
|
2001-09-25 16:23:09 -07:00
|
|
|
|
2002-02-14 11:31:16 -08:00
|
|
|
#include "gimpclone.h"
|
2003-02-05 06:39:40 -08:00
|
|
|
#include "gimpcloneoptions.h"
|
2001-04-19 06:01:44 -07:00
|
|
|
|
2003-03-25 08:38:19 -08:00
|
|
|
#include "gimp-intl.h"
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-14 16:23:52 -07:00
|
|
|
|
2000-12-29 07:22:01 -08:00
|
|
|
|
2012-11-01 13:39:14 -07:00
|
|
|
static gboolean gimp_clone_start (GimpPaintCore *paint_core,
|
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
|
GimpPaintOptions *paint_options,
|
|
|
|
|
const GimpCoords *coords,
|
|
|
|
|
GError **error);
|
|
|
|
|
|
|
|
|
|
static void gimp_clone_motion (GimpSourceCore *source_core,
|
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
|
GimpPaintOptions *paint_options,
|
|
|
|
|
const GimpCoords *coords,
|
2016-01-27 10:13:17 -08:00
|
|
|
GeglNode *op,
|
2012-11-01 13:39:14 -07:00
|
|
|
gdouble opacity,
|
|
|
|
|
GimpPickable *src_pickable,
|
|
|
|
|
GeglBuffer *src_buffer,
|
|
|
|
|
GeglRectangle *src_rect,
|
|
|
|
|
gint src_offset_x,
|
|
|
|
|
gint src_offset_y,
|
|
|
|
|
GeglBuffer *paint_buffer,
|
|
|
|
|
gint paint_buffer_x,
|
|
|
|
|
gint paint_buffer_y,
|
|
|
|
|
gint paint_area_offset_x,
|
|
|
|
|
gint paint_area_offset_y,
|
|
|
|
|
gint paint_area_width,
|
|
|
|
|
gint paint_area_height);
|
|
|
|
|
|
|
|
|
|
static gboolean gimp_clone_use_source (GimpSourceCore *source_core,
|
|
|
|
|
GimpSourceOptions *options);
|
2006-09-02 15:39:26 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GimpClone, gimp_clone, GIMP_TYPE_SOURCE_CORE)
|
|
|
|
|
|
|
|
|
|
#define parent_class gimp_clone_parent_class
|
2000-01-14 04:41:00 -08:00
|
|
|
|
1999-04-08 15:25:54 -07:00
|
|
|
|
2002-02-27 05:57:49 -08:00
|
|
|
void
|
|
|
|
|
gimp_clone_register (Gimp *gimp,
|
|
|
|
|
GimpPaintRegisterCallback callback)
|
|
|
|
|
{
|
2003-02-14 06:14:29 -08:00
|
|
|
(* callback) (gimp,
|
|
|
|
|
GIMP_TYPE_CLONE,
|
|
|
|
|
GIMP_TYPE_CLONE_OPTIONS,
|
2005-12-27 10:57:01 -08:00
|
|
|
"gimp-clone",
|
|
|
|
|
_("Clone"),
|
|
|
|
|
"gimp-tool-clone");
|
2002-02-27 05:57:49 -08:00
|
|
|
}
|
|
|
|
|
|
2001-04-19 06:01:44 -07:00
|
|
|
static void
|
2002-02-14 11:31:16 -08:00
|
|
|
gimp_clone_class_init (GimpCloneClass *klass)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2006-09-02 15:39:26 -07:00
|
|
|
GimpPaintCoreClass *paint_core_class = GIMP_PAINT_CORE_CLASS (klass);
|
|
|
|
|
GimpSourceCoreClass *source_core_class = GIMP_SOURCE_CORE_CLASS (klass);
|
2002-02-07 03:33:01 -08:00
|
|
|
|
2012-11-01 13:39:14 -07:00
|
|
|
paint_core_class->start = gimp_clone_start;
|
2004-06-14 05:52:33 -07:00
|
|
|
|
2012-11-01 13:39:14 -07:00
|
|
|
source_core_class->use_source = gimp_clone_use_source;
|
|
|
|
|
source_core_class->motion = gimp_clone_motion;
|
1999-02-05 01:55:44 -08:00
|
|
|
}
|
|
|
|
|
|
2006-03-30 06:04:53 -08:00
|
|
|
static void
|
2006-09-02 15:39:26 -07:00
|
|
|
gimp_clone_init (GimpClone *clone)
|
2006-03-30 06:04:53 -08:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2006-09-19 16:14:50 -07:00
|
|
|
static gboolean
|
2006-09-26 13:55:40 -07:00
|
|
|
gimp_clone_start (GimpPaintCore *paint_core,
|
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
|
GimpPaintOptions *paint_options,
|
2009-04-17 13:29:25 -07:00
|
|
|
const GimpCoords *coords,
|
2006-09-26 13:55:40 -07:00
|
|
|
GError **error)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2004-05-25 13:41:09 -07:00
|
|
|
GimpCloneOptions *options = GIMP_CLONE_OPTIONS (paint_options);
|
2002-02-14 11:31:16 -08:00
|
|
|
|
2006-09-19 16:14:50 -07:00
|
|
|
if (! GIMP_PAINT_CORE_CLASS (parent_class)->start (paint_core, drawable,
|
2006-09-26 13:55:40 -07:00
|
|
|
paint_options, coords,
|
|
|
|
|
error))
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2006-09-19 16:14:50 -07:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
2002-06-09 06:56:09 -07:00
|
|
|
|
2014-04-29 11:55:08 -07:00
|
|
|
if (options->clone_type == GIMP_CLONE_PATTERN)
|
2006-09-19 16:14:50 -07:00
|
|
|
{
|
|
|
|
|
if (! gimp_context_get_pattern (GIMP_CONTEXT (options)))
|
|
|
|
|
{
|
2008-11-12 02:56:06 -08:00
|
|
|
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
|
2015-12-15 14:45:18 -08:00
|
|
|
_("No patterns available for use with this tool."));
|
2006-09-19 16:14:50 -07:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|
2006-03-30 06:04:53 -08:00
|
|
|
|
2006-09-19 16:14:50 -07:00
|
|
|
return TRUE;
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2006-09-02 15:39:26 -07:00
|
|
|
gimp_clone_motion (GimpSourceCore *source_core,
|
2002-06-09 06:56:09 -07:00
|
|
|
GimpDrawable *drawable,
|
2006-09-04 15:54:50 -07:00
|
|
|
GimpPaintOptions *paint_options,
|
2009-05-03 03:08:21 -07:00
|
|
|
const GimpCoords *coords,
|
2016-01-27 10:13:17 -08:00
|
|
|
GeglNode *op,
|
2006-09-04 15:54:50 -07:00
|
|
|
gdouble opacity,
|
|
|
|
|
GimpPickable *src_pickable,
|
2012-03-30 13:11:46 -07:00
|
|
|
GeglBuffer *src_buffer,
|
2012-03-31 06:40:21 -07:00
|
|
|
GeglRectangle *src_rect,
|
2006-09-07 02:35:52 -07:00
|
|
|
gint src_offset_x,
|
|
|
|
|
gint src_offset_y,
|
2012-04-01 12:02:49 -07:00
|
|
|
GeglBuffer *paint_buffer,
|
|
|
|
|
gint paint_buffer_x,
|
|
|
|
|
gint paint_buffer_y,
|
2006-09-04 15:54:50 -07:00
|
|
|
gint paint_area_offset_x,
|
2006-09-07 01:49:52 -07:00
|
|
|
gint paint_area_offset_y,
|
|
|
|
|
gint paint_area_width,
|
|
|
|
|
gint paint_area_height)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2015-04-19 12:58:36 -07:00
|
|
|
GimpPaintCore *paint_core = GIMP_PAINT_CORE (source_core);
|
|
|
|
|
GimpBrushCore *brush_core = GIMP_BRUSH_CORE (source_core);
|
|
|
|
|
GimpCloneOptions *options = GIMP_CLONE_OPTIONS (paint_options);
|
|
|
|
|
GimpSourceOptions *source_options = GIMP_SOURCE_OPTIONS (paint_options);
|
|
|
|
|
GimpContext *context = GIMP_CONTEXT (paint_options);
|
|
|
|
|
GimpDynamics *dynamics = brush_core->dynamics;
|
|
|
|
|
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
|
|
|
|
gdouble fade_point;
|
|
|
|
|
gdouble force;
|
2002-06-09 06:56:09 -07:00
|
|
|
|
2012-11-01 13:39:14 -07:00
|
|
|
if (gimp_source_core_use_source (source_core, source_options))
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2018-05-24 07:21:21 -07:00
|
|
|
gimp_gegl_buffer_copy (src_buffer,
|
|
|
|
|
GEGL_RECTANGLE (src_rect->x,
|
|
|
|
|
src_rect->y,
|
|
|
|
|
paint_area_width,
|
|
|
|
|
paint_area_height),
|
|
|
|
|
GEGL_ABYSS_NONE,
|
|
|
|
|
paint_buffer,
|
|
|
|
|
GEGL_RECTANGLE (paint_area_offset_x,
|
|
|
|
|
paint_area_offset_y,
|
|
|
|
|
0, 0));
|
2016-01-27 10:13:17 -08:00
|
|
|
if (op)
|
|
|
|
|
{
|
|
|
|
|
GeglNode *graph, *source, *target;
|
|
|
|
|
|
|
|
|
|
graph = gegl_node_new ();
|
|
|
|
|
source = gegl_node_new_child (graph,
|
|
|
|
|
"operation", "gegl:buffer-source",
|
|
|
|
|
"buffer", paint_buffer,
|
|
|
|
|
NULL);
|
|
|
|
|
gegl_node_add_child (graph, op);
|
|
|
|
|
target = gegl_node_new_child (graph,
|
|
|
|
|
"operation", "gegl:write-buffer",
|
|
|
|
|
"buffer", paint_buffer,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
gegl_node_link_many (source, op, target, NULL);
|
|
|
|
|
gegl_node_process (target);
|
|
|
|
|
|
|
|
|
|
g_object_unref (graph);
|
|
|
|
|
}
|
2012-11-01 13:39:14 -07:00
|
|
|
}
|
2014-04-29 11:55:08 -07:00
|
|
|
else if (options->clone_type == GIMP_CLONE_PATTERN)
|
2012-11-01 13:39:14 -07:00
|
|
|
{
|
|
|
|
|
GimpPattern *pattern = gimp_context_get_pattern (context);
|
|
|
|
|
GeglBuffer *src_buffer = gimp_pattern_create_buffer (pattern);
|
|
|
|
|
|
2017-04-19 20:33:44 -07:00
|
|
|
src_offset_x += gegl_buffer_get_width (src_buffer) / 2;
|
|
|
|
|
src_offset_y += gegl_buffer_get_height (src_buffer) / 2;
|
|
|
|
|
|
2012-11-01 13:39:14 -07:00
|
|
|
gegl_buffer_set_pattern (paint_buffer,
|
|
|
|
|
GEGL_RECTANGLE (paint_area_offset_x,
|
|
|
|
|
paint_area_offset_y,
|
|
|
|
|
paint_area_width,
|
|
|
|
|
paint_area_height),
|
|
|
|
|
src_buffer,
|
|
|
|
|
- paint_buffer_x - src_offset_x,
|
|
|
|
|
- paint_buffer_y - src_offset_y);
|
|
|
|
|
|
|
|
|
|
g_object_unref (src_buffer);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
g_return_if_reached ();
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|
|
|
|
|
|
2009-10-13 12:02:10 -07:00
|
|
|
fade_point = gimp_paint_options_get_fade (paint_options, image,
|
|
|
|
|
paint_core->pixel_dist);
|
1999-07-09 09:41:58 -07:00
|
|
|
|
2015-04-19 12:58:36 -07:00
|
|
|
if (gimp_dynamics_is_output_enabled (dynamics, GIMP_DYNAMICS_OUTPUT_FORCE))
|
2015-04-19 12:27:48 -07:00
|
|
|
force = gimp_dynamics_get_linear_value (dynamics,
|
|
|
|
|
GIMP_DYNAMICS_OUTPUT_FORCE,
|
|
|
|
|
coords,
|
|
|
|
|
paint_options,
|
|
|
|
|
fade_point);
|
2015-01-19 00:46:31 -08:00
|
|
|
else
|
|
|
|
|
force = paint_options->brush_force;
|
2008-05-22 09:38:57 -07:00
|
|
|
|
2004-05-25 13:41:09 -07:00
|
|
|
gimp_brush_core_paste_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
|
2009-05-17 13:45:06 -07:00
|
|
|
coords,
|
2004-07-28 04:17:49 -07:00
|
|
|
MIN (opacity, GIMP_OPACITY_OPAQUE),
|
|
|
|
|
gimp_context_get_opacity (context),
|
|
|
|
|
gimp_context_get_paint_mode (context),
|
|
|
|
|
gimp_paint_options_get_brush_mode (paint_options),
|
2010-04-08 14:44:52 -07:00
|
|
|
force,
|
2005-12-07 13:17:12 -08:00
|
|
|
|
|
|
|
|
/* In fixed mode, paint incremental so the
|
|
|
|
|
* individual brushes are properly applied
|
|
|
|
|
* on top of each other.
|
|
|
|
|
* Otherwise the stuff we paint is seamless
|
|
|
|
|
* and we don't need intermediate masking.
|
|
|
|
|
*/
|
2006-09-02 15:39:26 -07:00
|
|
|
source_options->align_mode ==
|
|
|
|
|
GIMP_SOURCE_ALIGN_FIXED ?
|
2016-01-27 10:13:17 -08:00
|
|
|
GIMP_PAINT_INCREMENTAL : GIMP_PAINT_CONSTANT,
|
|
|
|
|
NULL);
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|
2012-11-01 13:39:14 -07:00
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gimp_clone_use_source (GimpSourceCore *source_core,
|
|
|
|
|
GimpSourceOptions *options)
|
|
|
|
|
{
|
2014-04-29 11:55:08 -07:00
|
|
|
return GIMP_CLONE_OPTIONS (options)->clone_type == GIMP_CLONE_IMAGE;
|
2012-11-01 13:39:14 -07:00
|
|
|
}
|