1999-07-01 16:52:50 +00:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (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
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2000-12-16 21:37:03 +00:00
|
|
|
|
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc
1999-09-01 Tor Lillqvist <tml@iki.fi>
* app/appenv.h
* libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI,
RINT(), ROUND() etc from app/appenv.h here, so plug-ins can
use them, too. Remove some commented-out old stuff in appenv.h.
* libgimp/gimp.h: Include gimpmath.h.
* libgimp/gimp.c (gimp_main): Win32: Don't install signal
handlers, we can't do anything useful in the handler ourselves
anyway (it would be nice to print out a backtrace, but that seems
pretty hard to do, even if not impossible). Let Windows inform the
user about the crash. If the plug-in was compiled with MSVC, and
the user also has it, she is offered a chance to start the
debugger automatically anyway.
* app/*several*.c: Include gimpmath.h for G_PI etc. Don't include
<math.h>, as gimpmath.h includes it.
* plug-ins/*/*many*.c: Include config.h. Don't include <math.h>.
Remove all the duplicated definitions of G_PI and rint(). Use
RINT() instead of rint().
* app/app_procs.[ch]: app_exit() takes a gboolean.
* app/batch.c
* app/commands.c
* app/interface.c: Call app_exit() with FALSE or TRUE.
* app/main.c (on_error): Call gimp_fatal_error. (main): Don't
install any signal handler on Win32 here, either.
* app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format
the message and call MessageBox with it. g_on_error_query doesn't
do anything useful on Win32, and printf'ing a message to stdout or
stderr doesn't do anything, either, in a windowing application.
1999-09-01 20:30:56 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
#include <glib-object.h>
|
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc
1999-09-01 Tor Lillqvist <tml@iki.fi>
* app/appenv.h
* libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI,
RINT(), ROUND() etc from app/appenv.h here, so plug-ins can
use them, too. Remove some commented-out old stuff in appenv.h.
* libgimp/gimp.h: Include gimpmath.h.
* libgimp/gimp.c (gimp_main): Win32: Don't install signal
handlers, we can't do anything useful in the handler ourselves
anyway (it would be nice to print out a backtrace, but that seems
pretty hard to do, even if not impossible). Let Windows inform the
user about the crash. If the plug-in was compiled with MSVC, and
the user also has it, she is offered a chance to start the
debugger automatically anyway.
* app/*several*.c: Include gimpmath.h for G_PI etc. Don't include
<math.h>, as gimpmath.h includes it.
* plug-ins/*/*many*.c: Include config.h. Don't include <math.h>.
Remove all the duplicated definitions of G_PI and rint(). Use
RINT() instead of rint().
* app/app_procs.[ch]: app_exit() takes a gboolean.
* app/batch.c
* app/commands.c
* app/interface.c: Call app_exit() with FALSE or TRUE.
* app/main.c (on_error): Call gimp_fatal_error. (main): Don't
install any signal handler on Win32 here, either.
* app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format
the message and call MessageBox with it. g_on_error_query doesn't
do anything useful on Win32, and printf'ing a message to stdout or
stderr doesn't do anything, either, in a windowing application.
1999-09-01 20:30:56 +00:00
|
|
|
|
2001-01-23 23:56:18 +00:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
|
2002-02-14 19:31:16 +00:00
|
|
|
#include "paint-types.h"
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2001-05-15 11:25:25 +00:00
|
|
|
#include "base/pixel-region.h"
|
|
|
|
#include "base/temp-buf.h"
|
|
|
|
|
2001-04-11 17:20:34 +00:00
|
|
|
#include "paint-funcs/paint-funcs.h"
|
|
|
|
|
2001-07-07 12:17:23 +00:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
#include "core/gimpbrush.h"
|
|
|
|
#include "core/gimpdrawable.h"
|
2001-07-07 12:17:23 +00:00
|
|
|
#include "core/gimpimage.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
|
2002-02-14 19:31:16 +00:00
|
|
|
#include "gimpsmudge.h"
|
2003-02-05 14:39:40 +00:00
|
|
|
#include "gimpsmudgeoptions.h"
|
2001-04-11 17:20:34 +00:00
|
|
|
|
2003-03-25 16:38:19 +00:00
|
|
|
#include "gimp-intl.h"
|
2003-02-14 14:14:29 +00:00
|
|
|
|
2000-04-27 17:27:28 +00:00
|
|
|
|
2002-02-21 16:02:30 +00:00
|
|
|
static void gimp_smudge_class_init (GimpSmudgeClass *klass);
|
|
|
|
static void gimp_smudge_init (GimpSmudge *smudge);
|
|
|
|
|
2002-06-09 13:56:09 +00:00
|
|
|
static void gimp_smudge_finalize (GObject *object);
|
|
|
|
|
2002-02-21 16:02:30 +00:00
|
|
|
static void gimp_smudge_paint (GimpPaintCore *paint_core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options,
|
|
|
|
GimpPaintCoreState paint_state);
|
|
|
|
static gboolean gimp_smudge_start (GimpPaintCore *paint_core,
|
|
|
|
GimpDrawable *drawable);
|
|
|
|
static void gimp_smudge_motion (GimpPaintCore *paint_core,
|
|
|
|
GimpDrawable *drawable,
|
2002-06-09 13:56:09 +00:00
|
|
|
GimpPaintOptions *paint_options);
|
1999-07-19 22:42:49 +00:00
|
|
|
|
2002-02-14 19:31:16 +00:00
|
|
|
static void gimp_smudge_nonclipped_painthit_coords (GimpPaintCore *paint_core,
|
|
|
|
gint *x,
|
2003-07-14 14:50:41 +00:00
|
|
|
gint *y,
|
2002-02-14 19:31:16 +00:00
|
|
|
gint *w,
|
|
|
|
gint *h);
|
1999-07-01 16:52:50 +00:00
|
|
|
|
2000-01-14 12:41:00 +00:00
|
|
|
|
2002-02-14 19:31:16 +00:00
|
|
|
static GimpPaintCoreClass *parent_class = NULL;
|
2001-11-20 23:00:47 +00:00
|
|
|
|
1999-07-01 16:52:50 +00:00
|
|
|
|
2002-02-27 13:57:49 +00:00
|
|
|
void
|
|
|
|
gimp_smudge_register (Gimp *gimp,
|
|
|
|
GimpPaintRegisterCallback callback)
|
|
|
|
{
|
2003-02-14 14:14:29 +00:00
|
|
|
(* callback) (gimp,
|
|
|
|
GIMP_TYPE_SMUDGE,
|
|
|
|
GIMP_TYPE_SMUDGE_OPTIONS,
|
|
|
|
_("Smudge"));
|
2002-02-27 13:57:49 +00:00
|
|
|
}
|
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
GType
|
2002-02-14 19:31:16 +00:00
|
|
|
gimp_smudge_get_type (void)
|
2001-04-11 17:20:34 +00:00
|
|
|
{
|
2002-02-14 19:31:16 +00:00
|
|
|
static GType type = 0;
|
1999-07-01 16:52:50 +00:00
|
|
|
|
2002-02-14 19:31:16 +00:00
|
|
|
if (! type)
|
2001-04-11 17:20:34 +00:00
|
|
|
{
|
2002-02-14 19:31:16 +00:00
|
|
|
static const GTypeInfo info =
|
2001-04-11 17:20:34 +00:00
|
|
|
{
|
2002-02-14 19:31:16 +00:00
|
|
|
sizeof (GimpSmudgeClass),
|
2001-08-14 14:53:55 +00:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
2002-02-14 19:31:16 +00:00
|
|
|
(GClassInitFunc) gimp_smudge_class_init,
|
2001-08-14 14:53:55 +00:00
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
2002-02-14 19:31:16 +00:00
|
|
|
sizeof (GimpSmudge),
|
2001-08-14 14:53:55 +00:00
|
|
|
0, /* n_preallocs */
|
2002-02-14 19:31:16 +00:00
|
|
|
(GInstanceInitFunc) gimp_smudge_init,
|
2001-04-11 17:20:34 +00:00
|
|
|
};
|
|
|
|
|
2002-02-14 19:31:16 +00:00
|
|
|
type = g_type_register_static (GIMP_TYPE_PAINT_CORE,
|
|
|
|
"GimpSmudge",
|
|
|
|
&info, 0);
|
2001-04-11 17:20:34 +00:00
|
|
|
}
|
|
|
|
|
2002-02-14 19:31:16 +00:00
|
|
|
return type;
|
1999-07-01 16:52:50 +00:00
|
|
|
}
|
|
|
|
|
2001-04-11 17:20:34 +00:00
|
|
|
static void
|
2002-02-14 19:31:16 +00:00
|
|
|
gimp_smudge_class_init (GimpSmudgeClass *klass)
|
1999-07-01 16:52:50 +00:00
|
|
|
{
|
2002-06-09 13:56:09 +00:00
|
|
|
GObjectClass *object_class;
|
2002-02-14 19:31:16 +00:00
|
|
|
GimpPaintCoreClass *paint_core_class;
|
1999-07-01 16:52:50 +00:00
|
|
|
|
2002-06-09 13:56:09 +00:00
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
2002-02-14 19:31:16 +00:00
|
|
|
paint_core_class = GIMP_PAINT_CORE_CLASS (klass);
|
1999-07-01 16:52:50 +00:00
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
1999-07-01 16:52:50 +00:00
|
|
|
|
2002-06-09 13:56:09 +00:00
|
|
|
object_class->finalize = gimp_smudge_finalize;
|
|
|
|
|
2002-02-14 19:31:16 +00:00
|
|
|
paint_core_class->paint = gimp_smudge_paint;
|
2001-04-11 17:20:34 +00:00
|
|
|
}
|
1999-07-01 16:52:50 +00:00
|
|
|
|
2001-04-11 17:20:34 +00:00
|
|
|
static void
|
2002-02-14 19:31:16 +00:00
|
|
|
gimp_smudge_init (GimpSmudge *smudge)
|
2001-04-11 17:20:34 +00:00
|
|
|
{
|
2002-02-14 19:31:16 +00:00
|
|
|
GimpPaintCore *paint_core;
|
1999-07-01 16:52:50 +00:00
|
|
|
|
2002-02-14 19:31:16 +00:00
|
|
|
paint_core = GIMP_PAINT_CORE (smudge);
|
2001-04-11 17:20:34 +00:00
|
|
|
|
2002-06-09 13:56:09 +00:00
|
|
|
smudge->initialized = FALSE;
|
|
|
|
smudge->accum_data = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_smudge_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GimpSmudge *smudge;
|
|
|
|
|
|
|
|
smudge = GIMP_SMUDGE (object);
|
|
|
|
|
|
|
|
if (smudge->accum_data)
|
|
|
|
{
|
|
|
|
g_free (smudge->accum_data);
|
|
|
|
smudge->accum_data = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
1999-07-01 16:52:50 +00:00
|
|
|
}
|
|
|
|
|
2001-04-11 17:20:34 +00:00
|
|
|
static void
|
2002-02-14 19:31:16 +00:00
|
|
|
gimp_smudge_paint (GimpPaintCore *paint_core,
|
|
|
|
GimpDrawable *drawable,
|
2002-02-21 16:02:30 +00:00
|
|
|
GimpPaintOptions *paint_options,
|
2002-02-14 19:31:16 +00:00
|
|
|
GimpPaintCoreState paint_state)
|
1999-07-01 16:52:50 +00:00
|
|
|
{
|
2002-06-09 13:56:09 +00:00
|
|
|
GimpSmudge *smudge;
|
2001-11-20 13:53:21 +00:00
|
|
|
|
2002-06-09 13:56:09 +00:00
|
|
|
smudge = GIMP_SMUDGE (paint_core);
|
2001-11-20 13:53:21 +00:00
|
|
|
|
2002-02-14 19:31:16 +00:00
|
|
|
switch (paint_state)
|
1999-07-01 16:52:50 +00:00
|
|
|
{
|
|
|
|
case MOTION_PAINT:
|
2002-06-09 13:56:09 +00:00
|
|
|
/* initialization fails if the user starts outside the drawable */
|
|
|
|
if (! smudge->initialized)
|
|
|
|
smudge->initialized = gimp_smudge_start (paint_core, drawable);
|
|
|
|
|
|
|
|
if (smudge->initialized)
|
|
|
|
gimp_smudge_motion (paint_core, drawable, paint_options);
|
1999-07-01 16:52:50 +00:00
|
|
|
break;
|
2000-12-31 04:07:42 +00:00
|
|
|
|
1999-07-01 16:52:50 +00:00
|
|
|
case FINISH_PAINT:
|
2002-06-09 13:56:09 +00:00
|
|
|
if (smudge->accum_data)
|
|
|
|
{
|
|
|
|
g_free (smudge->accum_data);
|
|
|
|
smudge->accum_data = NULL;
|
|
|
|
}
|
|
|
|
smudge->initialized = FALSE;
|
1999-07-01 16:52:50 +00:00
|
|
|
break;
|
2000-12-31 04:07:42 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
1999-07-01 16:52:50 +00:00
|
|
|
}
|
|
|
|
|
2001-04-11 17:20:34 +00:00
|
|
|
return;
|
1999-07-01 16:52:50 +00:00
|
|
|
}
|
|
|
|
|
2000-01-14 18:45:36 +00:00
|
|
|
static gboolean
|
2002-02-14 19:31:16 +00:00
|
|
|
gimp_smudge_start (GimpPaintCore *paint_core,
|
2002-02-21 16:02:30 +00:00
|
|
|
GimpDrawable *drawable)
|
1999-07-01 16:52:50 +00:00
|
|
|
{
|
2002-06-09 13:56:09 +00:00
|
|
|
GimpSmudge *smudge;
|
2001-04-11 17:20:34 +00:00
|
|
|
GimpImage *gimage;
|
2000-12-31 04:07:42 +00:00
|
|
|
TempBuf *area;
|
1999-07-01 16:52:50 +00:00
|
|
|
PixelRegion srcPR;
|
2000-12-31 04:07:42 +00:00
|
|
|
gint x, y, w, h;
|
1999-07-01 16:52:50 +00:00
|
|
|
|
2002-06-09 13:56:09 +00:00
|
|
|
smudge = GIMP_SMUDGE (paint_core);
|
|
|
|
|
2003-07-16 11:25:37 +00:00
|
|
|
if (! (gimage = gimp_item_get_image (GIMP_ITEM (drawable))))
|
|
|
|
return FALSE;
|
1999-07-01 16:52:50 +00:00
|
|
|
|
2001-01-14 21:11:52 +00:00
|
|
|
if (gimp_drawable_is_indexed (drawable))
|
2000-01-14 18:45:36 +00:00
|
|
|
return FALSE;
|
1999-07-01 16:52:50 +00:00
|
|
|
|
2003-07-16 11:25:37 +00:00
|
|
|
if (! (area = gimp_paint_core_get_paint_area (paint_core, drawable, 1.0)))
|
2000-01-14 18:45:36 +00:00
|
|
|
return FALSE;
|
2003-06-13 11:12:04 +00:00
|
|
|
|
2000-01-14 18:45:36 +00:00
|
|
|
/* adjust the x and y coordinates to the upper left corner of the brush */
|
2002-02-14 19:31:16 +00:00
|
|
|
gimp_smudge_nonclipped_painthit_coords (paint_core, &x, &y, &w, &h);
|
2003-06-09 15:24:30 +00:00
|
|
|
|
|
|
|
/* Allocate the accumulation buffer */
|
|
|
|
smudge->accumPR.bytes = gimp_drawable_bytes (drawable);
|
2003-06-13 11:12:04 +00:00
|
|
|
smudge->accum_data = g_malloc (w * h * smudge->accumPR.bytes);
|
|
|
|
|
2003-06-13 11:16:08 +00:00
|
|
|
/* If clipped, prefill the smudge buffer
|
|
|
|
with the color at the brush position. */
|
|
|
|
if (x != area->x || y != area->y || w != area->width || h != area->height)
|
2003-06-13 11:12:04 +00:00
|
|
|
{
|
|
|
|
guchar *fill;
|
|
|
|
|
|
|
|
fill = gimp_drawable_get_color_at (drawable,
|
|
|
|
CLAMP ((gint) paint_core->cur_coords.x,
|
|
|
|
0, gimp_item_width (GIMP_ITEM (drawable)) - 1),
|
|
|
|
CLAMP ((gint) paint_core->cur_coords.y,
|
|
|
|
0, gimp_item_height (GIMP_ITEM (drawable)) - 1));
|
|
|
|
g_return_val_if_fail (fill != NULL, FALSE);
|
|
|
|
|
|
|
|
srcPR.w = w;
|
|
|
|
srcPR.h = h;
|
|
|
|
srcPR.bytes = smudge->accumPR.bytes;
|
|
|
|
srcPR.rowstride = srcPR.bytes * w;
|
|
|
|
srcPR.data = smudge->accum_data;
|
2003-07-14 14:50:41 +00:00
|
|
|
|
2003-06-13 11:12:04 +00:00
|
|
|
color_region (&srcPR, fill);
|
|
|
|
g_free (fill);
|
|
|
|
}
|
1999-09-26 04:53:59 +00:00
|
|
|
|
2003-07-14 14:50:41 +00:00
|
|
|
smudge->accumPR.x = area->x - x;
|
2002-06-09 13:56:09 +00:00
|
|
|
smudge->accumPR.y = area->y - y;
|
|
|
|
smudge->accumPR.w = area->width;
|
|
|
|
smudge->accumPR.h = area->height;
|
2003-07-14 14:50:41 +00:00
|
|
|
smudge->accumPR.rowstride = smudge->accumPR.bytes * w;
|
2002-06-09 13:56:09 +00:00
|
|
|
smudge->accumPR.data = (smudge->accum_data +
|
|
|
|
smudge->accumPR.rowstride * smudge->accumPR.y +
|
|
|
|
smudge->accumPR.x * smudge->accumPR.bytes);
|
1999-07-01 16:52:50 +00:00
|
|
|
|
2003-07-14 14:50:41 +00:00
|
|
|
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
|
2001-01-14 21:11:52 +00:00
|
|
|
area->x, area->y, area->width, area->height, FALSE);
|
1999-07-01 16:52:50 +00:00
|
|
|
|
|
|
|
/* copy the region under the original painthit. */
|
2002-06-09 13:56:09 +00:00
|
|
|
copy_region (&srcPR, &smudge->accumPR);
|
1999-07-01 16:52:50 +00:00
|
|
|
|
2003-07-14 14:50:41 +00:00
|
|
|
smudge->accumPR.x = area->x - x;
|
2002-06-09 13:56:09 +00:00
|
|
|
smudge->accumPR.y = area->y - y;
|
|
|
|
smudge->accumPR.w = area->width;
|
|
|
|
smudge->accumPR.h = area->height;
|
|
|
|
smudge->accumPR.rowstride = smudge->accumPR.bytes * w;
|
|
|
|
smudge->accumPR.data = (smudge->accum_data +
|
|
|
|
smudge->accumPR.rowstride * smudge->accumPR.y +
|
|
|
|
smudge->accumPR.x * smudge->accumPR.bytes);
|
1999-09-26 04:53:59 +00:00
|
|
|
|
2000-01-14 18:45:36 +00:00
|
|
|
return TRUE;
|
1999-07-01 16:52:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-06-09 13:56:09 +00:00
|
|
|
gimp_smudge_motion (GimpPaintCore *paint_core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options)
|
1999-07-01 16:52:50 +00:00
|
|
|
{
|
2002-06-09 13:56:09 +00:00
|
|
|
GimpSmudge *smudge;
|
|
|
|
GimpSmudgeOptions *options;
|
|
|
|
GimpPressureOptions *pressure_options;
|
|
|
|
GimpContext *context;
|
2003-02-05 16:59:04 +00:00
|
|
|
GimpImage *gimage;
|
2002-06-09 13:56:09 +00:00
|
|
|
TempBuf *area;
|
|
|
|
PixelRegion srcPR, destPR, tempPR;
|
|
|
|
gdouble rate;
|
|
|
|
gdouble opacity;
|
|
|
|
gint x, y, w, h;
|
|
|
|
|
2003-02-05 16:59:04 +00:00
|
|
|
smudge = GIMP_SMUDGE (paint_core);
|
|
|
|
options = GIMP_SMUDGE_OPTIONS (paint_options);
|
|
|
|
context = GIMP_CONTEXT (paint_options);
|
2002-06-09 13:56:09 +00:00
|
|
|
|
|
|
|
pressure_options = paint_options->pressure_options;
|
1999-07-01 16:52:50 +00:00
|
|
|
|
2003-07-16 11:25:37 +00:00
|
|
|
if (! (gimage = gimp_item_get_image (GIMP_ITEM (drawable))))
|
|
|
|
return;
|
1999-07-01 16:52:50 +00:00
|
|
|
|
2001-01-14 21:11:52 +00:00
|
|
|
if (gimp_drawable_is_indexed (drawable))
|
1999-07-01 16:52:50 +00:00
|
|
|
return;
|
|
|
|
|
2003-07-16 11:25:37 +00:00
|
|
|
opacity = gimp_paint_options_get_fade (paint_options, gimage,
|
|
|
|
paint_core->pixel_dist);
|
|
|
|
|
|
|
|
if (opacity == 0.0)
|
|
|
|
return;
|
|
|
|
|
2002-02-14 19:31:16 +00:00
|
|
|
gimp_smudge_nonclipped_painthit_coords (paint_core, &x, &y, &w, &h);
|
1999-07-01 16:52:50 +00:00
|
|
|
|
2003-07-16 11:25:37 +00:00
|
|
|
/* Get the paint area (Smudge won't scale!) */
|
2002-02-14 19:31:16 +00:00
|
|
|
if (! (area = gimp_paint_core_get_paint_area (paint_core, drawable, 1.0)))
|
1999-07-01 16:52:50 +00:00
|
|
|
return;
|
|
|
|
|
2003-06-09 15:24:30 +00:00
|
|
|
/* srcPR will be the pixels under the current painthit from the drawable */
|
2003-07-14 14:50:41 +00:00
|
|
|
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
|
2000-01-14 12:41:00 +00:00
|
|
|
area->x, area->y, area->width, area->height, FALSE);
|
1999-07-01 16:52:50 +00:00
|
|
|
|
1999-11-13 01:02:27 +00:00
|
|
|
/* Enable pressure sensitive rate */
|
|
|
|
if (pressure_options->rate)
|
2003-07-16 11:25:37 +00:00
|
|
|
rate = MIN (options->rate / 100.0 * 2.0 * paint_core->cur_coords.pressure,
|
2003-06-09 15:24:30 +00:00
|
|
|
1.0);
|
1999-09-09 01:47:54 +00:00
|
|
|
else
|
2002-06-09 13:56:09 +00:00
|
|
|
rate = options->rate / 100.0;
|
1999-09-09 01:47:54 +00:00
|
|
|
|
2003-07-14 14:50:41 +00:00
|
|
|
/* The tempPR will be the built up buffer (for smudge) */
|
|
|
|
tempPR.x = area->x - x;
|
2002-06-09 13:56:09 +00:00
|
|
|
tempPR.y = area->y - y;
|
|
|
|
tempPR.w = area->width;
|
|
|
|
tempPR.h = area->height;
|
|
|
|
tempPR.bytes = smudge->accumPR.bytes;
|
|
|
|
tempPR.rowstride = smudge->accumPR.rowstride;
|
|
|
|
tempPR.data = (smudge->accum_data +
|
|
|
|
tempPR.y * tempPR.rowstride +
|
|
|
|
tempPR.x * tempPR.bytes);
|
1999-07-01 16:52:50 +00:00
|
|
|
|
2003-07-14 14:50:41 +00:00
|
|
|
/* The dest will be the paint area we got above (= canvas_buf) */
|
1999-07-01 16:52:50 +00:00
|
|
|
|
2002-06-09 13:56:09 +00:00
|
|
|
destPR.x = 0;
|
2003-07-14 14:50:41 +00:00
|
|
|
destPR.y = 0;
|
|
|
|
destPR.w = area->width;
|
|
|
|
destPR.h = area->height;
|
2002-06-09 13:56:09 +00:00
|
|
|
destPR.bytes = area->bytes;
|
2003-07-14 14:50:41 +00:00
|
|
|
destPR.rowstride = area->width * area->bytes;
|
|
|
|
destPR.data = temp_buf_data (area);
|
1999-07-01 16:52:50 +00:00
|
|
|
|
2002-06-09 13:56:09 +00:00
|
|
|
/* Smudge uses the buffer Accum.
|
|
|
|
* For each successive painthit Accum is built like this
|
|
|
|
* Accum = rate*Accum + (1-rate)*I.
|
2003-07-14 14:50:41 +00:00
|
|
|
* where I is the pixels under the current painthit.
|
|
|
|
* Then the paint area (canvas_buf) is built as
|
2002-06-09 13:56:09 +00:00
|
|
|
* (Accum,1) (if no alpha),
|
|
|
|
*/
|
1999-07-01 16:52:50 +00:00
|
|
|
|
1999-11-13 01:02:27 +00:00
|
|
|
blend_region (&srcPR, &tempPR, &tempPR, ROUND (rate * 255.0));
|
1999-07-01 16:52:50 +00:00
|
|
|
|
|
|
|
/* re-init the tempPR */
|
|
|
|
|
2002-06-09 13:56:09 +00:00
|
|
|
tempPR.x = area->x - x;
|
|
|
|
tempPR.y = area->y - y;
|
|
|
|
tempPR.w = area->width;
|
|
|
|
tempPR.h = area->height;
|
|
|
|
tempPR.bytes = smudge->accumPR.bytes;
|
|
|
|
tempPR.rowstride = smudge->accumPR.rowstride;
|
|
|
|
tempPR.data = (smudge->accum_data +
|
|
|
|
tempPR.y * tempPR.rowstride +
|
|
|
|
tempPR.x * tempPR.bytes);
|
|
|
|
|
|
|
|
if (! gimp_drawable_has_alpha (drawable))
|
|
|
|
add_alpha_region (&tempPR, &destPR);
|
|
|
|
else
|
2000-02-08 20:48:48 +00:00
|
|
|
copy_region (&tempPR, &destPR);
|
1999-07-01 16:52:50 +00:00
|
|
|
|
1999-09-09 01:47:54 +00:00
|
|
|
if (pressure_options->opacity)
|
2003-07-16 11:25:37 +00:00
|
|
|
opacity *= 2.0 * paint_core->cur_coords.pressure;
|
1999-09-09 01:47:54 +00:00
|
|
|
|
2003-07-16 11:25:37 +00:00
|
|
|
/* Replace the newly made paint area to the gimage */
|
2003-07-14 14:50:41 +00:00
|
|
|
gimp_paint_core_replace_canvas (paint_core, drawable,
|
2002-03-03 17:38:12 +00:00
|
|
|
MIN (opacity, GIMP_OPACITY_OPAQUE),
|
2003-07-16 11:25:37 +00:00
|
|
|
gimp_context_get_opacity (context),
|
2003-07-14 14:50:41 +00:00
|
|
|
gimp_paint_options_get_brush_mode (paint_options),
|
2002-06-09 13:56:09 +00:00
|
|
|
1.0,
|
|
|
|
GIMP_PAINT_INCREMENTAL);
|
1999-07-01 16:52:50 +00:00
|
|
|
}
|
2001-04-11 17:20:34 +00:00
|
|
|
|
2003-07-14 14:50:41 +00:00
|
|
|
static void
|
2002-02-14 19:31:16 +00:00
|
|
|
gimp_smudge_nonclipped_painthit_coords (GimpPaintCore *paint_core,
|
2003-07-14 14:50:41 +00:00
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gint *w,
|
2002-02-14 19:31:16 +00:00
|
|
|
gint *h)
|
2001-04-11 17:20:34 +00:00
|
|
|
{
|
2002-02-14 19:31:16 +00:00
|
|
|
/* Note: these are the brush mask size plus a border of 1 pixel */
|
2003-06-09 15:24:30 +00:00
|
|
|
*x =
|
|
|
|
(gint) paint_core->cur_coords.x - paint_core->brush->mask->width / 2 - 1;
|
|
|
|
*y =
|
|
|
|
(gint) paint_core->cur_coords.y - paint_core->brush->mask->height / 2 - 1;
|
|
|
|
*w = paint_core->brush->mask->width + 2;
|
2002-02-14 19:31:16 +00:00
|
|
|
*h = paint_core->brush->mask->height + 2;
|
2001-04-11 17:20:34 +00:00
|
|
|
}
|