? patch
Index: config.h.in
===================================================================
RCS file: /debian/home/gnomecvs/gimp/config.h.in,v
retrieving revision 1.1.1.1.2.1
diff -u -r1.1.1.1.2.1 config.h.in
--- config.h.in	1998/07/31 00:05:21	1.1.1.1.2.1
+++ config.h.in	1998/12/02 21:51:21
@@ -49,6 +49,10 @@
 /* Define if you can safely include both <sys/time.h> and <time.h>.  */
 #undef TIME_WITH_SYS_TIME
 
+/* Define if your processor stores words with the most significant
+   byte first (like Motorola and SPARC, unlike Intel and VAX).  */
+#undef WORDS_BIGENDIAN
+
 #undef HAVE_DIRENT_H
 #undef HAVE_DOPRNT
 #undef HAVE_IPC_H
Index: gimprc.in
===================================================================
RCS file: /debian/home/gnomecvs/gimp/gimprc.in,v
retrieving revision 1.4.2.1
diff -u -r1.4.2.1 gimprc.in
--- gimprc.in	1998/07/31 00:05:25	1.4.2.1
+++ gimprc.in	1998/12/02 21:51:21
@@ -118,7 +118,7 @@
 #  pixel and progresses in all directions until the difference of pixel
 #  intensity from the original is greater than a specified threshold
 #  ==> This value represents the default threshold
-(default-threshold 15)
+(default-threshold 0.05)
 
 # There is always a tradeoff between memory usage and speed.  In most
 #  cases, the GIMP opts for speed over memory.  However, if memory is
@@ -208,3 +208,7 @@
 
 # path for gflare flares directory
 (gflare-path "${gimp_dir}/gflares:${gimp_data_dir}/gflares")
+
+# the precision you want to work at
+(default-image-precision 2)
+
Index: app/Makefile.am
===================================================================
RCS file: /debian/home/gnomecvs/gimp/app/Makefile.am,v
retrieving revision 1.1.1.1.2.13
diff -u -r1.1.1.1.2.13 Makefile.am
--- Makefile.am	1998/10/15 00:03:57	1.1.1.1.2.13
+++ Makefile.am	1998/12/02 21:51:21
@@ -318,7 +318,8 @@
 	-DLIBDIR=\""$(gimpplugindir)"\"	\
 	-DDATADIR=\""$(gimpdatadir)"\"	\
 	-DGIMPDIR=\""$(gimpdir)"\"	\
-	-DPRECISION_CONFIG=$(precision)
+	-DPRECISION_CONFIG=$(precision) \
+	-DBUILD_SGRAIL
 
 INCLUDES = \
 	$(X_CFLAGS)			\
Index: app/app_procs.h
===================================================================
RCS file: /debian/home/gnomecvs/gimp/app/app_procs.h,v
retrieving revision 1.1.1.1.2.5
diff -u -r1.1.1.1.2.5 app_procs.h
--- app_procs.h	1998/09/08 17:34:51	1.1.1.1.2.5
+++ app_procs.h	1998/12/02 21:51:21
@@ -18,6 +18,9 @@
 #ifndef __APP_PROCS_H__
 #define __APP_PROCS_H__
 
+#include <sys/types.h> /* for key_t */
+
+
 /* Function declarations */
 void gimp_init (int, char **);
 /*typedef int key_t;*/
Index: app/blend.c
===================================================================
RCS file: /debian/home/gnomecvs/gimp/app/blend.c,v
retrieving revision 1.2.2.14
diff -u -r1.2.2.14 blend.c
--- blend.c	1998/10/13 18:05:35	1.2.2.14
+++ blend.c	1998/12/02 21:51:22
@@ -139,9 +139,11 @@
 static void   blend_mode_callback       (GtkWidget *, gpointer);
 static void   paint_mode_callback       (GtkWidget *, gpointer);
 static void   repeat_type_callback      (GtkWidget *, gpointer);
+#ifndef BUILD_SGRAIL
 static void   supersample_toggle_update (GtkWidget *, gpointer);
 static void   max_depth_scale_update    (GtkAdjustment *, int *);
 static void   threshold_scale_update    (GtkAdjustment *, double *);
+#endif
 
 static void   blend_button_press            (Tool *, GdkEventButton *, gpointer);
 static void   blend_button_release          (Tool *, GdkEventButton *, gpointer);
@@ -221,9 +223,11 @@
   { "Square", 0, 0, gradient_type_callback, (gpointer) Square, NULL, NULL },
   { "Conical (symmetric)", 0, 0, gradient_type_callback, (gpointer) ConicalSymmetric, NULL, NULL },
   { "Conical (asymmetric)", 0, 0, gradient_type_callback, (gpointer) ConicalAsymmetric, NULL, NULL },
+#ifndef BUILD_SGRAIL
   { "Shapeburst (angular)", 0, 0, gradient_type_callback, (gpointer) ShapeburstAngular, NULL, NULL },
   { "Shapeburst (spherical)", 0, 0, gradient_type_callback, (gpointer) ShapeburstSpherical, NULL, NULL },
   { "Shapeburst (dimpled)", 0, 0, gradient_type_callback, (gpointer) ShapeburstDimpled, NULL, NULL },
+#endif
   { NULL, 0, 0, NULL, NULL, NULL, NULL }
 };
 
@@ -278,6 +282,7 @@
   blend_options->repeat = (RepeatMode) client_data;
 }
 
+#ifndef BUILD_SGRAIL
 static void
 supersample_toggle_update(GtkWidget *widget,
 			  gpointer   client_data)
@@ -309,13 +314,16 @@
 {
   *scale_val = adjustment->value;
 }
+#endif
 
 static BlendOptions *
 create_blend_options ()
 {
   BlendOptions *options;
   GtkWidget *vbox;
+#ifndef BUILD_SGRAIL
   GtkWidget *frame;
+#endif
   GtkWidget *label;
   GtkWidget *bm_option_menu;
   GtkWidget *bm_menu;
@@ -330,12 +338,14 @@
   GtkWidget *offset_scale;
   GtkObject *opacity_scale_data;
   GtkObject *offset_scale_data;
+#ifndef BUILD_SGRAIL
   GtkWidget *button;
   GtkObject *depth_scale_data;
   GtkWidget *depth_scale;
   GtkObject *threshold_scale_data;
   GtkWidget *threshold_scale;
-
+#endif
+  
   /*  the new options structure  */
   options = (BlendOptions *) g_malloc (sizeof (BlendOptions));
   options->opacity 	 = 100.0;
@@ -456,7 +466,7 @@
   gtk_widget_show (table);
 
   /* supersampling toggle */
-
+#ifndef BUILD_SGRAIL
   button = gtk_check_button_new_with_label("Adaptive supersampling");
   gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
   gtk_signal_connect(GTK_OBJECT(button), "toggled",
@@ -524,7 +534,8 @@
   gtk_widget_show(frame);
   gtk_widget_set_sensitive(frame, FALSE);
   options->frame = frame;
-
+#endif
+  
   /*  Register this selection options widget with the main tools options dialog  */
   tools_register_options (BLEND, vbox);
 
Index: app/brush_select.c
===================================================================
RCS file: /debian/home/gnomecvs/gimp/app/brush_select.c,v
retrieving revision 1.1.1.1.2.10
diff -u -r1.1.1.1.2.10 brush_select.c
--- brush_select.c	1998/11/07 00:58:45	1.1.1.1.2.10
+++ brush_select.c	1998/12/02 21:51:22
@@ -89,20 +89,26 @@
 static MenuItem option_items[] =
 {
   { "Normal", 0, 0, paint_mode_menu_callback, (gpointer) NORMAL_MODE, NULL, NULL },
+#ifndef BUILD_SGRAIL
   { "Dissolve", 0, 0, paint_mode_menu_callback, (gpointer) DISSOLVE_MODE, NULL, NULL },
   { "Behind", 0, 0, paint_mode_menu_callback, (gpointer) BEHIND_MODE, NULL, NULL },
+#endif
   { "Multiply", 0, 0, paint_mode_menu_callback, (gpointer) MULTIPLY_MODE, NULL, NULL },
+#ifndef BUILD_SGRAIL
   { "Screen", 0, 0, paint_mode_menu_callback, (gpointer) SCREEN_MODE, NULL, NULL },
   { "Overlay", 0, 0, paint_mode_menu_callback, (gpointer) OVERLAY_MODE, NULL, NULL },
+#endif
   { "Difference", 0, 0, paint_mode_menu_callback, (gpointer) DIFFERENCE_MODE, NULL, NULL },
   { "Addition", 0, 0, paint_mode_menu_callback, (gpointer) ADDITION_MODE, NULL, NULL },
   { "Subtract", 0, 0, paint_mode_menu_callback, (gpointer) SUBTRACT_MODE, NULL, NULL },
   { "Darken Only", 0, 0, paint_mode_menu_callback, (gpointer) DARKEN_ONLY_MODE, NULL, NULL },
   { "Lighten Only", 0, 0, paint_mode_menu_callback, (gpointer) LIGHTEN_ONLY_MODE, NULL, NULL },
+#ifndef BUILD_SGRAIL
   { "Hue", 0, 0, paint_mode_menu_callback, (gpointer) HUE_MODE, NULL, NULL },
   { "Saturation", 0, 0, paint_mode_menu_callback, (gpointer) SATURATION_MODE, NULL, NULL },
   { "Color", 0, 0, paint_mode_menu_callback, (gpointer) COLOR_MODE, NULL, NULL },
   { "Value", 0, 0, paint_mode_menu_callback, (gpointer) VALUE_MODE, NULL, NULL },
+#endif
   { NULL, 0, 0, NULL, NULL, NULL, NULL }
 };
 
@@ -127,7 +133,7 @@
   GtkWidget *menu;
   int i;
 
-  for (i = 0; i <= VALUE_MODE; i++)
+  for (i = 0; i <= (sizeof (option_items) / sizeof (MenuItem)); i++)
     option_items[i].callback = callback;
 
   menu = build_menu (option_items, NULL);
@@ -394,7 +400,7 @@
   gtk_widget_popup (bsp->brush_popup, x, y);
   
   /*  Draw the brush  */
-  buf = g_new (gchar, brush_width);
+  buf = g_new (guchar, brush_width);
   brush_tag = canvas_tag (brush->mask);
   brush_prec = tag_precision (brush_tag);
   for (y = 0; y < brush_height; y++)
Index: app/by_color_select.c
===================================================================
RCS file: /debian/home/gnomecvs/gimp/app/by_color_select.c,v
retrieving revision 1.1.1.1.2.7
diff -u -r1.1.1.1.2.7 by_color_select.c
--- by_color_select.c	1998/08/25 03:42:49	1.1.1.1.2.7
+++ by_color_select.c	1998/12/02 21:51:22
@@ -589,24 +589,27 @@
   return bcd;
 }
 
+
 static void
 by_color_select_render (ByColorDialog *bcd,
 			GImage        *gimage)
 {
+  PixelArea srcPR, destPR;
   Channel * mask;
+  Canvas * source_buf = NULL;
   Canvas * scaled_buf = NULL;
-  unsigned char *buf;
-  PixelArea srcPR, destPR;
-  int width, height, w, h;
+  Canvas * copied_buf = NULL;
+  Precision prec;
+  guchar *buf;
+  int width, height;
   int i;
   int scale;
 
   mask = gimage_get_mask (gimage);
-  w = drawable_width (GIMP_DRAWABLE (mask));
-  h = drawable_height (GIMP_DRAWABLE (mask));
-
-  width = w;
-  height = h;
+  prec = tag_precision (gimage_tag (gimage));
+                        
+  width = drawable_width (GIMP_DRAWABLE (mask));
+  height = drawable_height (GIMP_DRAWABLE (mask));
   scale = FALSE;
 
   if ((width > PREVIEW_WIDTH) || (height > PREVIEW_HEIGHT))
@@ -631,75 +634,69 @@
     gtk_preview_size (GTK_PREVIEW (bcd->preview), width, height);
 
   /*  clear the image buf  */
-  buf = (unsigned char *) g_malloc (bcd->preview->requisition.width);
+  buf = (guchar *) g_malloc (bcd->preview->requisition.width);
   memset (buf, 0, bcd->preview->requisition.width);
   for (i = 0; i < bcd->preview->requisition.height; i++)
-    gtk_preview_draw_row (GTK_PREVIEW (bcd->preview), buf, 0, i, bcd->preview->requisition.width);
+  gtk_preview_draw_row (GTK_PREVIEW (bcd->preview),
+                        buf, 0, i, bcd->preview->requisition.width);
   g_free (buf);
-
+  
   /*  if the mask is empty, no need to scale and update again  */
   if (gimage_mask_is_empty (gimage))
     return;
+
+  /* get the raw mask data */
+  source_buf = drawable_data (GIMP_DRAWABLE (mask));
+
+  /* scale it if needed */
+  if (scale)
+    {
+      scaled_buf = canvas_new (tag_new (prec, FORMAT_GRAY, ALPHA_NO),
+                               width, height,
+                               STORAGE_FLAT);
+
+      pixelarea_init (&srcPR, source_buf, 
+                      0, 0, 
+                      0, 0,
+                      FALSE);
+      pixelarea_init (&destPR, scaled_buf,
+                      0, 0,
+                      0, 0,
+                      TRUE);
+      scale_area (&srcPR, &destPR);
+
+      source_buf = scaled_buf;
+    }
 
-  scaled_buf = canvas_new (tag_new (tag_precision (gimage_tag (gimage)),
-                                    FORMAT_GRAY,
-                                    ALPHA_NO),
-                           width,
-                           height,
+  /* copy to a flat buffer (and convert the precision if needed) */
+  copied_buf = canvas_new (tag_new (PRECISION_U8, FORMAT_GRAY, ALPHA_NO),
+                           width, height,
                            STORAGE_FLAT);
-  
-  pixelarea_init (&srcPR, drawable_data (GIMP_DRAWABLE (mask)), 
+
+  pixelarea_init (&srcPR, source_buf, 
                   0, 0, 
-                  w, h,
+                  0, 0,
                   FALSE);
-  
-  pixelarea_init (&destPR, scaled_buf,
+  pixelarea_init (&destPR, copied_buf,
                   0, 0,
-                  width, height,
+                  0, 0,
                   TRUE);
+  copy_area (&srcPR, &destPR);
 
-  if (scale)
-    {
-      scale_area (&srcPR, &destPR);
-    }
-  else
-    {
-      copy_area (&srcPR, &destPR);
-    }
 
+  /* copy each row of the (now flat) preview to screen */
+  canvas_portion_refro (copied_buf, 0, 0);
+  for (i = 0; i < height; i++)
   {
-    PixelArea a;
-    PixelRow srcrow, dstrow;
-    int w, h;
-
-    w = canvas_width (scaled_buf);
-    h = canvas_height (scaled_buf);
-
-    buf = (unsigned char *) g_malloc (w);
-
-    pixelrow_init (&dstrow,
-                   tag_new (PRECISION_U8,
-                            FORMAT_GRAY,
-                            ALPHA_NO),
-                   buf,
-                   w);
-
-    pixelarea_init (&a, scaled_buf,
-                    0, 0,
-                    0, 0,
-                    FALSE);
-    
-    for (i = 0; i < h; i++)
-      {
-        pixelarea_getdata (&a, &srcrow, i);
-        copy_row (&srcrow, &dstrow);
-        gtk_preview_draw_row (GTK_PREVIEW (bcd->preview), buf, 0, i, width);
-      }
-
-    g_free (buf);
+    buf = canvas_portion_data (copied_buf, 0, i);
+    gtk_preview_draw_row (GTK_PREVIEW (bcd->preview), buf, 0, i, width);
   }
+  canvas_portion_unref (copied_buf, 0, 0);
+  
   
+  /* clean up our scratch space */
   canvas_delete (scaled_buf);
+  canvas_delete (copied_buf);
 }
 
 static void
Index: app/commands.c
===================================================================
RCS file: /debian/home/gnomecvs/gimp/app/commands.c,v
retrieving revision 1.4.2.13
diff -u -r1.4.2.13 commands.c
--- commands.c	1998/10/07 19:33:10	1.4.2.13
+++ commands.c	1998/12/02 21:51:23
@@ -434,7 +434,7 @@
     gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button), TRUE);
   gtk_widget_show (button);
 
-
+#ifndef BUILD_SGRAIL
   frame = gtk_frame_new ("Storage Type");
   gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
   gtk_widget_show (frame);
@@ -476,7 +476,7 @@
   if (vals->storage == STORAGE_SHM)
     gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button), TRUE);
   gtk_widget_show (button);
-
+#endif
 
   frame = gtk_frame_new ("Fill Type");
   gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
@@ -744,8 +744,10 @@
     update = g_list_append (update, "default-image-size");
   if (default_format != old_default_format)
     update = g_list_append (update, "default-image-type");
+#ifndef BUILD_SGRAIL
   if (default_precision != old_default_precision)
     update = g_list_append (update, "default-image-precision");
+#endif
   if (preview_size != old_preview_size)
     update = g_list_append (update, "preview-size");
   if (transparency_type != old_transparency_type)
@@ -869,7 +871,9 @@
   default_width = old_default_width;
   default_height = old_default_height;
   default_format = old_default_format;
+#ifndef BUILD_SGRAIL
   default_precision = old_default_precision;
+#endif
   if (preview_size != old_preview_size)
     {
       lc_dialog_rebuild (old_preview_size);
@@ -929,11 +933,13 @@
   else if (data==&default_format)
     {
       default_format = (long) gtk_object_get_user_data (GTK_OBJECT (widget));
-    } 
+    }
+#ifndef BUILD_SGRAIL
   else if (data==&default_precision)
     {
       default_precision = (Precision) gtk_object_get_user_data (GTK_OBJECT (widget));
-    } 
+    }
+#endif
   else if (GTK_TOGGLE_BUTTON (widget)->active)
     {
       val = data;
@@ -1085,7 +1091,9 @@
       old_default_width = default_width;
       old_default_height = default_height;
       old_default_format = default_format;
+#ifndef BUILD_SGRAIL
       old_default_precision = default_precision;
+#endif
       old_stingy_memory_use = edit_stingy_memory_use;
       old_tile_cache_size = edit_tile_cache_size;
       old_install_cmap = edit_install_cmap;
@@ -1238,7 +1246,8 @@
       hbox = gtk_hbox_new (FALSE, 2);
       gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
       gtk_widget_show (hbox);
-      
+
+#ifndef BUILD_SGRAIL
       frame = gtk_frame_new ("Image precision");
       gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
       gtk_widget_show (frame);
@@ -1291,7 +1300,8 @@
       hbox = gtk_hbox_new (FALSE, 2);
       gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
       gtk_widget_show (hbox);
-
+#endif
+      
       label = gtk_label_new ("Preview size:");
       gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
       gtk_widget_show (label);
Index: app/flip_tool.c
===================================================================
RCS file: /debian/home/gnomecvs/gimp/app/flip_tool.c,v
retrieving revision 1.1.1.1.2.4
diff -u -r1.1.1.1.2.4 flip_tool.c
--- flip_tool.c	1998/08/09 23:10:49	1.1.1.1.2.4
+++ flip_tool.c	1998/12/02 21:51:23
@@ -247,7 +247,7 @@
   if (!orig)
     return NULL;
 
-  new = canvas_new (canvas_tag (orig),
+  new = canvas_new (drawable_tag (drawable),
                     canvas_width (orig), canvas_height (orig),
                     STORAGE_TILED);
 
@@ -302,7 +302,7 @@
   if (!orig)
     return NULL;
 
-  new = canvas_new (canvas_tag (orig),
+  new = canvas_new (drawable_tag (drawable),
                     canvas_width (orig), canvas_height (orig),
                     STORAGE_TILED);
 
Index: app/fuzzy_select.c
===================================================================
RCS file: /debian/home/gnomecvs/gimp/app/fuzzy_select.c,v
retrieving revision 1.1.1.1.2.11
diff -u -r1.1.1.1.2.11 fuzzy_select.c
--- fuzzy_select.c	1998/10/08 00:17:07	1.1.1.1.2.11
+++ fuzzy_select.c	1998/12/02 21:51:23
@@ -17,6 +17,8 @@
  */
 #include <stdlib.h>
 #include <math.h>
+#include <string.h>
+
 #include "appenv.h"
 #include "boundary.h"
 #include "canvas.h"
@@ -114,7 +116,7 @@
 
 /* private methods */
 static guint pixeliter_choose_chunk (PixelIter *);
-static guint pixeliter_first        (PixelIter *, BBox *, guint *, guint *);
+static guint pixeliter_first        (PixelIter *, BBox *, gint *, gint *);
 
 /* types of refs for pixeliter_init */
 #define REF_NONE 0
@@ -447,7 +449,7 @@
                )
 {
   guint changed = FALSE;
-  guint x, y;
+  gint x, y;
   
   /* get pixels in this chunk which need attention */
   while (pixeliter_get_work (p, &x, &y))
@@ -474,8 +476,17 @@
            (xmax_c < p->chunk.w) && (dd[xmax_c] != 0);
            xmax_c++);
              
+      xmin_c++;
+
+
+      /* del work for contiguous row of pixels */
+      pixeliter_del_work (p,
+                          p->chunk.x + xmin_c, y,
+                          xmax_c - xmin_c, 1);
+
+      
       /* add work to adjacent chunks if segment reached the edges */
-      if (xmin_c < 0)
+      if (xmin_c == 0)
         {
           pixeliter_add_work (p,
                               p->chunk.x - 1, y,
@@ -489,25 +500,17 @@
                               1, 1);
         }
       
-      xmin_c++;
-      xmax_c--;
-      
-      /* del work for those pixels */
-      pixeliter_del_work (p,
-                          p->chunk.x + xmin_c, y,
-                          xmax_c - xmin_c + 1, 1);
-
       /* add work to next and prev rows */
       pixeliter_add_work (p,
                           p->chunk.x + xmin_c, y - 1,
-                          xmax_c - xmin_c + 1, 1);
+                          xmax_c - xmin_c, 1);
       
       pixeliter_add_work (p,
                           p->chunk.x + xmin_c, y + 1,
-                          xmax_c - xmin_c + 1, 1);
+                          xmax_c - xmin_c, 1);
       
       /* save those pixels on x_mask */
-      memcpy (&md[xmin_c], &dd[xmin_c], (xmax_c - xmin_c + 1) * sizeof (guint8));
+      memcpy (&md[xmin_c], &dd[xmin_c], (xmax_c - xmin_c) * sizeof (guint8));
       changed = TRUE;
     }
 
@@ -521,7 +524,7 @@
                )
 {
   guint changed = FALSE;
-  guint x, y;
+  gint x, y;
   
   /* get pixels in this chunk which need attention */
   while (pixeliter_get_work (p, &x, &y))
@@ -548,8 +551,17 @@
            (xmax_c < p->chunk.w) && (dd[xmax_c] != 0);
            xmax_c++);
              
+      xmin_c++;
+      
+
+
+      /* del work for contiguous row of pixels */
+      pixeliter_del_work (p,
+                          p->chunk.x + xmin_c, y,
+                          xmax_c - xmin_c, 1);
+
       /* add work to adjacent chunks if segment reached the edges */
-      if (xmin_c < 0)
+      if (xmin_c == 0)
         {
           pixeliter_add_work (p,
                               p->chunk.x - 1, y,
@@ -563,25 +575,17 @@
                               1, 1);
         }
       
-      xmin_c++;
-      xmax_c--;
-      
-      /* del work for those pixels */
-      pixeliter_del_work (p,
-                          p->chunk.x + xmin_c, y,
-                          xmax_c - xmin_c + 1, 1);
-
       /* add work to next and prev rows */
       pixeliter_add_work (p,
                           p->chunk.x + xmin_c, y - 1,
-                          xmax_c - xmin_c + 1, 1);
+                          xmax_c - xmin_c, 1);
       
       pixeliter_add_work (p,
                           p->chunk.x + xmin_c, y + 1,
-                          xmax_c - xmin_c + 1, 1);
+                          xmax_c - xmin_c, 1);
       
       /* save those pixels on x_mask */
-      memcpy (&md[xmin_c], &dd[xmin_c], (xmax_c - xmin_c + 1) * sizeof (guint16));
+      memcpy (&md[xmin_c], &dd[xmin_c], (xmax_c - xmin_c) * sizeof (guint16));
       changed = TRUE;
     }
 
@@ -595,7 +599,7 @@
                  )
 {
   guint changed = FALSE;
-  guint x, y;
+  gint x, y;
   
   /* get pixels in this chunk which need attention */
   while (pixeliter_get_work (p, &x, &y))
@@ -669,7 +673,7 @@
                  )
 {
   guint changed = FALSE;
-  guint x, y;
+  gint x, y;
   
   /* get pixels in this chunk which need attention */
   while (pixeliter_get_work (p, &x, &y))
@@ -1452,14 +1456,17 @@
 
   p->image = image;
   p->reftype = reftype;
+
   p->area.x = x;
-  p->area.y = y;
-  p->area.w = canvas_width (image);
+  p->area.w = canvas_width (image) - x;
   if ((w > 0) && (w <= p->area.w))
     p->area.w = w;
-  p->area.h = canvas_height (image);
+
+  p->area.y = y;
+  p->area.h = canvas_height (image) - y;
   if ((h > 0) && (h <= p->area.h))
     p->area.h = h;
+
   p->chunk.x = 0;
   p->chunk.y = 0;
   p->chunk.w = 0;
@@ -1521,7 +1528,7 @@
     if (canvas_portion_refrw (p->image, p->chunk.x, p->chunk.y) != REFRC_OK)
       return FALSE;
 
-  /* ready ike?  kick the callback! */
+  /* ready ike?  kick the callback! seed_fill seed_fill_u16 */
   rc = p->callback (p);
 
   /* unref the image data if required */
@@ -1579,8 +1586,8 @@
 pixeliter_first  (
                   PixelIter * p,
                   BBox * b,
-                  guint * xx,
-                  guint * yy
+                  gint * xx,
+                  gint * yy
                   )
 {
   guint x, y, w, h;
Index: app/gdisplay.c
===================================================================
RCS file: /debian/home/gnomecvs/gimp/app/gdisplay.c,v
retrieving revision 1.4.2.8
diff -u -r1.4.2.8 gdisplay.c
--- gdisplay.c	1998/09/23 18:22:01	1.4.2.8
+++ gdisplay.c	1998/12/02 21:51:24
@@ -139,12 +139,11 @@
   int empty = gimage_is_empty (gimage);
   Tag t = gimage_tag (gimage);
 
-  sprintf (title, "%s-%d.%d (%s - %s - %s)%s",
+  sprintf (title, "%s-%d.%d (%s - %s)%s",
 	   prune_filename (gimage_filename (gimage)),
 	   gimage->ID, gimage->instance_count,
 	   tag_string_precision (tag_precision (t)),
 	   tag_string_format (tag_format (t)),
-	   tag_string_alpha (tag_alpha (t)),
            empty ? " (empty)" : "");
 }
 
@@ -987,11 +986,15 @@
 
   menus_set_sensitive ("<Image>/Image/RGB", (format != FORMAT_RGB));
   menus_set_sensitive ("<Image>/Image/Grayscale", (format != FORMAT_GRAY));
+#ifndef BUILD_SGRAIL
   menus_set_sensitive ("<Image>/Image/Indexed", (format != FORMAT_INDEXED));
 
+#endif
   menus_set_sensitive ("<Image>/Image/Colors/Threshold", (format != FORMAT_INDEXED));
   menus_set_sensitive ("<Image>/Image/Colors/Posterize", (format != FORMAT_INDEXED));
+#ifndef BUILD_SGRAIL
   menus_set_sensitive ("<Image>/Image/Colors/Equalize", (format != FORMAT_INDEXED));
+#endif
   menus_set_sensitive ("<Image>/Image/Colors/Invert", (format != FORMAT_INDEXED));
 
   menus_set_sensitive ("<Image>/Image/Colors/Color Balance", (format == FORMAT_RGB));
@@ -1001,7 +1004,6 @@
   menus_set_sensitive ("<Image>/Image/Colors/Levels", (format != FORMAT_INDEXED));
 
   menus_set_sensitive ("<Image>/Image/Colors/Desaturate", (format == FORMAT_RGB));
-
   menus_set_sensitive ("<Image>/Image/Alpha/Add Alpha Channel", !fs && !aux && lp && !lm && !alpha);
 
   menus_set_sensitive ("<Image>/Select", lp);
@@ -1017,7 +1019,9 @@
   menus_set_sensitive ("<Image>/Edit/Paste Named", lp);
   menus_set_sensitive ("<Image>/Image/Colors", lp);
   menus_set_sensitive ("<Image>/Image/Channel Ops/Offset", lp);
+#ifndef BUILD_SGRAIL
   menus_set_sensitive ("<Image>/Image/Histogram", lp);
+#endif
   menus_set_sensitive ("<Image>/Filters", lp);
 
   /* save selection to channel */
Index: app/gimage.c
===================================================================
RCS file: /debian/home/gnomecvs/gimp/app/gimage.c,v
retrieving revision 1.2.2.28
diff -u -r1.2.2.28 gimage.c
--- gimage.c	1998/09/30 23:47:31	1.2.2.28
+++ gimage.c	1998/12/02 21:51:24
@@ -1644,6 +1644,7 @@
   if (merge_list && merge_list->next)
     {
       layer = gimage_merge_layers (gimage, merge_list, merge_type);
+      layer->opacity = 1.0;
       g_slist_free (merge_list);
       return layer;
     }
Index: app/image_render.c
===================================================================
RCS file: /debian/home/gnomecvs/gimp/app/image_render.c,v
retrieving revision 1.1.1.1.2.22
diff -u -r1.1.1.1.2.22 image_render.c
--- image_render.c	1998/11/07 00:58:54	1.1.1.1.2.22
+++ image_render.c	1998/12/02 21:51:25
@@ -5260,7 +5260,6 @@
   guint16 *src;
   gint src8bit;
   guchar *dest;
-  gulong val;
   int byte_order;
   int y, ye;
   int x, xe;
@@ -5332,7 +5331,6 @@
   guint16 *src;
   gint src8bit;
   guchar *dest;
-  gulong val;
   int byte_order;
   int y, ye;
   int x, xe;
@@ -5683,7 +5681,6 @@
   gulong *lookup_blue;
   guint16 *src;
   guchar *dest;
-  gulong val;
   int byte_order;
   int y, ye;
   int x, xe;
@@ -5749,7 +5746,6 @@
   gulong *lookup_blue;
   guint16 *src;
   guchar *dest;
-  gulong val;
   int byte_order;
   int y, ye;
   int x, xe;
@@ -5936,7 +5932,6 @@
   guchar *dest;
   guint *alpha;
   gulong r, g, b;
-  gulong val;
   guint a;
   int dark_light;
   int byte_order;
@@ -6052,7 +6047,6 @@
   guchar *dest;
   guint *alpha;
   gulong r, g, b;
-  gulong val;
   guint a;
   int dark_light;
   int byte_order;
Index: app/interface.c
===================================================================
RCS file: /debian/home/gnomecvs/gimp/app/interface.c,v
retrieving revision 1.2.2.3
diff -u -r1.2.2.3 interface.c
--- interface.c	1998/07/31 00:08:14	1.2.2.3
+++ interface.c	1998/12/02 21:51:25
@@ -358,7 +358,11 @@
 			GTK_EXPAND | GTK_SHRINK | GTK_FILL,
 			GTK_EXPAND | GTK_SHRINK | GTK_FILL,
 			0, 0);
-
+#ifdef BUILD_SGRAIL
+      if ((tool_data[i].callback_data != ISCISSORS) &&
+          (tool_data[i].callback_data != TEXT))
+        {
+#endif
       alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
       gtk_container_border_width (GTK_CONTAINER (alignment), 0);
       gtk_container_add (GTK_CONTAINER (button), alignment);
@@ -378,6 +382,9 @@
 
       gtk_widget_show (pixmap);
       gtk_widget_show (alignment);
+#ifdef BUILD_SGRAIL
+        }
+#endif
       gtk_widget_show (button);
     }
 
Index: app/layer.c
===================================================================
RCS file: /debian/home/gnomecvs/gimp/app/layer.c,v
retrieving revision 1.2.2.21
diff -u -r1.2.2.21 layer.c
--- layer.c	1998/11/07 00:58:55	1.2.2.21
+++ layer.c	1998/12/02 21:51:25
@@ -933,6 +933,8 @@
       canvas_portion_refro (canvas, x, y);
       c_data = canvas_portion_data (canvas, x, y);
 
+      mask = NULL;
+      m_data = NULL;
       if (layer->mask)
 	{
 	  mask = GIMP_DRAWABLE(layer->mask)->tiles;
Index: app/layers_dialog.c
===================================================================
RCS file: /debian/home/gnomecvs/gimp/app/layers_dialog.c,v
retrieving revision 1.2.2.12
diff -u -r1.2.2.12 layers_dialog.c
--- layers_dialog.c	1998/09/27 01:17:35	1.2.2.12
+++ layers_dialog.c	1998/12/02 21:51:26
@@ -254,19 +254,25 @@
 static MenuItem option_items[] =
 {
   { "Normal", 0, 0, paint_mode_menu_callback, (gpointer) NORMAL_MODE, NULL, NULL },
+#ifndef BUILD_SGRAIL
   { "Dissolve", 0, 0, paint_mode_menu_callback, (gpointer) DISSOLVE_MODE, NULL, NULL },
+#endif
   { "Multiply", 0, 0, paint_mode_menu_callback, (gpointer) MULTIPLY_MODE, NULL, NULL },
+#ifndef BUILD_SGRAIL
   { "Screen", 0, 0, paint_mode_menu_callback, (gpointer) SCREEN_MODE, NULL, NULL },
   { "Overlay", 0, 0, paint_mode_menu_callback, (gpointer) OVERLAY_MODE, NULL, NULL },
+#endif
   { "Difference", 0, 0, paint_mode_menu_callback, (gpointer) DIFFERENCE_MODE, NULL, NULL },
   { "Addition", 0, 0, paint_mode_menu_callback, (gpointer) ADDITION_MODE, NULL, NULL },
   { "Subtract", 0, 0, paint_mode_menu_callback, (gpointer) SUBTRACT_MODE, NULL, NULL },
   { "Darken Only", 0, 0, paint_mode_menu_callback, (gpointer) DARKEN_ONLY_MODE, NULL, NULL },
   { "Lighten Only", 0, 0, paint_mode_menu_callback, (gpointer) LIGHTEN_ONLY_MODE, NULL, NULL },
+#ifndef BUILD_SGRAIL
   { "Hue", 0, 0, paint_mode_menu_callback, (gpointer) HUE_MODE, NULL, NULL },
   { "Saturation", 0, 0, paint_mode_menu_callback, (gpointer) SATURATION_MODE, NULL, NULL },
   { "Color", 0, 0, paint_mode_menu_callback, (gpointer) COLOR_MODE, NULL, NULL },
   { "Value", 0, 0, paint_mode_menu_callback, (gpointer) VALUE_MODE, NULL, NULL },
+#endif
   { NULL, 0, 0, NULL, NULL, NULL, NULL }
 };
 
@@ -1049,8 +1055,7 @@
   /* dump it to screen */
   canvas_portion_refro (display_buf, 0, 0);
   {
-    int i, j, b;
-    int num_channels = tag_num_channels (canvas_tag (display_buf));
+    int i;
     for (i = 0; i < height; i++)
       {
         guchar * t = canvas_portion_data (display_buf, 0, i);
@@ -2852,10 +2857,18 @@
        */
       layersD->opacity_data->value = layer_widget->layer->opacity * 100.0;
       gtk_signal_emit_by_name (GTK_OBJECT (layersD->opacity_data), "value_changed");
+#ifdef BUILD_SGRAIL
+      {
+        static int foo[] = {0, 0, 0, 1, 0, 0, 2, 3, 4, 5, 6, 0, 0, 0, 0};
+        gtk_option_menu_set_history (GTK_OPTION_MENU (layersD->mode_option_menu),
+                                     foo[layer_widget->layer->mode]);
+      }
+#else
       gtk_option_menu_set_history (GTK_OPTION_MENU (layersD->mode_option_menu),
 				   /*  Kludge to deal with the absence of behind */
 				   ((layer_widget->layer->mode > BEHIND_MODE) ?
 				    layer_widget->layer->mode - 1 : layer_widget->layer->mode));
+#endif
       gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (layersD->preserve_trans),
 				   (layer_widget->layer->preserve_trans) ?
 				   GTK_STATE_ACTIVE : GTK_STATE_NORMAL);
Index: app/main.c
===================================================================
RCS file: /debian/home/gnomecvs/gimp/app/main.c,v
retrieving revision 1.2.2.6
diff -u -r1.2.2.6 main.c
--- main.c	1998/08/07 22:26:10	1.2.2.6
+++ main.c	1998/12/02 21:51:26
@@ -280,16 +280,6 @@
   if (!app_exit_finish_done ())
     gtk_main ();
 
-  {
-    extern int ref_ro, ref_rw,ref_un, ref_fa , ref_uf;
-    
-    g_warning ("Refs:   %d+%d = %d", ref_ro, ref_rw, (ref_ro+ref_rw));
-    g_warning ("Unrefs: %d", ref_un);
-    
-    g_warning ("Frefs:   %d", ref_fa);
-    g_warning ("Funrefs: %d", ref_uf);
-  }
-
   return 0;
 }
 
Index: app/menus.c
===================================================================
RCS file: /debian/home/gnomecvs/gimp/app/menus.c,v
retrieving revision 1.4.2.4
diff -u -r1.4.2.4 menus.c
--- menus.c	1998/07/31 00:08:39	1.4.2.4
+++ menus.c	1998/12/02 21:51:26
@@ -94,7 +94,9 @@
   { "<Image>/Select/None", "<control><shift>A", select_none_cmd_callback, NULL },
   { "<Image>/Select/Float", "<control><shift>L", select_float_cmd_callback, NULL },
   { "<Image>/Select/Sharpen", "<control><shift>H", select_sharpen_cmd_callback, NULL },
+#ifndef BUILD_SGRAIL
   { "<Image>/Select/Border", "<control><shift>B", select_border_cmd_callback, NULL },
+#endif
   { "<Image>/Select/Feather", "<control><shift>F", select_feather_cmd_callback, NULL },
   { "<Image>/Select/Grow", NULL, select_grow_cmd_callback, NULL },
   { "<Image>/Select/Shrink", NULL, select_shrink_cmd_callback, NULL },
@@ -119,8 +121,10 @@
   { "<Image>/View/<separator>", NULL, NULL, NULL },
   { "<Image>/View/New View", NULL, view_new_view_cmd_callback, NULL },
   { "<Image>/View/Shrink Wrap", "<control>E", view_shrink_wrap_cmd_callback, NULL },
-  
+
+#ifndef BUILD_SGRAIL
   { "<Image>/Image/Colors/Equalize", NULL, image_equalize_cmd_callback, NULL },
+#endif
   { "<Image>/Image/Colors/Invert", NULL, image_invert_cmd_callback, NULL },
   { "<Image>/Image/Colors/Posterize", NULL, image_posterize_cmd_callback, NULL },
   { "<Image>/Image/Colors/Threshold", NULL, image_threshold_cmd_callback, NULL },
@@ -139,13 +143,17 @@
   { "<Image>/Image/<separator>", NULL, NULL, NULL },
   { "<Image>/Image/RGB", NULL, image_convert_rgb_cmd_callback, NULL },
   { "<Image>/Image/Grayscale", NULL, image_convert_grayscale_cmd_callback, NULL },
+#ifndef BUILD_SGRAIL
   { "<Image>/Image/Indexed", NULL, image_convert_indexed_cmd_callback, NULL },
+#endif
   { "<Image>/Image/<separator>", NULL, NULL, NULL },
   { "<Image>/Image/Resize", NULL, image_resize_cmd_callback, NULL },
   { "<Image>/Image/Scale", NULL, image_scale_cmd_callback, NULL },
   { "<Image>/Image/<separator>", NULL, NULL, NULL },
+#ifndef BUILD_SGRAIL
   { "<Image>/Image/Histogram", NULL, image_histogram_cmd_callback, NULL },
   { "<Image>/Image/<separator>", NULL, NULL, NULL },
+#endif
 
   { "<Image>/Layers/Layers & Channels...", "<control>L", dialogs_lc_cmd_callback, NULL },
   { "<Image>/Layers/Raise Layer", "<control>F", layers_raise_cmd_callback, NULL },
@@ -162,13 +170,17 @@
   { "<Image>/Tools/Free Select", "F", tools_select_cmd_callback, (gpointer) FREE_SELECT },
   { "<Image>/Tools/Fuzzy Select", "Z", tools_select_cmd_callback, (gpointer) FUZZY_SELECT },
   { "<Image>/Tools/Bezier Select", "B", tools_select_cmd_callback, (gpointer) BEZIER_SELECT },
+#ifndef BUILD_SGRAIL
   { "<Image>/Tools/Intelligent Scissors", "I", tools_select_cmd_callback, (gpointer) ISCISSORS },
+#endif
   { "<Image>/Tools/Move", "M", tools_select_cmd_callback, (gpointer) MOVE },
   { "<Image>/Tools/Magnify", "<shift>M", tools_select_cmd_callback, (gpointer) MAGNIFY },
   { "<Image>/Tools/Crop", "<shift>C", tools_select_cmd_callback, (gpointer) CROP },
   { "<Image>/Tools/Transform", "<shift>T", tools_select_cmd_callback, (gpointer) ROTATE },
   { "<Image>/Tools/Flip", "<shift>F", tools_select_cmd_callback, (gpointer) FLIP_HORZ },
+#ifndef BUILD_SGRAIL
   { "<Image>/Tools/Text", "T", tools_select_cmd_callback, (gpointer) TEXT },
+#endif
   { "<Image>/Tools/Color Picker", "O", tools_select_cmd_callback, (gpointer) COLOR_PICKER },
   { "<Image>/Tools/Bucket Fill", "<shift>B", tools_select_cmd_callback, (gpointer) BUCKET_FILL },
   { "<Image>/Tools/Blend", "L", tools_select_cmd_callback, (gpointer) BLEND },
@@ -196,7 +208,9 @@
   { "<Image>/Dialogs/Palette...", "<control>P", dialogs_palette_cmd_callback, NULL },
   { "<Image>/Dialogs/Gradient Editor...", "<control>G", dialogs_gradient_editor_cmd_callback, NULL },
   { "<Image>/Dialogs/Layers & Channels...", "<control>L", dialogs_lc_cmd_callback, NULL },
+#ifndef BUILD_SGRAIL
   { "<Image>/Dialogs/Indexed Palette...", NULL, dialogs_indexed_palette_cmd_callback, NULL },
+#endif
   { "<Image>/Dialogs/Tool Options...", NULL, dialogs_tools_options_cmd_callback, NULL },
 
   { "<Load>/Automatic", NULL, file_load_by_extension_callback, NULL },
Index: app/paint_funcs_row_u16.c
===================================================================
RCS file: /debian/home/gnomecvs/gimp/app/Attic/paint_funcs_row_u16.c,v
retrieving revision 1.1.2.22
diff -u -r1.1.2.22 paint_funcs_row_u16.c
--- paint_funcs_row_u16.c	1998/09/30 20:09:47	1.1.2.22
+++ paint_funcs_row_u16.c	1998/12/02 21:51:37
@@ -140,21 +140,20 @@
   guint16 *color         = (guint16*) pixelrow_data (col);
 
   Tag     tag           = pixelrow_tag (image);
-  int     has_alpha     = (tag_alpha (tag) == ALPHA_YES) ? 1 : 0;
-
   gint    width         = pixelrow_width (image);  
 
   gint    src_channels  = tag_num_channels (pixelrow_tag (image));
   gint    dest_channels = tag_num_channels (pixelrow_tag (mask));
 
-  
+  int     has_alpha     = (tag_alpha (tag) == ALPHA_YES) ? 1 : 0;
 
-  threshold *= 65535;
+  guint16 thresh        = (threshold + 0.000001) * 65535;
+
   
   while (width--)
     {
       /*  if there is an alpha channel, never select transparent regions  */
-      if (has_alpha && src[src_channels] == 0)
+      if (has_alpha && src[src_channels-1] == 0)
         {
           *dest = 0;
         }
@@ -164,7 +163,7 @@
           gint diff;
           gint max = 0;
           
-          for (b = 0; b < src_channels; b++)
+          for (b = 0; b < src_channels-has_alpha; b++)
             {
               diff = src[b] - color[b];
               diff = abs (diff);
@@ -172,11 +171,11 @@
                 max = diff;
             }
       
-          if (antialias && threshold > 0)
+          if (antialias && thresh > 0)
             {
               float aa;
 
-              aa = 1.5 - ((float) max / threshold);
+              aa = 1.5 - ((float) max / (float) thresh);
               if (aa <= 0)
                 *dest = 0;
               else if (aa < 0.5)
@@ -186,15 +185,15 @@
             }
           else
             {
-              if (max > threshold)
+              if (max > thresh)
                 *dest = 0;
               else
                 *dest = 65535;
             }
-          
-          src += src_channels;
-          dest += dest_channels;
         }
+          
+      src += src_channels;
+      dest += dest_channels;
     }
 }
 
Index: app/paint_funcs_row_u8.c
===================================================================
RCS file: /debian/home/gnomecvs/gimp/app/Attic/paint_funcs_row_u8.c,v
retrieving revision 1.1.2.22
diff -u -r1.1.2.22 paint_funcs_row_u8.c
--- paint_funcs_row_u8.c	1998/11/07 00:59:02	1.1.2.22
+++ paint_funcs_row_u8.c	1998/12/02 21:51:38
@@ -141,21 +141,20 @@
   guint8 *color         = (guint8*) pixelrow_data (col);
 
   Tag     tag           = pixelrow_tag (image);
-  int     has_alpha     = (tag_alpha (tag) == ALPHA_YES) ? 1 : 0;
-
   gint    width         = pixelrow_width (image);  
 
   gint    src_channels  = tag_num_channels (pixelrow_tag (image));
   gint    dest_channels = tag_num_channels (pixelrow_tag (mask));
 
-  
+  int     has_alpha     = (tag_alpha (tag) == ALPHA_YES) ? 1 : 0;
 
-  threshold *= 255;
+  guint8 thresh        = (threshold + 0.000001) * 255;
+
   
   while (width--)
     {
       /*  if there is an alpha channel, never select transparent regions  */
-      if (has_alpha && src[src_channels] == 0)
+      if (has_alpha && src[src_channels-1] == 0)
         {
           *dest = 0;
         }
@@ -165,7 +164,7 @@
           gint diff;
           gint max = 0;
           
-          for (b = 0; b < src_channels; b++)
+          for (b = 0; b < src_channels-has_alpha; b++)
             {
               diff = src[b] - color[b];
               diff = abs (diff);
@@ -173,29 +172,29 @@
                 max = diff;
             }
       
-          if (antialias && threshold > 0)
+          if (antialias && thresh > 0)
             {
               float aa;
 
-              aa = 1.5 - ((float) max / threshold);
+              aa = 1.5 - ((float) max / (float) thresh);
               if (aa <= 0)
                 *dest = 0;
               else if (aa < 0.5)
-                *dest = (aa * 512);
+                *dest = (aa * 256 * 2);
               else
                 *dest = 255;
             }
           else
             {
-              if (max > threshold)
+              if (max > thresh)
                 *dest = 0;
               else
                 *dest = 255;
             }
-          
-          src += src_channels;
-          dest += dest_channels;
         }
+          
+      src += src_channels;
+      dest += dest_channels;
     }
 }
 
Index: app/pattern_select.c
===================================================================
RCS file: /debian/home/gnomecvs/gimp/app/pattern_select.c,v
retrieving revision 1.1.1.1.2.7
diff -u -r1.1.1.1.2.7 pattern_select.c
--- pattern_select.c	1998/08/25 03:43:21	1.1.1.1.2.7
+++ pattern_select.c	1998/12/02 21:51:39
@@ -278,7 +278,7 @@
   gtk_widget_popup (psp->pattern_popup, x, y);
 
   /*  Draw the pattern  */
-  buf = g_new (gchar, pattern_width * 3);
+  buf = g_new (guchar, pattern_width * 3);
   pattern_tag = canvas_tag (pattern->mask);
   pattern_prec = tag_precision (pattern_tag);
   src = canvas_portion_data (pattern->mask,0,0);
