diff --git a/ChangeLog b/ChangeLog index 2024bca6b1..57bb88b2de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2004-09-24 Sven Neumann + + * 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 * app/plug-in/plug-in-message.c: removed a linebreak from a diff --git a/app/base/curves.c b/app/base/curves.c index c60c5bc569..6a71615f3c 100644 --- a/app/base/curves.c +++ b/app/base/curves.c @@ -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; diff --git a/app/base/curves.h b/app/base/curves.h index 82ca004915..c35ab05d9d 100644 --- a/app/base/curves.h +++ b/app/base/curves.h @@ -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]; }; diff --git a/app/pdb/color_cmds.c b/app/pdb/color_cmds.c index 34cb4189e2..be2b413311 100644 --- a/app/pdb/color_cmds.c +++ b/app/pdb/color_cmds.c @@ -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]; diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c index 093fcc4922..a941940bf1 100644 --- a/app/tools/gimpcurvestool.c +++ b/app/tools/gimpcurvestool.c @@ -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) diff --git a/tools/pdbgen/pdb/color.pdb b/tools/pdbgen/pdb/color.pdb index 8e50bee532..ccec2c3778 100644 --- a/tools/pdbgen/pdb/color.pdb +++ b/tools/pdbgen/pdb/color.pdb @@ -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];