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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "base/gimplut.h"
|
|
|
|
#include "base/pixel-region.h"
|
|
|
|
#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"
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimpimage.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
|
|
|
|
2004-05-26 04:41:09 +08:00
|
|
|
static void gimp_dodge_burn_finalize (GObject *object);
|
|
|
|
|
|
|
|
static void gimp_dodge_burn_paint (GimpPaintCore *paint_core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options,
|
2004-07-19 22:37:40 +08:00
|
|
|
GimpPaintState paint_state,
|
2004-05-27 00:13:53 +08:00
|
|
|
guint32 time);
|
2004-05-26 04:41:09 +08:00
|
|
|
static void gimp_dodge_burn_motion (GimpPaintCore *paint_core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options);
|
|
|
|
|
|
|
|
static void gimp_dodge_burn_make_luts (GimpDodgeBurn *dodgeburn,
|
|
|
|
gdouble db_exposure,
|
|
|
|
GimpDodgeBurnType type,
|
|
|
|
GimpTransferMode mode,
|
|
|
|
GimpDrawable *drawable);
|
|
|
|
|
|
|
|
static gfloat gimp_dodge_burn_highlights_lut_func (gpointer user_data,
|
|
|
|
gint nchannels,
|
|
|
|
gint channel,
|
|
|
|
gfloat value);
|
|
|
|
static gfloat gimp_dodge_burn_midtones_lut_func (gpointer user_data,
|
|
|
|
gint nchannels,
|
|
|
|
gint channel,
|
|
|
|
gfloat value);
|
|
|
|
static gfloat gimp_dodge_burn_shadows_lut_func (gpointer user_data,
|
|
|
|
gint nchannels,
|
|
|
|
gint channel,
|
|
|
|
gfloat value);
|
|
|
|
|
|
|
|
|
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
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
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
|
|
|
object_class->finalize = gimp_dodge_burn_finalize;
|
2002-06-09 21:56:09 +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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-06-09 21:56:09 +08:00
|
|
|
static void
|
2003-02-05 22:39:40 +08:00
|
|
|
gimp_dodge_burn_finalize (GObject *object)
|
1999-07-02 00:52:50 +08:00
|
|
|
{
|
2004-05-26 04:41:09 +08:00
|
|
|
GimpDodgeBurn *dodgeburn = GIMP_DODGE_BURN (object);
|
1999-07-02 00:52:50 +08:00
|
|
|
|
2002-06-09 21:56:09 +08:00
|
|
|
if (dodgeburn->lut)
|
1999-07-02 00:52:50 +08:00
|
|
|
{
|
2002-06-09 21:56:09 +08:00
|
|
|
gimp_lut_free (dodgeburn->lut);
|
|
|
|
dodgeburn->lut = NULL;
|
1999-07-02 00:52:50 +08:00
|
|
|
}
|
|
|
|
|
2002-06-09 21:56:09 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
1999-07-02 00:52:50 +08:00
|
|
|
}
|
2001-03-31 23:45:05 +08:00
|
|
|
|
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,
|
|
|
|
GimpPaintState paint_state,
|
|
|
|
guint32 time)
|
1999-07-02 00:52:50 +08:00
|
|
|
{
|
2004-05-26 04:41:09 +08:00
|
|
|
GimpDodgeBurn *dodgeburn = GIMP_DODGE_BURN (paint_core);
|
|
|
|
GimpDodgeBurnOptions *options = GIMP_DODGE_BURN_OPTIONS (paint_options);
|
2002-06-09 21:56:09 +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:
|
2002-06-09 21:56:09 +08:00
|
|
|
dodgeburn->lut = gimp_lut_new ();
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
gimp_dodge_burn_make_luts (dodgeburn,
|
|
|
|
options->exposure,
|
|
|
|
options->type,
|
|
|
|
options->mode,
|
|
|
|
drawable);
|
2001-04-07 19:01:22 +08:00
|
|
|
break;
|
|
|
|
|
2004-07-19 22:37:40 +08:00
|
|
|
case GIMP_PAINT_STATE_MOTION:
|
2003-02-05 22:39:40 +08:00
|
|
|
gimp_dodge_burn_motion (paint_core, drawable, paint_options);
|
2001-04-07 19:01:22 +08:00
|
|
|
break;
|
|
|
|
|
2004-07-19 22:37:40 +08:00
|
|
|
case GIMP_PAINT_STATE_FINISH:
|
2002-06-09 21:56:09 +08:00
|
|
|
if (dodgeburn->lut)
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
|
|
|
gimp_lut_free (dodgeburn->lut);
|
|
|
|
dodgeburn->lut = NULL;
|
|
|
|
}
|
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,
|
|
|
|
GimpPaintOptions *paint_options)
|
1999-07-02 00:52:50 +08:00
|
|
|
{
|
2008-05-10 18:03:21 +08:00
|
|
|
GimpDodgeBurn *dodgeburn = GIMP_DODGE_BURN (paint_core);
|
|
|
|
GimpContext *context = GIMP_CONTEXT (paint_options);
|
|
|
|
GimpImage *image;
|
|
|
|
TempBuf *area;
|
|
|
|
TempBuf *orig;
|
|
|
|
PixelRegion srcPR, destPR, tempPR;
|
|
|
|
guchar *temp_data;
|
|
|
|
gdouble opacity;
|
2008-05-23 00:38:57 +08:00
|
|
|
gdouble hardness;
|
1999-07-02 00:52:50 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
image = gimp_item_get_image (GIMP_ITEM (drawable));
|
1999-07-02 00:52:50 +08:00
|
|
|
|
2003-07-16 19:25:37 +08:00
|
|
|
if (gimp_drawable_is_indexed (drawable))
|
|
|
|
return;
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
opacity = gimp_paint_options_get_fade (paint_options, image,
|
2003-07-16 19:25:37 +08:00
|
|
|
paint_core->pixel_dist);
|
|
|
|
if (opacity == 0.0)
|
1999-07-02 00:52:50 +08:00
|
|
|
return;
|
|
|
|
|
2004-05-26 17:32:03 +08:00
|
|
|
area = gimp_paint_core_get_paint_area (paint_core, drawable, paint_options);
|
|
|
|
if (! area)
|
1999-07-02 00:52:50 +08:00
|
|
|
return;
|
|
|
|
|
2001-03-31 23:45:05 +08:00
|
|
|
/* Constant painting --get a copy of the orig drawable (with no
|
|
|
|
* paint from this stroke yet)
|
|
|
|
*/
|
1999-07-02 00:52:50 +08:00
|
|
|
{
|
2004-05-28 17:34:13 +08:00
|
|
|
GimpItem *item = GIMP_ITEM (drawable);
|
2003-05-08 21:12:46 +08:00
|
|
|
gint x1, y1, x2, y2;
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2008-11-03 08:09:01 +08:00
|
|
|
x1 = CLAMP (area->x, 0, gimp_item_get_width (item));
|
|
|
|
y1 = CLAMP (area->y, 0, gimp_item_get_height (item));
|
|
|
|
x2 = CLAMP (area->x + area->width, 0, gimp_item_get_width (item));
|
|
|
|
y2 = CLAMP (area->y + area->height, 0, gimp_item_get_height (item));
|
2000-12-31 12:07:42 +08:00
|
|
|
|
|
|
|
if (!(x2 - x1) || !(y2 - y1))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* get the original untouched image */
|
2002-02-15 03:31:16 +08:00
|
|
|
orig = gimp_paint_core_get_orig_image (paint_core, drawable, x1, y1, x2, y2);
|
|
|
|
|
2005-09-04 01:16:58 +08:00
|
|
|
pixel_region_init_temp_buf (&srcPR, orig,
|
|
|
|
0, 0, x2 - x1, y2 - y1);
|
2000-12-31 12:07:42 +08:00
|
|
|
}
|
1999-07-02 00:52:50 +08:00
|
|
|
|
2003-07-16 19:25:37 +08:00
|
|
|
/* tempPR will hold the dodgeburned region */
|
2005-09-04 01:16:58 +08:00
|
|
|
temp_data = g_malloc (srcPR.h * srcPR.bytes * srcPR.w);
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2005-09-04 01:16:58 +08:00
|
|
|
pixel_region_init_data (&tempPR, temp_data,
|
|
|
|
srcPR.bytes,
|
|
|
|
srcPR.bytes * srcPR.w,
|
|
|
|
srcPR.x,
|
|
|
|
srcPR.y,
|
|
|
|
srcPR.w,
|
|
|
|
srcPR.h);
|
1999-07-02 00:52:50 +08:00
|
|
|
|
|
|
|
/* DodgeBurn the region */
|
2002-06-09 21:56:09 +08:00
|
|
|
gimp_lut_process (dodgeburn->lut, &srcPR, &tempPR);
|
1999-07-02 00:52:50 +08:00
|
|
|
|
2003-07-14 22:50:41 +08:00
|
|
|
/* The dest is the paint area we got above (= canvas_buf) */
|
2005-09-04 01:16:58 +08:00
|
|
|
pixel_region_init_temp_buf (&destPR, area,
|
|
|
|
0, 0, area->width, area->height);
|
1999-07-02 00:52:50 +08:00
|
|
|
|
2003-07-14 22:50:41 +08:00
|
|
|
/* Now add an alpha to the dodgeburned region
|
2003-07-16 19:25:37 +08:00
|
|
|
* and put this in area = canvas_buf
|
|
|
|
*/
|
2001-01-15 05:11:52 +08:00
|
|
|
if (! gimp_drawable_has_alpha (drawable))
|
1999-07-02 00:52:50 +08:00
|
|
|
add_alpha_region (&tempPR, &destPR);
|
|
|
|
else
|
1999-11-13 09:02:27 +08:00
|
|
|
copy_region (&tempPR, &destPR);
|
1999-07-02 00:52:50 +08:00
|
|
|
|
2008-04-25 21:39:36 +08:00
|
|
|
g_free (temp_data);
|
|
|
|
|
2008-05-10 18:03:21 +08:00
|
|
|
opacity *= gimp_paint_options_get_dynamic_opacity (paint_options,
|
2008-07-18 03:00:13 +08:00
|
|
|
&paint_core->cur_coords);
|
1999-09-09 09:47:54 +08:00
|
|
|
|
2008-05-23 00:38:57 +08:00
|
|
|
hardness = gimp_paint_options_get_dynamic_hardness (paint_options,
|
2008-07-18 03:00:13 +08:00
|
|
|
&paint_core->cur_coords);
|
2008-05-23 00:38:57 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
/* Replace the newly dodgedburned area (canvas_buf) to the image */
|
2004-05-26 04:41:09 +08:00
|
|
|
gimp_brush_core_replace_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
|
2006-04-12 20:49:29 +08:00
|
|
|
MIN (opacity, GIMP_OPACITY_OPAQUE),
|
|
|
|
gimp_context_get_opacity (context),
|
|
|
|
gimp_paint_options_get_brush_mode (paint_options),
|
2008-05-23 00:38:57 +08:00
|
|
|
hardness,
|
2002-06-09 21:56:09 +08:00
|
|
|
GIMP_PAINT_CONSTANT);
|
1999-07-02 00:52:50 +08:00
|
|
|
}
|
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
static void
|
|
|
|
gimp_dodge_burn_make_luts (GimpDodgeBurn *dodgeburn,
|
|
|
|
gdouble db_exposure,
|
|
|
|
GimpDodgeBurnType type,
|
|
|
|
GimpTransferMode mode,
|
|
|
|
GimpDrawable *drawable)
|
2002-06-09 21:56:09 +08:00
|
|
|
{
|
|
|
|
GimpLutFunc lut_func;
|
|
|
|
gint nchannels = gimp_drawable_bytes (drawable);
|
|
|
|
static gfloat exposure;
|
|
|
|
|
|
|
|
exposure = db_exposure / 100.0;
|
|
|
|
|
|
|
|
/* make the exposure negative if burn for luts*/
|
|
|
|
if (type == GIMP_BURN)
|
|
|
|
exposure = -exposure;
|
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case GIMP_HIGHLIGHTS:
|
2003-07-14 22:50:41 +08:00
|
|
|
lut_func = gimp_dodge_burn_highlights_lut_func;
|
2002-06-09 21:56:09 +08:00
|
|
|
break;
|
|
|
|
case GIMP_MIDTONES:
|
2003-07-14 22:50:41 +08:00
|
|
|
lut_func = gimp_dodge_burn_midtones_lut_func;
|
2002-06-09 21:56:09 +08:00
|
|
|
break;
|
|
|
|
case GIMP_SHADOWS:
|
2003-07-14 22:50:41 +08:00
|
|
|
lut_func = gimp_dodge_burn_shadows_lut_func;
|
2002-06-09 21:56:09 +08:00
|
|
|
break;
|
|
|
|
default:
|
2003-07-14 22:50:41 +08:00
|
|
|
lut_func = NULL;
|
2002-06-09 21:56:09 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_lut_setup_exact (dodgeburn->lut,
|
2006-04-12 20:49:29 +08:00
|
|
|
lut_func, (gpointer) &exposure,
|
|
|
|
nchannels);
|
2002-06-09 21:56:09 +08:00
|
|
|
}
|
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
static gfloat
|
2003-07-14 22:50:41 +08:00
|
|
|
gimp_dodge_burn_highlights_lut_func (gpointer user_data,
|
|
|
|
gint nchannels,
|
|
|
|
gint channel,
|
2003-02-05 22:39:40 +08:00
|
|
|
gfloat value)
|
2001-04-07 19:01:22 +08:00
|
|
|
{
|
|
|
|
gfloat *exposure_ptr = (gfloat *) user_data;
|
|
|
|
gfloat exposure = *exposure_ptr;
|
|
|
|
gfloat factor = 1.0 + exposure * (.333333);
|
|
|
|
|
|
|
|
if ((nchannels == 2 && channel == 1) ||
|
|
|
|
(nchannels == 4 && channel == 3))
|
|
|
|
return value;
|
|
|
|
|
|
|
|
return factor * value;
|
|
|
|
}
|
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
static gfloat
|
2003-07-14 22:50:41 +08:00
|
|
|
gimp_dodge_burn_midtones_lut_func (gpointer user_data,
|
|
|
|
gint nchannels,
|
|
|
|
gint channel,
|
2003-02-05 22:39:40 +08:00
|
|
|
gfloat value)
|
2001-04-07 19:01:22 +08:00
|
|
|
{
|
|
|
|
gfloat *exposure_ptr = (gfloat *) user_data;
|
|
|
|
gfloat exposure = *exposure_ptr;
|
|
|
|
gfloat factor;
|
|
|
|
|
|
|
|
if ((nchannels == 2 && channel == 1) ||
|
|
|
|
(nchannels == 4 && channel == 3))
|
|
|
|
return value;
|
|
|
|
|
|
|
|
if (exposure < 0)
|
|
|
|
factor = 1.0 - exposure * (.333333);
|
|
|
|
else
|
2002-03-04 01:38:12 +08:00
|
|
|
factor = 1 / (1.0 + exposure);
|
1999-07-02 00:52:50 +08:00
|
|
|
|
2003-07-14 22:50:41 +08:00
|
|
|
return pow (value, factor);
|
2001-04-07 19:01:22 +08:00
|
|
|
}
|
2001-03-24 10:27:16 +08:00
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
static gfloat
|
2003-07-14 22:50:41 +08:00
|
|
|
gimp_dodge_burn_shadows_lut_func (gpointer user_data,
|
|
|
|
gint nchannels,
|
|
|
|
gint channel,
|
2003-02-05 22:39:40 +08:00
|
|
|
gfloat value)
|
2001-03-31 23:45:05 +08:00
|
|
|
{
|
2001-04-07 19:01:22 +08:00
|
|
|
gfloat *exposure_ptr = (gfloat *) user_data;
|
|
|
|
gfloat exposure = *exposure_ptr;
|
|
|
|
gfloat new_value;
|
|
|
|
gfloat factor;
|
|
|
|
|
|
|
|
if ((nchannels == 2 && channel == 1) ||
|
|
|
|
(nchannels == 4 && channel == 3))
|
|
|
|
return value;
|
|
|
|
|
|
|
|
if (exposure >= 0)
|
|
|
|
{
|
|
|
|
factor = 0.333333 * exposure;
|
2003-07-14 22:50:41 +08:00
|
|
|
new_value = factor + value - factor * value;
|
2001-04-07 19:01:22 +08:00
|
|
|
}
|
2003-07-14 22:50:41 +08:00
|
|
|
else /* exposure < 0 */
|
2001-04-07 19:01:22 +08:00
|
|
|
{
|
|
|
|
factor = -0.333333 * exposure;
|
|
|
|
if (value < factor)
|
2006-04-12 20:49:29 +08:00
|
|
|
new_value = 0;
|
2001-04-07 19:01:22 +08:00
|
|
|
else /*factor <= value <=1*/
|
2006-04-12 20:49:29 +08:00
|
|
|
new_value = (value - factor)/(1 - factor);
|
2001-04-07 19:01:22 +08:00
|
|
|
}
|
2001-03-31 23:45:05 +08:00
|
|
|
|
2003-07-14 22:50:41 +08:00
|
|
|
return new_value;
|
2001-03-31 23:45:05 +08:00
|
|
|
}
|