Index: gimpcurvestool.c
===================================================================
RCS file: /cvs/gnome/gimp/app/tools/gimpcurvestool.c,v
retrieving revision 1.174
diff -u -3 -r1.174 gimpcurvestool.c
--- gimpcurvestool.c	5 Mar 2004 10:03:07 -0000	1.174
+++ gimpcurvestool.c	10 Mar 2004 13:27:12 -0000
@@ -660,45 +660,83 @@
   gint            fields;
   gchar           buf[50];
   gint            index[5][17];
-  gint            value[5][17];
+  gint            value[5][256];
+  gint curve_type[5];
+  gint version;
 
   if (! fgets (buf, sizeof (buf), file))
     return FALSE;
-
-  if (strcmp (buf, "# GIMP Curves File\n") != 0)
+ if (strcmp (buf, "# GIMP Curves File\n") != 0 &&
+        strcmp (buf, "# GIMP2 Curves File\n") != 0 )
     return FALSE;
+  if (strcmp (buf, "# GIMP2 Curves File\n")==0)
+    {
+       /* Version 2 and above includes support for loading  and saving GIMP_CURVE_FREE curves*/
+       fields= fscanf (file, "%d", &version);
+       if (fields != 1)
+         return FALSE;
+       if (version>=2)
+         {
+           for ( i = 0; i < 5; i++)
+             {
+               fields = fscanf (file, "%d ", &curve_type[i]);
+               if ( fields != 1 )
+                 return FALSE;
+             }
+         }
+    }
+   else
+    version = 1;
+
+  if (version == 1)
+    for (i = 0; i < 5 ; i++)
+      curve_type[i] = GIMP_CURVE_SMOOTH;
 
   for (i = 0; i < 5; i++)
     {
-      for (j = 0; j < 17; j++)
-	{
-	  fields = fscanf (file, "%d %d ", &index[i][j], &value[i][j]);
-	  if (fields != 2)
-	    {
-	      g_print ("fields != 2");
-	      return FALSE;
-	    }
-	}
+      if (curve_type [i] == GIMP_CURVE_SMOOTH)
+        for (j = 0; j < 17; j++)
+          {
+            fields = fscanf (file, "%d %d ", &index[i][j], &value[i][j]);
+            if (fields != 2)
+             {
+               g_print ("fields != 2");
+               return FALSE;
+             }
+          }
+      else
+        for (j = 0; j < 256;  j++)
+          {
+            fields = fscanf (file, "%d ",  &value[i][j]);
+            if (fields != 1)
+              {
+                g_print ("fields != 1");
+                return FALSE;
+              }
+          }
     }
 
   for (i = 0; i < 5; i++)
     {
-      tool->curves->curve_type[i] = GIMP_CURVE_SMOOTH;
-
-      for (j = 0; j < 17; j++)
-	{
-	  tool->curves->points[i][j][0] = index[i][j];
-	  tool->curves->points[i][j][1] = value[i][j];
-	}
+      tool->curves->curve_type[i] = curve_type[i];
+      if (curve_type [i] == GIMP_CURVE_SMOOTH)
+        for (j = 0; j < 17; j++)
+          {
+             tool->curves->points[i][j][0] = index[i][j];
+             tool->curves->points[i][j][1] = value[i][j];
+          }
+      else
+        for  (j = 0; j < 256; j++)
+          tool->curves->curve[i][j] = value[i][j];
     }
 
   for (i = 0; i < 5; i++)
-    curves_calculate_curve (tool->curves, i);
+    if (curve_type[i] == GIMP_CURVE_SMOOTH)
+        curves_calculate_curve (tool->curves, i);
 
   curves_update (tool, ALL);
-
   gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (tool->curve_type),
-			           GIMP_CURVE_SMOOTH);
+                curve_type[tool->channel]);
 
   return TRUE;
 }
@@ -710,29 +748,24 @@
   GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
   FILE           *file = fp;
   gint            i, j;
-  gint32          index;
 
-  for (i = 0; i < 5; i++)
-    if (tool->curves->curve_type[i] == GIMP_CURVE_FREE)
-      {
-	/*  pick representative points from the curve
-            and make them control points  */
-	for (j = 0; j <= 8; j++)
-	  {
-	    index = CLAMP0255 (j * 32);
-	    tool->curves->points[i][j * 2][0] = index;
-	    tool->curves->points[i][j * 2][1] = tool->curves->curve[i][index];
-	  }
-      }
+  fprintf (file, "# GIMP2 Curves File\n");
+  fprintf (file, "2\n");
 
-  fprintf (file, "# GIMP Curves File\n");
+  for (i = 0; i < 5; i++)
+    fprintf (file, "%d ",tool->curves->curve_type[i]);
+  fprintf (file, "\n");
 
   for (i = 0; i < 5; i++)
     {
-      for (j = 0; j < 17; j++)
-	fprintf (file, "%d %d ",
+        if (tool->curves->curve_type[i] == GIMP_CURVE_SMOOTH)
+          for (j = 0; j < 17; j++)
+            fprintf (file, "%d %d ",
                  tool->curves->points[i][j][0],
                  tool->curves->points[i][j][1]);
+        else
+          for (j = 0; j < 256; j++)
+            fprintf (file, "%d ", tool->curves->curve[i][j]);
 
       fprintf (file, "\n");
     }
