Commit 53ff497a authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

app/base/curves.[ch] defined CURVES_NUM_POINTS and use it.

2004-09-24  Sven Neumann  <sven@gimp.org>

	* app/base/curves.[ch]
	* app/tools/gimpcurvestool.c: defined CURVES_NUM_POINTS and use it.

	* tools/pdbgen/pdb/color.pdb (curves_spline_invoker): unset the
	last control point which got initialized to (255,255) by
	curves_init(). Fixes bug #153635.

	* app/pdb/color_cmds.c: regenerated.
parent 9e7ebaf5
2004-09-24 Sven Neumann <sven@gimp.org>
* app/base/curves.[ch]
* app/tools/gimpcurvestool.c: defined CURVES_NUM_POINTS and use it.
* tools/pdbgen/pdb/color.pdb (curves_spline_invoker): unset the
last control point which got initialized to (255,255) by
curves_init(). Fixes bug #153635.
* app/pdb/color_cmds.c: regenerated.
2004-09-24 Sven Neumann <sven@gimp.org>
* app/plug-in/plug-in-message.c: removed a linebreak from a
......
......@@ -86,7 +86,7 @@ curves_channel_reset (Curves *curves,
for (j = 0; j < 256; j++)
curves->curve[channel][j] = j;
for (j = 0; j < 17; j++)
for (j = 0; j < CURVES_NUM_POINTS; j++)
{
curves->points[channel][j][0] = -1;
curves->points[channel][j][1] = -1;
......@@ -94,8 +94,8 @@ curves_channel_reset (Curves *curves,
curves->points[channel][0][0] = 0;
curves->points[channel][0][1] = 0;
curves->points[channel][16][0] = 255;
curves->points[channel][16][1] = 255;
curves->points[channel][CURVES_NUM_POINTS - 1][0] = 255;
curves->points[channel][CURVES_NUM_POINTS - 1][1] = 255;
}
void
......@@ -103,7 +103,7 @@ curves_calculate_curve (Curves *curves,
GimpHistogramChannel channel)
{
gint i;
gint points[17];
gint points[CURVES_NUM_POINTS];
gint num_pts;
gint p1, p2, p3, p4;
......@@ -117,7 +117,7 @@ curves_calculate_curve (Curves *curves,
case GIMP_CURVE_SMOOTH:
/* cycle through the curves */
num_pts = 0;
for (i = 0; i < 17; i++)
for (i = 0; i < CURVES_NUM_POINTS; i++)
if (curves->points[channel][i][0] != -1)
points[num_pts++] = i;
......
......@@ -19,11 +19,12 @@
#ifndef __CURVES_H__
#define __CURVES_H__
#define CURVES_NUM_POINTS 17
struct _Curves
{
GimpCurveType curve_type[5];
gint points[5][17][2];
gint points[5][CURVES_NUM_POINTS][2];
guchar curve[5][256];
};
......
......@@ -707,6 +707,10 @@ curves_spline_invoker (Gimp *gimp,
curves_init (&c);
/* unset the last point */
c.points[channel][CURVES_NUM_POINTS - 1][0] = -1;
c.points[channel][CURVES_NUM_POINTS - 1][1] = -1;
for (j = 0; j < num_points / 2; j++)
{
c.points[channel][j][0] = control_pts[j * 2];
......
......@@ -406,7 +406,7 @@ curves_add_point (GimpCurvesTool *tool,
curvex = tool->col_value[cchan];
distance = G_MAXINT;
for (i = 0; i < 17; i++)
for (i = 0; i < CURVES_NUM_POINTS; i++)
{
if (tool->curves->points[cchan][i][0] != -1)
if (abs (curvex - tool->curves->points[cchan][i][0]) < distance)
......@@ -663,8 +663,8 @@ gimp_curves_tool_settings_load (GimpImageMapTool *image_map_tool,
gint i, j;
gint fields;
gchar buf[50];
gint index[5][17];
gint value[5][17];
gint index[5][CURVES_NUM_POINTS];
gint value[5][CURVES_NUM_POINTS];
if (! fgets (buf, sizeof (buf), file))
return FALSE;
......@@ -674,7 +674,7 @@ gimp_curves_tool_settings_load (GimpImageMapTool *image_map_tool,
for (i = 0; i < 5; i++)
{
for (j = 0; j < 17; j++)
for (j = 0; j < CURVES_NUM_POINTS; j++)
{
fields = fscanf (file, "%d %d ", &index[i][j], &value[i][j]);
if (fields != 2)
......@@ -690,7 +690,7 @@ gimp_curves_tool_settings_load (GimpImageMapTool *image_map_tool,
{
tool->curves->curve_type[i] = GIMP_CURVE_SMOOTH;
for (j = 0; j < 17; j++)
for (j = 0; j < CURVES_NUM_POINTS; j++)
{
tool->curves->points[i][j][0] = index[i][j];
tool->curves->points[i][j][1] = value[i][j];
......@@ -734,7 +734,7 @@ gimp_curves_tool_settings_save (GimpImageMapTool *image_map_tool,
for (i = 0; i < 5; i++)
{
for (j = 0; j < 17; j++)
for (j = 0; j < CURVES_NUM_POINTS; j++)
fprintf (file, "%d %d ",
tool->curves->points[i][j][0],
tool->curves->points[i][j][1]);
......@@ -929,7 +929,7 @@ curves_graph_events (GtkWidget *widget,
y = CLAMP0255 (y);
distance = G_MAXINT;
for (i = 0, closest_point = 0; i < 17; i++)
for (i = 0, closest_point = 0; i < CURVES_NUM_POINTS; i++)
{
if (tool->curves->points[tool->channel][i][0] != -1)
if (abs (x - tool->curves->points[tool->channel][i][0]) < distance)
......@@ -964,7 +964,7 @@ curves_graph_events (GtkWidget *widget,
break;
}
tool->rightmost = 256;
for (i = closest_point + 1; i < 17; i++)
for (i = closest_point + 1; i < CURVES_NUM_POINTS; i++)
if (tool->curves->points[tool->channel][i][0] != -1)
{
tool->rightmost = tool->curves->points[tool->channel][i][0];
......@@ -1211,7 +1211,7 @@ curves_graph_expose (GtkWidget *widget,
if (tool->curves->curve_type[tool->channel] == GIMP_CURVE_SMOOTH)
{
/* Draw the points */
for (i = 0; i < 17; i++)
for (i = 0; i < CURVES_NUM_POINTS; i++)
{
x = tool->curves->points[tool->channel][i][0];
if (x < 0)
......
......@@ -432,6 +432,10 @@ HELP
curves_init (&c);
/* unset the last point */
c.points[channel][CURVES_NUM_POINTS - 1][0] = -1;
c.points[channel][CURVES_NUM_POINTS - 1][1] = -1;
for (j = 0; j < num_points / 2; j++)
{
c.points[channel][j][0] = control_pts[j * 2];
......
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