? .bumpmap.c.swp
? patch_diff
Index: sel_gauss.c
===================================================================
RCS file: /cvs/gnome/gimp/plug-ins/common/sel_gauss.c,v
retrieving revision 1.61
diff -u -p -r1.61 sel_gauss.c
--- sel_gauss.c	30 Sep 2005 08:15:59 -0000	1.61
+++ sel_gauss.c	28 Oct 2005 23:54:53 -0000
@@ -45,6 +45,7 @@ typedef struct
   gdouble  radius;
   gint     maxdelta;
   gboolean update_preview;
+  gint32   delta_id;
 } BlurValues;
 
 
@@ -76,7 +77,8 @@ static BlurValues bvals =
 {
   5.0, /* radius   */
   50,  /* maxdelta */
-  TRUE /* update_preview */
+  TRUE, /* update_preview */
+  -1
 };
 
 MAIN ()
@@ -161,6 +163,7 @@ run (const gchar      *name,
         {
           bvals.radius   = param[3].data.d_float;
           bvals.maxdelta = CLAMP (param[4].data.d_int32, 0, 255);
+	  bvals.delta_id = param[5].data.d_drawable;
 
           if (bvals.radius <= 0.0)
             status = GIMP_PDB_CALLING_ERROR;
@@ -219,6 +222,7 @@ sel_gauss_dialog (GimpDrawable *drawable
   GtkWidget *table;
   GtkWidget *spinbutton;
   GtkObject *adj;
+  GtkWidget *delta_id;
   gboolean   run;
 
   gimp_ui_init (PLUG_IN_BINARY, FALSE);
@@ -252,7 +256,7 @@ sel_gauss_dialog (GimpDrawable *drawable
                     G_CALLBACK (preview_update),
                     NULL);
 
-  table = gtk_table_new (2, 3, FALSE);
+  table = gtk_table_new (3, 3, FALSE);
   gtk_table_set_col_spacings (GTK_TABLE (table), 6);
   gtk_table_set_row_spacings (GTK_TABLE (table), 6);
   gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 0);
@@ -276,6 +280,7 @@ sel_gauss_dialog (GimpDrawable *drawable
                               bvals.maxdelta, 0, 255, 1, 8, 0,
                               TRUE, 0, 0,
                               NULL, NULL);
+
   g_signal_connect (adj, "value-changed",
                     G_CALLBACK (gimp_int_adjustment_update),
                     &bvals.maxdelta);
@@ -283,6 +288,15 @@ sel_gauss_dialog (GimpDrawable *drawable
                             G_CALLBACK (gimp_preview_invalidate),
                             preview);
 
+  delta_id = gimp_drawable_combo_box_new (NULL, NULL);
+
+  gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX(delta_id), bvals.delta_id,
+                            G_CALLBACK (gimp_int_adjustment_update), &bvals.delta_id);
+
+  gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
+		             _("Delta layer:"), 0, 0,
+			     delta_id, 2, TRUE);
+  
   gtk_widget_show (dialog);
 
   run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
@@ -318,6 +332,7 @@ init_matrix (gdouble   radius,
 static void
 matrixmult (guchar   *src,
             guchar   *dest,
+	    guchar   *del,
             gint      width,
             gint      height,
             gdouble **mat,
@@ -332,6 +347,7 @@ matrixmult (guchar   *src,
   gint     rowstride;
   gdouble  sum, fact, d, alpha = 1.0;
   guchar  *src_b, *src_db;
+  guchar  *del_b, *del_db;
   gdouble *m;
   gint     offset;
 
@@ -351,6 +367,7 @@ matrixmult (guchar   *src,
               sum = 0.0;
               fact = 0.0;
               src_db = src + dix + b;
+	      del_db = del + dix + b;
 
               offset = rowstride * (y - numrad) + bytes * (x - numrad);
 
@@ -364,16 +381,18 @@ matrixmult (guchar   *src,
                   m = mat[ABS(i)];
 
                   src_b = src + six + b;
+		  del_b = del + six + b;
 
                   for (j = 1 - numrad; j < numrad; j++)
                     {
                       src_b += rowstride;
+		      del_b += rowstride;
                       six += rowstride;
 
                       if (y + j < 0 || y + j >= height)
                         continue;
 
-                      tmp = *src_db - *src_b;
+                      tmp = *del_db - *del_b;
                       if (tmp > maxdelta || tmp < -maxdelta)
                         continue;
 
@@ -406,12 +425,14 @@ sel_gauss (GimpDrawable *drawable,
            gdouble       radius,
            gint          maxdelta)
 {
-  GimpPixelRgn src_rgn, dest_rgn;
+  GimpPixelRgn src_rgn, dest_rgn, del_rgn;
+  GimpDrawable *delta;
   gint         width, height;
   gint         bytes;
   gboolean     has_alpha;
   guchar      *dest;
   guchar      *src;
+  guchar      *del;
   gint         x1, y1, x2, y2;
   gint         i;
   gdouble    **mat;
@@ -432,12 +453,19 @@ sel_gauss (GimpDrawable *drawable,
 
   src  = g_new (guchar, width * height * bytes);
   dest = g_new (guchar, width * height * bytes);
-
+  del = g_new (guchar, width * height * bytes);
+  
   gimp_pixel_rgn_init (&src_rgn,
                        drawable, x1, y1, width, height, FALSE, FALSE);
   gimp_pixel_rgn_get_rect (&src_rgn, src, x1, y1, width, height);
 
-  matrixmult (src, dest, width, height, mat, numrad,
+  delta = gimp_drawable_get (bvals.delta_id);
+
+  gimp_pixel_rgn_init (&del_rgn, delta, x1, y1, width, height, FALSE, FALSE);
+
+  gimp_pixel_rgn_get_rect (&del_rgn, del, x1, y1, width, height);
+
+  matrixmult (src, dest, del, width, height, mat, numrad,
               bytes, has_alpha, maxdelta, FALSE);
 
   gimp_pixel_rgn_init (&dest_rgn,
@@ -479,6 +507,8 @@ preview_update (GimpPreview *preview)
     gimp_drawable_preview_get_drawable (GIMP_DRAWABLE_PREVIEW (preview));
   bytes = drawable->bpp;
 
+  // delta = gimp_drawable_get (bvals.delta_id);
+  
   /*
    * Setup for filter...
    */
@@ -489,8 +519,9 @@ preview_update (GimpPreview *preview)
   gimp_pixel_rgn_init (&srcPR, drawable,
                        x1, y1, width, height,
                        FALSE, FALSE);
+  
   render_buffer = g_new (guchar, width * height * bytes);
-
+  
   src = g_new (guchar, width * height * bytes);
 
   /* render image */
@@ -506,7 +537,7 @@ preview_update (GimpPreview *preview)
 
   init_matrix(radius, mat, numrad);
 
-  matrixmult (src, render_buffer,
+  matrixmult (src, src, render_buffer,
               width, height,
               mat, numrad,
               bytes, has_alpha, bvals.maxdelta, TRUE);
