Commit 57211570 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

app/gegl/gimpoperationcolorize.[ch] app/gegl/gimpoperationlevels.[ch]

2008-01-15  Michael Natterer  <mitch@gimp.org>

	* app/gegl/gimpoperationcolorize.[ch]
	* app/gegl/gimpoperationlevels.[ch]
	* app/gegl/gimpoperationthreshold.[ch]: changed all properties from
	float to double.

	* app/gegl/gimpoperationcolorize.c: normalized property ranges to
	[0.0..1.0] or [-1.0..1.0] resp.

	* app/tools/gimpcolorizetool.c: changed accordingly.


svn path=/trunk/; revision=24621
parent c7b8f059
2008-01-15 Michael Natterer <mitch@gimp.org>
* app/gegl/gimpoperationcolorize.[ch]
* app/gegl/gimpoperationlevels.[ch]
* app/gegl/gimpoperationthreshold.[ch]: changed all properties from
float to double.
* app/gegl/gimpoperationcolorize.c: normalized property ranges to
[0.0..1.0] or [-1.0..1.0] resp.
* app/tools/gimpcolorizetool.c: changed accordingly.
2008-01-15 Michael Natterer <mitch@gimp.org>
* app/tools/gimpimagemaptool.c (gimp_image_map_tool_notify_preview):
......
......@@ -77,32 +77,29 @@ gimp_operation_colorize_class_init (GimpOperationColorizeClass * klass)
gegl_operation_class_set_name (operation_class, "gimp-colorize");
g_object_class_install_property (object_class,
PROP_HUE,
g_param_spec_float ("hue",
"Hue",
"Hue",
0.0, 360.0, 180.0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_SATURATION,
g_param_spec_float ("saturation",
"Saturation",
"Saturation",
0.0, 100.0, 50.0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_LIGHTNESS,
g_param_spec_float ("lightness",
"Lightness",
"Lightness",
-100.0, 100.0, 0.0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_HUE,
g_param_spec_double ("hue",
"Hue",
"Hue",
0.0, 1.0, 0.5,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_SATURATION,
g_param_spec_double ("saturation",
"Saturation",
"Saturation",
0.0, 1.0, 0.5,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_LIGHTNESS,
g_param_spec_double ("lightness",
"Lightness",
"Lightness",
-1.0, 1.0, 0.0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
}
static void
......@@ -121,15 +118,15 @@ gimp_operation_colorize_get_property (GObject *object,
switch (property_id)
{
case PROP_HUE:
g_value_set_float (value, self->hue);
g_value_set_double (value, self->hue);
break;
case PROP_SATURATION:
g_value_set_float (value, self->saturation);
g_value_set_double (value, self->saturation);
break;
case PROP_LIGHTNESS:
g_value_set_float (value, self->lightness);
g_value_set_double (value, self->lightness);
break;
default:
......@@ -149,15 +146,15 @@ gimp_operation_colorize_set_property (GObject *object,
switch (property_id)
{
case PROP_HUE:
self->hue = g_value_get_float (value);
self->hue = g_value_get_double (value);
break;
case PROP_SATURATION:
self->saturation = g_value_get_float (value);
self->saturation = g_value_get_double (value);
break;
case PROP_LIGHTNESS:
self->lightness = g_value_get_float (value);
self->lightness = g_value_get_double (value);
break;
default:
......@@ -187,17 +184,17 @@ gimp_operation_colorize_process (GeglOperation *operation,
if (self->lightness > 0)
{
lum = lum * (100.0 - self->lightness) / 100.0;
lum = lum * (1.0 - self->lightness);
lum += 1.0 - (100.0 - self->lightness) / 100.0;
lum += 1.0 - (1.0 - self->lightness);
}
else if (self->lightness < 0)
{
lum = lum * (self->lightness + 100.0) / 100.0;
lum = lum * (self->lightness + 1.0);
}
hsl.h = self->hue / 360.0;
hsl.s = self->saturation / 100.0;
hsl.h = self->hue;
hsl.s = self->saturation;
hsl.l = lum;
gimp_hsl_to_rgb (&hsl, &rgb);
......
......@@ -38,9 +38,9 @@ struct _GimpOperationColorize
{
GeglOperationPointFilter parent_instance;
gfloat hue;
gfloat saturation;
gfloat lightness;
gdouble hue;
gdouble saturation;
gdouble lightness;
};
struct _GimpOperationColorizeClass
......
......@@ -91,44 +91,44 @@ gimp_operation_levels_class_init (GimpOperationLevelsClass * klass)
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_GAMMA,
g_param_spec_float ("gamma",
"Gamma",
"Gamma",
0.1, 10.0, 1.0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_param_spec_double ("gamma",
"Gamma",
"Gamma",
0.1, 10.0, 1.0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_LOW_INPUT,
g_param_spec_float ("low-input",
"Low Input",
"Low Input",
0.0, 1.0, 0.0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_param_spec_double ("low-input",
"Low Input",
"Low Input",
0.0, 1.0, 0.0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_HIGH_INPUT,
g_param_spec_float ("high-input",
"High Input",
"High Input",
0.0, 1.0, 1.0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_param_spec_double ("high-input",
"High Input",
"High Input",
0.0, 1.0, 1.0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_LOW_OUTPUT,
g_param_spec_float ("low-output",
"Low Output",
"Low Output",
0.0, 1.0, 0.0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_param_spec_double ("low-output",
"Low Output",
"Low Output",
0.0, 1.0, 0.0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_HIGH_OUTPUT,
g_param_spec_float ("high-output",
"High Output",
"High Output",
0.0, 1.0, 1.0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_param_spec_double ("high-output",
"High Output",
"High Output",
0.0, 1.0, 1.0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
}
static void
......@@ -165,23 +165,23 @@ gimp_operation_levels_get_property (GObject *object,
break;
case PROP_GAMMA:
g_value_set_float (value, self->gamma[self->channel]);
g_value_set_double (value, self->gamma[self->channel]);
break;
case PROP_LOW_INPUT:
g_value_set_float (value, self->low_input[self->channel]);
g_value_set_double (value, self->low_input[self->channel]);
break;
case PROP_HIGH_INPUT:
g_value_set_float (value, self->high_input[self->channel]);
g_value_set_double (value, self->high_input[self->channel]);
break;
case PROP_LOW_OUTPUT:
g_value_set_float (value, self->low_output[self->channel]);
g_value_set_double (value, self->low_output[self->channel]);
break;
case PROP_HIGH_OUTPUT:
g_value_set_float (value, self->high_output[self->channel]);
g_value_set_double (value, self->high_output[self->channel]);
break;
default:
......@@ -205,23 +205,23 @@ gimp_operation_levels_set_property (GObject *object,
break;
case PROP_GAMMA:
self->gamma[self->channel] = g_value_get_float (value);
self->gamma[self->channel] = g_value_get_double (value);
break;
case PROP_LOW_INPUT:
self->low_input[self->channel] = g_value_get_float (value);
self->low_input[self->channel] = g_value_get_double (value);
break;
case PROP_HIGH_INPUT:
self->high_input[self->channel] = g_value_get_float (value);
self->high_input[self->channel] = g_value_get_double (value);
break;
case PROP_LOW_OUTPUT:
self->low_output[self->channel] = g_value_get_float (value);
self->low_output[self->channel] = g_value_get_double (value);
break;
case PROP_HIGH_OUTPUT:
self->high_output[self->channel] = g_value_get_float (value);
self->high_output[self->channel] = g_value_get_double (value);
break;
default:
......@@ -230,13 +230,13 @@ gimp_operation_levels_set_property (GObject *object,
}
}
static inline gfloat
gimp_operation_levels_map (gfloat value,
gfloat gamma,
gfloat low_input,
gfloat high_input,
gfloat low_output,
gfloat high_output)
static inline gdouble
gimp_operation_levels_map (gdouble value,
gdouble gamma,
gdouble low_input,
gdouble high_input,
gdouble low_output,
gdouble high_output)
{
/* determine input intensity */
if (high_input != low_input)
......@@ -278,7 +278,7 @@ gimp_operation_levels_process (GeglOperation *operation,
for (channel = 0; channel < 4; channel++)
{
gfloat value;
gdouble value;
value = gimp_operation_levels_map (src[channel],
self->gamma[channel + 1],
......@@ -288,7 +288,7 @@ gimp_operation_levels_process (GeglOperation *operation,
self->high_output[channel + 1]);
/* don't apply the overall curve to the alpha channel */
if (channel != 3)
if (channel != ALPHA_PIX)
value = gimp_operation_levels_map (value,
self->gamma[0],
self->low_input[0],
......
......@@ -42,13 +42,13 @@ struct _GimpOperationLevels
GimpHistogramChannel channel;
gfloat gamma[5];
gdouble gamma[5];
gfloat low_input[5];
gfloat high_input[5];
gdouble low_input[5];
gdouble high_input[5];
gfloat low_output[5];
gfloat high_output[5];
gdouble low_output[5];
gdouble high_output[5];
};
struct _GimpOperationLevelsClass
......
......@@ -76,23 +76,21 @@ gimp_operation_threshold_class_init (GimpOperationThresholdClass * klass)
gegl_operation_class_set_name (operation_class, "gimp-threshold");
g_object_class_install_property (object_class,
PROP_LOW,
g_param_spec_float ("low",
"Low",
"Low threshold",
0.0, 1.0, 0.5,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_HIGH,
g_param_spec_float ("high",
"High",
"High threshold",
0.0, 1.0, 1.0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_LOW,
g_param_spec_double ("low",
"Low",
"Low threshold",
0.0, 1.0, 0.5,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_HIGH,
g_param_spec_double ("high",
"High",
"High threshold",
0.0, 1.0, 1.0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
}
static void
......@@ -111,11 +109,11 @@ gimp_operation_threshold_get_property (GObject *object,
switch (property_id)
{
case PROP_LOW:
g_value_set_float (value, self->low);
g_value_set_double (value, self->low);
break;
case PROP_HIGH:
g_value_set_float (value, self->high);
g_value_set_double (value, self->high);
break;
default:
......@@ -135,11 +133,11 @@ gimp_operation_threshold_set_property (GObject *object,
switch (property_id)
{
case PROP_LOW:
self->low = g_value_get_float (value);
self->low = g_value_get_double (value);
break;
case PROP_HIGH:
self->high = g_value_get_float (value);
self->high = g_value_get_double (value);
break;
default:
......
......@@ -38,8 +38,8 @@ struct _GimpOperationThreshold
{
GeglOperationPointFilter parent_instance;
gfloat low;
gfloat high;
gdouble low;
gdouble high;
};
struct _GimpOperationThresholdClass
......
......@@ -172,9 +172,9 @@ gimp_colorize_tool_map (GimpImageMapTool *image_map_tool)
GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
gegl_node_set (image_map_tool->operation,
"hue", col_tool->colorize->hue,
"saturation", col_tool->colorize->saturation,
"lightness", col_tool->colorize->lightness,
"hue", col_tool->colorize->hue / 360.0,
"saturation", col_tool->colorize->saturation / 100.0,
"lightness", col_tool->colorize->lightness / 100.0,
NULL);
colorize_calculate (col_tool->colorize);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment