gimp r24708 - in trunk: . app/gegl app/tools
- From: mitch svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r24708 - in trunk: . app/gegl app/tools
- Date: Fri, 25 Jan 2008 13:02:37 +0000 (GMT)
Author: mitch
Date: Fri Jan 25 13:02:37 2008
New Revision: 24708
URL: http://svn.gnome.org/viewvc/gimp?rev=24708&view=rev
Log:
2008-01-25 Michael Natterer <mitch gimp org>
* app/gegl/gimpcurvesconfig.[ch]
* app/gegl/gimplevelsconfig.[ch]: add load_cruft() and
save_cruft() functions which load/save the old (current) curves
and levels file formats.
* app/tools/gimpcurvestool.c
* app/tools/gimplevelstool.c: use them here and remove a lot of
includes.
Modified:
trunk/ChangeLog
trunk/app/gegl/gimpcurvesconfig.c
trunk/app/gegl/gimpcurvesconfig.h
trunk/app/gegl/gimplevelsconfig.c
trunk/app/gegl/gimplevelsconfig.h
trunk/app/tools/gimpcurvestool.c
trunk/app/tools/gimplevelstool.c
Modified: trunk/app/gegl/gimpcurvesconfig.c
==============================================================================
--- trunk/app/gegl/gimpcurvesconfig.c (original)
+++ trunk/app/gegl/gimpcurvesconfig.c Fri Jan 25 13:02:37 2008
@@ -21,10 +21,13 @@
#include "config.h"
+#include <string.h>
+
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpmath/gimpmath.h"
+#include "libgimpconfig/gimpconfig.h"
#include "gegl-types.h"
@@ -35,6 +38,8 @@
#include "gimpcurvesconfig.h"
+#include "gimp-intl.h"
+
enum
{
@@ -200,6 +205,105 @@
gimp_curve_reset (config->curve[channel], FALSE);
}
+gboolean
+gimp_curves_config_load_cruft (GimpCurvesConfig *config,
+ gpointer fp,
+ GError **error)
+{
+ FILE *file = fp;
+ gint i, j;
+ gint fields;
+ gchar buf[50];
+ gint index[5][GIMP_CURVE_NUM_POINTS];
+ gint value[5][GIMP_CURVE_NUM_POINTS];
+
+ g_return_val_if_fail (GIMP_IS_CURVES_CONFIG (config), FALSE);
+ g_return_val_if_fail (file != NULL, FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ if (! fgets (buf, sizeof (buf), file) ||
+ strcmp (buf, "# GIMP Curves File\n") != 0)
+ {
+ g_set_error (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_PARSE,
+ _("not a GIMP Curves file"));
+ return FALSE;
+ }
+
+ for (i = 0; i < 5; i++)
+ {
+ for (j = 0; j < GIMP_CURVE_NUM_POINTS; j++)
+ {
+ fields = fscanf (file, "%d %d ", &index[i][j], &value[i][j]);
+ if (fields != 2)
+ {
+ /* FIXME: should have a helpful error message here */
+ g_printerr ("fields != 2");
+ g_set_error (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_PARSE,
+ _("parse error"));
+ return FALSE;
+ }
+ }
+ }
+
+ for (i = 0; i < 5; i++)
+ {
+ GimpCurve *curve = config->curve[i];
+
+ gimp_data_freeze (GIMP_DATA (curve));
+
+ gimp_curve_set_curve_type (curve, GIMP_CURVE_SMOOTH);
+
+ for (j = 0; j < GIMP_CURVE_NUM_POINTS; j++)
+ gimp_curve_set_point (curve, j, index[i][j], value[i][j]);
+
+ gimp_data_thaw (GIMP_DATA (curve));
+ }
+
+ return TRUE;
+}
+
+gboolean
+gimp_curves_config_save_cruft (GimpCurvesConfig *config,
+ gpointer fp)
+{
+ FILE *file = fp;
+ gint i, j;
+ gint32 index;
+
+ g_return_val_if_fail (GIMP_IS_CURVES_CONFIG (config), FALSE);
+ g_return_val_if_fail (file != NULL, FALSE);
+
+ fprintf (file, "# GIMP Curves File\n");
+
+ for (i = 0; i < 5; i++)
+ {
+ GimpCurve *curve = config->curve[i];
+
+ if (curve->curve_type == GIMP_CURVE_FREE)
+ {
+ /* pick representative points from the curve and make them
+ * control points
+ */
+ for (j = 0; j <= 8; j++)
+ {
+ index = CLAMP0255 (j * 32);
+
+ curve->points[j * 2][0] = index;
+ curve->points[j * 2][1] = curve->curve[index];
+ }
+ }
+
+ for (j = 0; j < GIMP_CURVE_NUM_POINTS; j++)
+ fprintf (file, "%d %d ",
+ curve->points[j][0],
+ curve->points[j][1]);
+
+ fprintf (file, "\n");
+ }
+
+ return TRUE;
+}
+
/* temp cruft */
Modified: trunk/app/gegl/gimpcurvesconfig.h
==============================================================================
--- trunk/app/gegl/gimpcurvesconfig.h (original)
+++ trunk/app/gegl/gimpcurvesconfig.h Fri Jan 25 13:02:37 2008
@@ -53,17 +53,23 @@
};
-GType gimp_curves_config_get_type (void) G_GNUC_CONST;
+GType gimp_curves_config_get_type (void) G_GNUC_CONST;
-void gimp_curves_config_reset (GimpCurvesConfig *config);
-void gimp_curves_config_reset_channel (GimpCurvesConfig *config,
- GimpHistogramChannel channel);
+void gimp_curves_config_reset (GimpCurvesConfig *config);
+void gimp_curves_config_reset_channel (GimpCurvesConfig *config,
+ GimpHistogramChannel channel);
+
+gboolean gimp_curves_config_load_cruft (GimpCurvesConfig *config,
+ gpointer fp,
+ GError **error);
+gboolean gimp_curves_config_save_cruft (GimpCurvesConfig *config,
+ gpointer fp);
/* temp cruft */
-void gimp_curves_config_to_cruft (GimpCurvesConfig *config,
- Curves *cruft,
- gboolean is_color);
+void gimp_curves_config_to_cruft (GimpCurvesConfig *config,
+ Curves *cruft,
+ gboolean is_color);
#endif /* __GIMP_CURVES_CONFIG_H__ */
Modified: trunk/app/gegl/gimplevelsconfig.c
==============================================================================
--- trunk/app/gegl/gimplevelsconfig.c (original)
+++ trunk/app/gegl/gimplevelsconfig.c Fri Jan 25 13:02:37 2008
@@ -21,10 +21,15 @@
#include "config.h"
+#include <errno.h>
+#include <string.h>
+
#include <gegl.h>
+#include <glib/gstdio.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpmath/gimpmath.h"
+#include "libgimpconfig/gimpconfig.h"
#include "gegl-types.h"
@@ -35,6 +40,8 @@
#include "gimplevelsconfig.h"
+#include "gimp-intl.h"
+
enum
{
@@ -413,6 +420,99 @@
}
}
+gboolean
+gimp_levels_config_load_cruft (GimpLevelsConfig *config,
+ gpointer fp,
+ GError **error)
+{
+ FILE *file = fp;
+ gint low_input[5];
+ gint high_input[5];
+ gint low_output[5];
+ gint high_output[5];
+ gdouble gamma[5];
+ gint i;
+ gint fields;
+ gchar buf[50];
+ gchar *nptr;
+
+ g_return_val_if_fail (GIMP_IS_LEVELS_CONFIG (config), FALSE);
+ g_return_val_if_fail (file != NULL, FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ if (! fgets (buf, sizeof (buf), file) ||
+ strcmp (buf, "# GIMP Levels File\n") != 0)
+ {
+ g_set_error (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_PARSE,
+ _("not a GIMP Levels file"));
+ return FALSE;
+ }
+
+ for (i = 0; i < 5; i++)
+ {
+ fields = fscanf (file, "%d %d %d %d ",
+ &low_input[i],
+ &high_input[i],
+ &low_output[i],
+ &high_output[i]);
+
+ if (fields != 4)
+ goto error;
+
+ if (! fgets (buf, 50, file))
+ goto error;
+
+ gamma[i] = g_ascii_strtod (buf, &nptr);
+
+ if (buf == nptr || errno == ERANGE)
+ goto error;
+ }
+
+ for (i = 0; i < 5; i++)
+ {
+ config->low_input[i] = low_input[i] / 255.0;
+ config->high_input[i] = high_input[i] / 255.0;
+ config->low_output[i] = low_output[i] / 255.0;
+ config->high_output[i] = high_output[i] / 255.0;
+ config->gamma[i] = gamma[i];
+ }
+
+ return TRUE;
+
+ error:
+ g_set_error (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_PARSE,
+ _("parse error"));
+ return FALSE;
+}
+
+gboolean
+gimp_levels_config_save_cruft (GimpLevelsConfig *config,
+ gpointer fp)
+{
+ FILE *file = fp;
+ gint i;
+
+ g_return_val_if_fail (GIMP_IS_LEVELS_CONFIG (config), FALSE);
+ g_return_val_if_fail (file != NULL, FALSE);
+
+ fprintf (file, "# GIMP Levels File\n");
+
+ for (i = 0; i < 5; i++)
+ {
+ gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
+
+ fprintf (file, "%d %d %d %d %s\n",
+ (gint) (config->low_input[i] * 255.999),
+ (gint) (config->high_input[i] * 255.999),
+ (gint) (config->low_output[i] * 255.999),
+ (gint) (config->high_output[i] * 255.999),
+ g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
+ config->gamma[i]));
+ }
+
+ return TRUE;
+}
+
/* temp cruft */
Modified: trunk/app/gegl/gimplevelsconfig.h
==============================================================================
--- trunk/app/gegl/gimplevelsconfig.h (original)
+++ trunk/app/gegl/gimplevelsconfig.h Fri Jan 25 13:02:37 2008
@@ -54,28 +54,35 @@
};
-GType gimp_levels_config_get_type (void) G_GNUC_CONST;
+GType gimp_levels_config_get_type (void) G_GNUC_CONST;
+
+void gimp_levels_config_reset (GimpLevelsConfig *config);
+void gimp_levels_config_reset_channel (GimpLevelsConfig *config,
+ GimpHistogramChannel channel);
+
+void gimp_levels_config_stretch (GimpLevelsConfig *config,
+ GimpHistogram *histogram,
+ gboolean is_color);
+void gimp_levels_config_stretch_channel (GimpLevelsConfig *config,
+ GimpHistogram *histogram,
+ GimpHistogramChannel channel);
+void gimp_levels_config_adjust_by_colors (GimpLevelsConfig *config,
+ GimpHistogramChannel channel,
+ const GimpRGB *black,
+ const GimpRGB *gray,
+ const GimpRGB *white);
+
+gboolean gimp_levels_config_load_cruft (GimpLevelsConfig *config,
+ gpointer fp,
+ GError **error);
+gboolean gimp_levels_config_save_cruft (GimpLevelsConfig *config,
+ gpointer fp);
-void gimp_levels_config_reset (GimpLevelsConfig *config);
-void gimp_levels_config_reset_channel (GimpLevelsConfig *config,
- GimpHistogramChannel channel);
-
-void gimp_levels_config_stretch (GimpLevelsConfig *config,
- GimpHistogram *histogram,
- gboolean is_color);
-void gimp_levels_config_stretch_channel (GimpLevelsConfig *config,
- GimpHistogram *histogram,
- GimpHistogramChannel channel);
-void gimp_levels_config_adjust_by_colors (GimpLevelsConfig *config,
- GimpHistogramChannel channel,
- const GimpRGB *black,
- const GimpRGB *gray,
- const GimpRGB *white);
/* temp cruft */
-void gimp_levels_config_to_cruft (GimpLevelsConfig *config,
- Levels *cruft,
- gboolean is_color);
+void gimp_levels_config_to_cruft (GimpLevelsConfig *config,
+ Levels *cruft,
+ gboolean is_color);
#endif /* __GIMP_LEVELS_CONFIG_H__ */
Modified: trunk/app/tools/gimpcurvestool.c
==============================================================================
--- trunk/app/tools/gimpcurvestool.c (original)
+++ trunk/app/tools/gimpcurvestool.c Fri Jan 25 13:02:37 2008
@@ -18,16 +18,10 @@
#include "config.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include <gegl.h>
#include <gtk/gtk.h>
-#include "libgimpmath/gimpmath.h"
#include "libgimpcolor/gimpcolor.h"
-#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
@@ -627,55 +621,16 @@
GError **error)
{
GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
- FILE *file = fp;
- gint i, j;
- gint fields;
- gchar buf[50];
- gint index[5][GIMP_CURVE_NUM_POINTS];
- gint value[5][GIMP_CURVE_NUM_POINTS];
-
- if (! fgets (buf, sizeof (buf), file) ||
- strcmp (buf, "# GIMP Curves File\n") != 0)
- {
- g_set_error (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_PARSE,
- _("not a GIMP Curves file"));
- return FALSE;
- }
-
- for (i = 0; i < 5; i++)
- {
- for (j = 0; j < GIMP_CURVE_NUM_POINTS; j++)
- {
- fields = fscanf (file, "%d %d ", &index[i][j], &value[i][j]);
- if (fields != 2)
- {
- /* FIXME: should have a helpful error message here */
- g_printerr ("fields != 2");
- g_set_error (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_PARSE,
- _("parse error"));
- return FALSE;
- }
- }
- }
- for (i = 0; i < 5; i++)
+ if (gimp_curves_config_load_cruft (tool->config, fp, error))
{
- GimpCurve *curve = tool->config->curve[i];
-
- gimp_data_freeze (GIMP_DATA (curve));
-
- gimp_curve_set_curve_type (curve, GIMP_CURVE_SMOOTH);
-
- for (j = 0; j < GIMP_CURVE_NUM_POINTS; j++)
- gimp_curve_set_point (curve, j, index[i][j], value[i][j]);
+ gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (tool->curve_type),
+ GIMP_CURVE_SMOOTH);
- gimp_data_thaw (GIMP_DATA (curve));
+ return TRUE;
}
- gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (tool->curve_type),
- GIMP_CURVE_SMOOTH);
-
- return TRUE;
+ return FALSE;
}
static gboolean
@@ -683,39 +638,8 @@
gpointer fp)
{
GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
- FILE *file = fp;
- gint i, j;
- gint32 index;
-
- fprintf (file, "# GIMP Curves File\n");
-
- for (i = 0; i < 5; i++)
- {
- GimpCurve *curve = tool->config->curve[i];
- if (curve->curve_type == GIMP_CURVE_FREE)
- {
- /* pick representative points from the curve and make them
- * control points
- */
- for (j = 0; j <= 8; j++)
- {
- index = CLAMP0255 (j * 32);
-
- curve->points[j * 2][0] = index;
- curve->points[j * 2][1] = curve->curve[index];
- }
- }
-
- for (j = 0; j < GIMP_CURVE_NUM_POINTS; j++)
- fprintf (file, "%d %d ",
- curve->points[j][0],
- curve->points[j][1]);
-
- fprintf (file, "\n");
- }
-
- return TRUE;
+ return gimp_curves_config_save_cruft (tool->config, fp);
}
static void
Modified: trunk/app/tools/gimplevelstool.c
==============================================================================
--- trunk/app/tools/gimplevelstool.c (original)
+++ trunk/app/tools/gimplevelstool.c Fri Jan 25 13:02:37 2008
@@ -18,17 +18,10 @@
#include "config.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpmath/gimpmath.h"
-#include "libgimpcolor/gimpcolor.h"
-#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
@@ -54,7 +47,6 @@
#include "gimphistogramoptions.h"
#include "gimplevelstool.h"
-#include "gimptoolcontrol.h"
#include "gimp-intl.h"
@@ -65,8 +57,8 @@
#define PICK_ALL_CHANNELS (1 << 8)
#define HISTOGRAM_WIDTH 256
-#define GRADIENT_HEIGHT 12
-#define CONTROL_HEIGHT 10
+#define GRADIENT_HEIGHT 12
+#define CONTROL_HEIGHT 10
/* local function prototypes */
@@ -703,74 +695,15 @@
gpointer fp,
GError **error)
{
- GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
- FILE *file = fp;
- GimpHistogramChannel channel;
- gint low_input[5];
- gint high_input[5];
- gint low_output[5];
- gint high_output[5];
- gdouble gamma[5];
- gint i, fields;
- gchar buf[50];
- gchar *nptr;
-
- if (! fgets (buf, sizeof (buf), file) ||
- strcmp (buf, "# GIMP Levels File\n") != 0)
- {
- g_set_error (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_PARSE,
- _("not a GIMP Levels file"));
- return FALSE;
- }
-
- for (i = 0; i < 5; i++)
- {
- fields = fscanf (file, "%d %d %d %d ",
- &low_input[i],
- &high_input[i],
- &low_output[i],
- &high_output[i]);
-
- if (fields != 4)
- goto error;
-
- if (! fgets (buf, 50, file))
- goto error;
-
- gamma[i] = g_ascii_strtod (buf, &nptr);
-
- if (buf == nptr || errno == ERANGE)
- goto error;
- }
-
- channel = tool->config->channel;
+ GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
- for (i = 0; i < 5; i++)
+ if (gimp_levels_config_load_cruft (tool->config, fp, error))
{
- g_object_set (tool->config,
- "channel", i,
- NULL);
+ levels_update_adjustments (tool);
- g_object_set (tool->config,
- "low-input", low_input[i] / 255.0,
- "high-input", high_input[i] / 255.0,
- "low-output", low_output[i] / 255.0,
- "high-output", high_output[i] / 255.0,
- "gamma", gamma[i],
- NULL);
+ return TRUE;
}
- g_object_set (tool->config,
- "channel", channel,
- NULL);
-
- levels_update_adjustments (tool);
-
- return TRUE;
-
- error:
- g_set_error (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_PARSE,
- _("parse error"));
return FALSE;
}
@@ -779,25 +712,8 @@
gpointer fp)
{
GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
- FILE *file = fp;
- gint i;
-
- fprintf (file, "# GIMP Levels File\n");
-
- for (i = 0; i < 5; i++)
- {
- gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
-
- fprintf (file, "%d %d %d %d %s\n",
- (gint) (tool->config->low_input[i] * 255.999),
- (gint) (tool->config->high_input[i] * 255.999),
- (gint) (tool->config->low_output[i] * 255.999),
- (gint) (tool->config->high_output[i] * 255.999),
- g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
- tool->config->gamma[i]));
- }
- return TRUE;
+ return gimp_levels_config_save_cruft (tool->config, fp);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]