1997-11-25 06:05:25 +08: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
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
#include "config.h"
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2003-02-08 01:12:21 +08:00
|
|
|
#include <glib-object.h>
|
2000-01-14 20:41:00 +08:00
|
|
|
|
2001-11-21 07:00:47 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
#include "paint-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "base/temp-buf.h"
|
|
|
|
|
2001-04-07 23:58:26 +08:00
|
|
|
#include "paint-funcs/paint-funcs.h"
|
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpdrawable.h"
|
|
|
|
#include "core/gimpimage.h"
|
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
#include "gimperaser.h"
|
2003-02-05 22:39:40 +08:00
|
|
|
#include "gimperaseroptions.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2003-02-14 22:14:29 +08:00
|
|
|
|
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-15 07:23:52 +08:00
|
|
|
|
2004-05-26 04:41:09 +08:00
|
|
|
static void gimp_eraser_class_init (GimpEraserClass *klass);
|
|
|
|
static void gimp_eraser_init (GimpEraser *eraser);
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2004-05-26 04:41:09 +08:00
|
|
|
static void gimp_eraser_paint (GimpPaintCore *paint_core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options,
|
|
|
|
GimpPaintCoreState paint_state);
|
|
|
|
static void gimp_eraser_motion (GimpPaintCore *paint_core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options);
|
1999-07-20 06:42:49 +08:00
|
|
|
|
1998-03-01 09:18:45 +08:00
|
|
|
|
2004-05-26 04:41:09 +08:00
|
|
|
static GimpBrushCoreClass *parent_class = NULL;
|
2001-03-12 12:40:17 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
|
2002-02-27 21:57:49 +08:00
|
|
|
void
|
|
|
|
gimp_eraser_register (Gimp *gimp,
|
|
|
|
GimpPaintRegisterCallback callback)
|
|
|
|
{
|
2003-02-14 22:14:29 +08:00
|
|
|
(* callback) (gimp,
|
|
|
|
GIMP_TYPE_ERASER,
|
|
|
|
GIMP_TYPE_ERASER_OPTIONS,
|
|
|
|
_("Eraser"));
|
2002-02-27 21:57:49 +08:00
|
|
|
}
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
GType
|
2002-02-15 03:31:16 +08:00
|
|
|
gimp_eraser_get_type (void)
|
2001-03-12 12:40:17 +08:00
|
|
|
{
|
2002-02-15 03:31:16 +08:00
|
|
|
static GType type = 0;
|
1999-04-22 22:34:00 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
if (! type)
|
2001-03-12 12:40:17 +08:00
|
|
|
{
|
2002-02-15 03:31:16 +08:00
|
|
|
static const GTypeInfo info =
|
2001-03-12 12:40:17 +08:00
|
|
|
{
|
2002-02-15 03:31:16 +08:00
|
|
|
sizeof (GimpEraserClass),
|
2004-05-26 04:41:09 +08:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_eraser_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpEraser),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_eraser_init,
|
2001-03-12 12:40:17 +08:00
|
|
|
};
|
|
|
|
|
2004-05-26 04:41:09 +08:00
|
|
|
type = g_type_register_static (GIMP_TYPE_BRUSH_CORE,
|
2003-07-14 22:50:41 +08:00
|
|
|
"GimpEraser",
|
2002-02-15 03:31:16 +08:00
|
|
|
&info, 0);
|
2001-03-12 12:40:17 +08:00
|
|
|
}
|
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
return type;
|
1999-04-09 06:25:54 +08:00
|
|
|
}
|
2001-03-12 12:40:17 +08:00
|
|
|
|
|
|
|
static void
|
2002-02-15 03:31:16 +08:00
|
|
|
gimp_eraser_class_init (GimpEraserClass *klass)
|
1998-03-01 09:18:45 +08:00
|
|
|
{
|
2004-05-26 04:41:09 +08:00
|
|
|
GimpPaintCoreClass *paint_core_class = GIMP_PAINT_CORE_CLASS (klass);
|
1999-04-13 01:55:06 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
1998-03-01 09:18:45 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
paint_core_class->paint = gimp_eraser_paint;
|
1998-03-01 09:18:45 +08:00
|
|
|
}
|
1999-08-14 04:50:30 +08:00
|
|
|
|
|
|
|
static void
|
2002-02-15 03:31:16 +08:00
|
|
|
gimp_eraser_init (GimpEraser *eraser)
|
1999-08-14 04:50:30 +08:00
|
|
|
{
|
2004-05-26 04:41:09 +08:00
|
|
|
GimpPaintCore *paint_core = GIMP_PAINT_CORE (eraser);
|
2001-11-21 07:00:47 +08:00
|
|
|
|
2002-02-16 01:44:05 +08:00
|
|
|
paint_core->flags |= CORE_HANDLES_CHANGING_BRUSH;
|
2001-12-02 06:59:48 +08:00
|
|
|
}
|
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
static void
|
2002-02-15 03:31:16 +08:00
|
|
|
gimp_eraser_paint (GimpPaintCore *paint_core,
|
|
|
|
GimpDrawable *drawable,
|
2002-02-22 00:02:30 +08:00
|
|
|
GimpPaintOptions *paint_options,
|
2002-02-15 03:31:16 +08:00
|
|
|
GimpPaintCoreState paint_state)
|
2001-03-12 12:40:17 +08:00
|
|
|
{
|
2002-02-15 03:31:16 +08:00
|
|
|
switch (paint_state)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-04-28 01:27:28 +08:00
|
|
|
case MOTION_PAINT:
|
2002-06-09 21:56:09 +08:00
|
|
|
gimp_eraser_motion (paint_core, drawable, paint_options);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
default:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static void
|
2002-02-22 00:02:30 +08:00
|
|
|
gimp_eraser_motion (GimpPaintCore *paint_core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-05-26 04:41:09 +08:00
|
|
|
GimpEraserOptions *options = GIMP_ERASER_OPTIONS (paint_options);
|
|
|
|
GimpContext *context = GIMP_CONTEXT (paint_options);
|
|
|
|
GimpPressureOptions *pressure_options = paint_options->pressure_options;
|
2003-07-14 22:50:41 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
gdouble opacity;
|
|
|
|
TempBuf *area;
|
|
|
|
guchar col[MAX_CHANNELS];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-05-26 04:41:09 +08:00
|
|
|
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-07-16 19:25:37 +08:00
|
|
|
opacity = gimp_paint_options_get_fade (paint_options, gimage,
|
|
|
|
paint_core->pixel_dist);
|
|
|
|
if (opacity == 0.0)
|
|
|
|
return;
|
|
|
|
|
2004-05-26 17:32:03 +08:00
|
|
|
area = gimp_paint_core_get_paint_area (paint_core, drawable, paint_options);
|
|
|
|
if (! area)
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
|
2004-05-26 17:32:03 +08:00
|
|
|
gimp_image_get_background (gimage, drawable, context, col);
|
|
|
|
|
2001-11-26 03:01:23 +08:00
|
|
|
/* set the alpha channel */
|
|
|
|
col[area->bytes - 1] = OPAQUE_OPACITY;
|
|
|
|
|
|
|
|
/* color the pixels */
|
|
|
|
color_pixels (temp_buf_data (area), col,
|
|
|
|
area->width * area->height, area->bytes);
|
|
|
|
|
|
|
|
if (pressure_options->opacity)
|
2004-05-24 21:11:43 +08:00
|
|
|
opacity *= PRESSURE_SCALE * paint_core->cur_coords.pressure;
|
2001-11-26 03:01:23 +08:00
|
|
|
|
2004-05-26 04:41:09 +08:00
|
|
|
gimp_brush_core_paste_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
|
2002-03-04 01:38:12 +08:00
|
|
|
MIN (opacity, GIMP_OPACITY_OPAQUE),
|
|
|
|
gimp_context_get_opacity (context),
|
2003-07-14 22:50:41 +08:00
|
|
|
(options->anti_erase ?
|
2002-03-19 23:05:38 +08:00
|
|
|
GIMP_ANTI_ERASE_MODE : GIMP_ERASE_MODE),
|
2003-07-14 22:50:41 +08:00
|
|
|
gimp_paint_options_get_brush_mode (paint_options),
|
2003-03-25 01:58:28 +08:00
|
|
|
paint_options->application_mode);
|
2001-10-31 06:59:06 +08:00
|
|
|
}
|