2008-01-23 17:28:16 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimpoperationcurves.c
|
|
|
|
* Copyright (C) 2007 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gegl.h>
|
|
|
|
|
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
|
|
|
|
#include "gegl-types.h"
|
|
|
|
|
2008-02-01 20:45:32 +08:00
|
|
|
#include "core/gimpcurve.h"
|
2008-05-11 22:56:57 +08:00
|
|
|
#include "core/gimpcurve-map.h"
|
2008-02-01 20:45:32 +08:00
|
|
|
|
2008-01-23 17:28:16 +08:00
|
|
|
#include "gimpcurvesconfig.h"
|
|
|
|
#include "gimpoperationcurves.h"
|
|
|
|
|
|
|
|
|
2008-06-11 17:42:22 +08:00
|
|
|
static gboolean gimp_operation_curves_process (GeglOperation *operation,
|
|
|
|
void *in_buf,
|
|
|
|
void *out_buf,
|
|
|
|
glong samples,
|
|
|
|
const GeglRectangle *roi);
|
2008-01-23 17:28:16 +08:00
|
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GimpOperationCurves, gimp_operation_curves,
|
2008-01-26 04:50:32 +08:00
|
|
|
GIMP_TYPE_OPERATION_POINT_FILTER)
|
2008-01-23 17:28:16 +08:00
|
|
|
|
|
|
|
#define parent_class gimp_operation_curves_parent_class
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2008-01-26 04:50:32 +08:00
|
|
|
gimp_operation_curves_class_init (GimpOperationCurvesClass *klass)
|
2008-01-23 17:28:16 +08:00
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
|
|
|
|
GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
|
|
|
|
|
2008-02-13 00:56:36 +08:00
|
|
|
object_class->set_property = gimp_operation_point_filter_set_property;
|
|
|
|
object_class->get_property = gimp_operation_point_filter_get_property;
|
2008-01-23 17:28:16 +08:00
|
|
|
|
2008-02-13 00:56:36 +08:00
|
|
|
operation_class->name = "gimp-curves";
|
|
|
|
operation_class->categories = "color";
|
|
|
|
operation_class->description = "GIMP Curves operation";
|
2008-01-23 17:28:16 +08:00
|
|
|
|
2008-02-13 00:56:36 +08:00
|
|
|
point_class->process = gimp_operation_curves_process;
|
2008-01-31 01:44:06 +08:00
|
|
|
|
2008-01-26 04:50:32 +08:00
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
GIMP_OPERATION_POINT_FILTER_PROP_CONFIG,
|
2008-01-23 17:28:16 +08:00
|
|
|
g_param_spec_object ("config",
|
|
|
|
"Config",
|
|
|
|
"The config object",
|
|
|
|
GIMP_TYPE_CURVES_CONFIG,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_operation_curves_init (GimpOperationCurves *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2008-06-11 17:42:22 +08:00
|
|
|
gimp_operation_curves_process (GeglOperation *operation,
|
|
|
|
void *in_buf,
|
|
|
|
void *out_buf,
|
|
|
|
glong samples,
|
|
|
|
const GeglRectangle *roi)
|
2008-01-23 17:28:16 +08:00
|
|
|
{
|
2008-01-26 04:50:32 +08:00
|
|
|
GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation);
|
|
|
|
GimpCurvesConfig *config = GIMP_CURVES_CONFIG (point->config);
|
|
|
|
gfloat *src = in_buf;
|
|
|
|
gfloat *dest = out_buf;
|
2008-01-23 17:28:16 +08:00
|
|
|
|
|
|
|
if (! config)
|
|
|
|
return FALSE;
|
|
|
|
|
2008-05-11 22:48:22 +08:00
|
|
|
gimp_curve_map_pixels (config->curve[0],
|
|
|
|
config->curve[1],
|
|
|
|
config->curve[2],
|
|
|
|
config->curve[3],
|
|
|
|
config->curve[4], src, dest, samples);
|
2008-01-23 17:28:16 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|