2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1999-07-02 00:52:50 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1999-07-02 00:52:50 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1999-07-02 00:52:50 +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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1999-07-02 00:52:50 +08:00
|
|
|
*/
|
2000-12-29 23:22:01 +08:00
|
|
|
|
1999-07-27 08:14:14 +08:00
|
|
|
#include "config.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-02 04:30:56 +08:00
|
|
|
|
2013-10-15 07:58:39 +08:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.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-02 04:30:56 +08:00
|
|
|
|
2009-06-18 02:55:05 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
#include "paint-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2012-04-03 01:17:57 +08:00
|
|
|
#include "gegl/gimp-gegl-loops.h"
|
2001-04-07 23:58:26 +08:00
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpdrawable.h"
|
2009-10-11 21:41:54 +08:00
|
|
|
#include "core/gimpdynamics.h"
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimpimage.h"
|
2016-01-28 02:13:17 +08:00
|
|
|
#include "core/gimpsymmetry.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
#include "gimpdodgeburn.h"
|
2003-02-05 22:39:40 +08:00
|
|
|
#include "gimpdodgeburnoptions.h"
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2003-02-14 22:14:29 +08:00
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
|
2012-04-03 01:17:57 +08:00
|
|
|
static void gimp_dodge_burn_paint (GimpPaintCore *paint_core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options,
|
2016-01-28 02:13:17 +08:00
|
|
|
GimpSymmetry *sym,
|
2012-04-03 01:17:57 +08:00
|
|
|
GimpPaintState paint_state,
|
|
|
|
guint32 time);
|
|
|
|
static void gimp_dodge_burn_motion (GimpPaintCore *paint_core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options,
|
2016-01-28 02:13:17 +08:00
|
|
|
GimpSymmetry *sym);
|
2004-05-26 04:41:09 +08:00
|
|
|
|
|
|
|
|
2006-05-15 17:46:31 +08:00
|
|
|
G_DEFINE_TYPE (GimpDodgeBurn, gimp_dodge_burn, GIMP_TYPE_BRUSH_CORE)
|
2005-12-08 05:11:53 +08:00
|
|
|
|
|
|
|
#define parent_class gimp_dodge_burn_parent_class
|
2000-01-14 20:41:00 +08:00
|
|
|
|
2001-03-31 23:45:05 +08:00
|
|
|
|
2002-02-27 21:57:49 +08:00
|
|
|
void
|
2003-02-05 22:39:40 +08:00
|
|
|
gimp_dodge_burn_register (Gimp *gimp,
|
|
|
|
GimpPaintRegisterCallback callback)
|
2002-02-27 21:57:49 +08:00
|
|
|
{
|
2003-02-14 22:14:29 +08:00
|
|
|
(* callback) (gimp,
|
|
|
|
GIMP_TYPE_DODGE_BURN,
|
|
|
|
GIMP_TYPE_DODGE_BURN_OPTIONS,
|
2005-12-28 02:57:01 +08:00
|
|
|
"gimp-dodge-burn",
|
|
|
|
_("Dodge/Burn"),
|
2005-12-28 04:51:24 +08:00
|
|
|
"gimp-tool-dodge");
|
2002-02-27 21:57:49 +08:00
|
|
|
}
|
|
|
|
|
1999-07-02 00:52:50 +08:00
|
|
|
static void
|
2003-02-05 22:39:40 +08:00
|
|
|
gimp_dodge_burn_class_init (GimpDodgeBurnClass *klass)
|
2001-03-24 10:27:16 +08:00
|
|
|
{
|
2004-05-26 04:41:09 +08:00
|
|
|
GimpPaintCoreClass *paint_core_class = GIMP_PAINT_CORE_CLASS (klass);
|
2004-05-28 04:48:49 +08:00
|
|
|
GimpBrushCoreClass *brush_core_class = GIMP_BRUSH_CORE_CLASS (klass);
|
2001-03-24 10:27:16 +08:00
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
paint_core_class->paint = gimp_dodge_burn_paint;
|
2004-05-28 04:48:49 +08:00
|
|
|
|
|
|
|
brush_core_class->handles_changing_brush = TRUE;
|
2001-03-31 23:45:05 +08:00
|
|
|
}
|
2001-03-24 10:27:16 +08:00
|
|
|
|
|
|
|
static void
|
2003-02-05 22:39:40 +08:00
|
|
|
gimp_dodge_burn_init (GimpDodgeBurn *dodgeburn)
|
1999-07-02 00:52:50 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-07-19 22:37:40 +08:00
|
|
|
gimp_dodge_burn_paint (GimpPaintCore *paint_core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options,
|
2016-01-28 02:13:17 +08:00
|
|
|
GimpSymmetry *sym,
|
2004-07-19 22:37:40 +08:00
|
|
|
GimpPaintState paint_state,
|
|
|
|
guint32 time)
|
1999-07-02 00:52:50 +08:00
|
|
|
{
|
2002-02-15 03:31:16 +08:00
|
|
|
switch (paint_state)
|
2001-04-07 19:01:22 +08:00
|
|
|
{
|
2004-07-19 22:37:40 +08:00
|
|
|
case GIMP_PAINT_STATE_INIT:
|
2001-04-07 19:01:22 +08:00
|
|
|
break;
|
|
|
|
|
2004-07-19 22:37:40 +08:00
|
|
|
case GIMP_PAINT_STATE_MOTION:
|
2016-01-28 02:13:17 +08:00
|
|
|
gimp_dodge_burn_motion (paint_core, drawable, paint_options, sym);
|
2001-04-07 19:01:22 +08:00
|
|
|
break;
|
|
|
|
|
2004-07-19 22:37:40 +08:00
|
|
|
case GIMP_PAINT_STATE_FINISH:
|
2001-04-07 19:01:22 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-02 00:52:50 +08:00
|
|
|
static void
|
2003-02-05 22:39:40 +08:00
|
|
|
gimp_dodge_burn_motion (GimpPaintCore *paint_core,
|
|
|
|
GimpDrawable *drawable,
|
2009-05-03 18:08:21 +08:00
|
|
|
GimpPaintOptions *paint_options,
|
2016-01-28 02:13:17 +08:00
|
|
|
GimpSymmetry *sym)
|
1999-07-02 00:52:50 +08:00
|
|
|
{
|
2012-04-03 01:17:57 +08:00
|
|
|
GimpDodgeBurnOptions *options = GIMP_DODGE_BURN_OPTIONS (paint_options);
|
|
|
|
GimpContext *context = GIMP_CONTEXT (paint_options);
|
|
|
|
GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics;
|
2012-04-28 17:42:33 +08:00
|
|
|
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
2012-04-03 01:17:57 +08:00
|
|
|
GeglBuffer *paint_buffer;
|
|
|
|
gint paint_buffer_x;
|
|
|
|
gint paint_buffer_y;
|
|
|
|
gdouble fade_point;
|
|
|
|
gdouble opacity;
|
2015-01-19 16:46:31 +08:00
|
|
|
gdouble force;
|
2016-01-28 02:13:17 +08:00
|
|
|
const GimpCoords *coords;
|
|
|
|
GeglNode *op;
|
|
|
|
gint paint_width, paint_height;
|
|
|
|
gint n_strokes;
|
|
|
|
gint i;
|
1999-07-02 00:52:50 +08:00
|
|
|
|
2009-10-14 02:30:54 +08:00
|
|
|
fade_point = gimp_paint_options_get_fade (paint_options, image,
|
|
|
|
paint_core->pixel_dist);
|
2003-07-16 19:25:37 +08:00
|
|
|
|
2016-01-28 02:13:17 +08:00
|
|
|
coords = gimp_symmetry_get_origin (sym);
|
2012-04-28 17:42:33 +08:00
|
|
|
opacity = gimp_dynamics_get_linear_value (dynamics,
|
|
|
|
GIMP_DYNAMICS_OUTPUT_OPACITY,
|
|
|
|
coords,
|
|
|
|
paint_options,
|
|
|
|
fade_point);
|
2003-07-16 19:25:37 +08:00
|
|
|
if (opacity == 0.0)
|
1999-07-02 00:52:50 +08:00
|
|
|
return;
|
|
|
|
|
2016-01-28 02:13:17 +08:00
|
|
|
gimp_brush_core_eval_transform_dynamics (GIMP_BRUSH_CORE (paint_core),
|
|
|
|
drawable,
|
|
|
|
paint_options,
|
|
|
|
coords);
|
|
|
|
n_strokes = gimp_symmetry_get_size (sym);
|
|
|
|
for (i = 0; i < n_strokes; i++)
|
|
|
|
{
|
|
|
|
coords = gimp_symmetry_get_coords (sym, i);
|
|
|
|
|
|
|
|
paint_buffer = gimp_paint_core_get_paint_buffer (paint_core, drawable,
|
2017-01-21 07:27:48 +08:00
|
|
|
paint_options,
|
2017-02-26 23:26:34 +08:00
|
|
|
GIMP_LAYER_MODE_NORMAL_LEGACY,
|
2017-01-21 07:27:48 +08:00
|
|
|
coords,
|
2016-01-28 02:13:17 +08:00
|
|
|
&paint_buffer_x,
|
|
|
|
&paint_buffer_y,
|
|
|
|
&paint_width,
|
|
|
|
&paint_height);
|
|
|
|
if (! paint_buffer)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
op = gimp_symmetry_get_operation (sym, i,
|
|
|
|
paint_width,
|
|
|
|
paint_height);
|
|
|
|
|
|
|
|
/* DodgeBurn the region */
|
|
|
|
gimp_gegl_dodgeburn (gimp_paint_core_get_orig_image (paint_core),
|
|
|
|
GEGL_RECTANGLE (paint_buffer_x,
|
|
|
|
paint_buffer_y,
|
|
|
|
gegl_buffer_get_width (paint_buffer),
|
|
|
|
gegl_buffer_get_height (paint_buffer)),
|
|
|
|
paint_buffer,
|
|
|
|
GEGL_RECTANGLE (0, 0, 0, 0),
|
|
|
|
options->exposure / 100.0,
|
|
|
|
options->type,
|
|
|
|
options->mode);
|
|
|
|
|
|
|
|
if (gimp_dynamics_is_output_enabled (dynamics, GIMP_DYNAMICS_OUTPUT_FORCE))
|
|
|
|
force = gimp_dynamics_get_linear_value (dynamics,
|
|
|
|
GIMP_DYNAMICS_OUTPUT_FORCE,
|
|
|
|
coords,
|
|
|
|
paint_options,
|
|
|
|
fade_point);
|
|
|
|
else
|
|
|
|
force = paint_options->brush_force;
|
|
|
|
|
|
|
|
/* Replace the newly dodgedburned area (paint_area) to the image */
|
|
|
|
gimp_brush_core_replace_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
|
|
|
|
coords,
|
|
|
|
MIN (opacity, GIMP_OPACITY_OPAQUE),
|
|
|
|
gimp_context_get_opacity (context),
|
|
|
|
gimp_paint_options_get_brush_mode (paint_options),
|
|
|
|
force,
|
|
|
|
GIMP_PAINT_CONSTANT, op);
|
|
|
|
}
|
1999-07-02 00:52:50 +08:00
|
|
|
}
|