Commit 3075f763 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

app/paint-funcs/paint-funcs.c (gaussian_blur_region)

2007-04-26  Sven Neumann  <sven@gimp.org>

	* app/paint-funcs/paint-funcs.c (gaussian_blur_region)
	* plug-ins/common/blur.c (blur)
	* plug-ins/common/gauss.c (do_encoded_lre) (do_full_lre): reduce
	rounding errors.

	* plug-ins/common/checkerboard.c (checkerboard_dialog): layout
	improvements.

svn path=/trunk/; revision=22345
parent fef631cc
2007-04-26 Sven Neumann <sven@gimp.org>
* app/paint-funcs/paint-funcs.c (gaussian_blur_region)
* plug-ins/common/blur.c (blur)
* plug-ins/common/gauss.c (do_encoded_lre) (do_full_lre): reduce
rounding errors.
* plug-ins/common/checkerboard.c (checkerboard_dialog): layout
improvements.
2007-04-26 Mukund Sivaraman <muks@mukund.org>
* plug-ins/common/tiff-save.c: disabled the layer offsets saving
......@@ -2742,7 +2742,7 @@ gaussian_blur_region (PixelRegion *srcR,
start = (row < length) ? -row : -length;
end = (height <= (row + length)) ? (height - row - 1) : length;
val = 0;
val = total / 2;
i = start;
b = buf + (row + i) * 2;
......@@ -2804,7 +2804,7 @@ gaussian_blur_region (PixelRegion *srcR,
start = (col < length) ? -col : -length;
end = (width <= (col + length)) ? (width - col - 1) : length;
val = 0;
val = total / 2;
i = start;
b = buf + (col + i) * 2;
......
......@@ -315,7 +315,7 @@ blur (GimpDrawable *drawable)
(gint) cr[col - bytes] + (gint) cr[col] +
(gint) cr[col + bytes] +
(gint) nr[col - bytes] + (gint) nr[col] +
(gint) nr[col + bytes]) / 9;
(gint) nr[col + bytes] + 4) / 9;
ind = 0;
}
else
......@@ -324,25 +324,25 @@ blur (GimpDrawable *drawable)
* otherwise we have an alpha channel,
* but this is a color channel
*/
*d++ = ((gint)
(((gdouble) (pr[col - bytes] * pr[col - ind])
+ (gdouble) (pr[col] * pr[col + bytes - ind])
+ (gdouble) (pr[col + bytes] * pr[col + 2*bytes - ind])
+ (gdouble) (cr[col - bytes] * cr[col - ind])
+ (gdouble) (cr[col] * cr[col + bytes - ind])
+ (gdouble) (cr[col + bytes] * cr[col + 2*bytes - ind])
+ (gdouble) (nr[col - bytes] * nr[col - ind])
+ (gdouble) (nr[col] * nr[col + bytes - ind])
+ (gdouble) (nr[col + bytes] * nr[col + 2*bytes - ind]))
/ ((gdouble) pr[col - ind]
+ (gdouble) pr[col + bytes - ind]
+ (gdouble) pr[col + 2*bytes - ind]
+ (gdouble) cr[col - ind]
+ (gdouble) cr[col + bytes - ind]
+ (gdouble) cr[col + 2*bytes - ind]
+ (gdouble) nr[col - ind]
+ (gdouble) nr[col + bytes - ind]
+ (gdouble) nr[col + 2*bytes - ind])));
*d++ = ROUND(
((gdouble) (pr[col - bytes] * pr[col - ind])
+ (gdouble) (pr[col] * pr[col + bytes - ind])
+ (gdouble) (pr[col + bytes] * pr[col + 2*bytes - ind])
+ (gdouble) (cr[col - bytes] * cr[col - ind])
+ (gdouble) (cr[col] * cr[col + bytes - ind])
+ (gdouble) (cr[col + bytes] * cr[col + 2*bytes - ind])
+ (gdouble) (nr[col - bytes] * nr[col - ind])
+ (gdouble) (nr[col] * nr[col + bytes - ind])
+ (gdouble) (nr[col + bytes] * nr[col + 2*bytes - ind]))
/ ((gdouble) pr[col - ind]
+ (gdouble) pr[col + bytes - ind]
+ (gdouble) pr[col + 2*bytes - ind]
+ (gdouble) cr[col - ind]
+ (gdouble) cr[col + bytes - ind]
+ (gdouble) cr[col + 2*bytes - ind]
+ (gdouble) nr[col - ind]
+ (gdouble) nr[col + bytes - ind]
+ (gdouble) nr[col + 2*bytes - ind]));
}
}
......
......@@ -331,6 +331,7 @@ checkerboard_dialog (gint32 image_ID,
{
GtkWidget *dialog;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *preview;
GtkWidget *toggle;
GtkWidget *size_entry;
......@@ -370,17 +371,9 @@ checkerboard_dialog (gint32 image_ID,
G_CALLBACK (do_checkerboard_pattern),
drawable);
toggle = gtk_check_button_new_with_mnemonic (_("_Psychobilly"));
gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), cvals.mode);
gtk_widget_show (toggle);
g_signal_connect (toggle, "toggled",
G_CALLBACK (gimp_toggle_button_update),
&cvals.mode);
g_signal_connect_swapped (toggle, "toggled",
G_CALLBACK (gimp_preview_invalidate),
preview);
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
/* Get the image resolution and unit */
gimp_image_get_resolution (image_ID, &xres, &yres);
......@@ -395,6 +388,8 @@ checkerboard_dialog (gint32 image_ID,
GIMP_SIZE_ENTRY_UPDATE_SIZE);
gtk_table_set_col_spacing (GTK_TABLE (size_entry), 0, 4);
gtk_table_set_col_spacing (GTK_TABLE (size_entry), 1, 4);
gtk_box_pack_start (GTK_BOX (hbox), size_entry, FALSE, FALSE, 0);
gtk_widget_show (size_entry);
/* set the unit back to pixels, since most times we will want pixels */
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (size_entry), GIMP_UNIT_PIXEL);
......@@ -423,8 +418,17 @@ checkerboard_dialog (gint32 image_ID,
G_CALLBACK (gimp_preview_invalidate),
preview);
gtk_box_pack_start (GTK_BOX (vbox), size_entry, FALSE, FALSE, 0);
gtk_widget_show (size_entry);
toggle = gtk_check_button_new_with_mnemonic (_("_Psychobilly"));
gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), cvals.mode);
gtk_widget_show (toggle);
g_signal_connect (toggle, "toggled",
G_CALLBACK (gimp_toggle_button_update),
&cvals.mode);
g_signal_connect_swapped (toggle, "toggled",
G_CALLBACK (gimp_preview_invalidate),
preview);
gtk_widget_show (dialog);
......
......@@ -746,7 +746,7 @@ do_encoded_lre (const gint *enc,
gint nb;
gint s1;
gint i;
gint val = 0;
gint val = ctotal / 2;
gint start = - length;
rpt = &enc[col + start];
......@@ -791,9 +791,9 @@ do_full_lre (const gint *src,
{
const gint *x1;
const gint *x2;
const gint *c = &curve[0];
const gint *c = &curve[0];
gint i;
gint val;
gint val = ctotal / 2;
x1 = x2 = &src[col];
......@@ -801,7 +801,7 @@ do_full_lre (const gint *src,
* processed ONCE
*/
val = x1[0] * c[0];
val += x1[0] * c[0];
c += 1;
x1 += 1;
......@@ -856,7 +856,7 @@ do_full_lre (const gint *src,
i -= 1;
}
*dest = val / ctotal;
*dest = (val + ctotal / 2) / ctotal;
dest += dist;
}
......@@ -1503,30 +1503,20 @@ find_iir_constants (gdouble *n_p,
gdouble *bd_m,
gdouble std_dev)
{
gint i;
gdouble x0;
gdouble x1;
gdouble x2;
gdouble x3;
gdouble x4;
gdouble x5;
gdouble x6;
gdouble x7;
gdouble div;
/* The constants used in the implemenation of a casual sequence
* using a 4th order approximation of the gaussian operator
*/
div = sqrt(2 * G_PI) * std_dev;
x0 = -1.783 / std_dev;
x1 = -1.723 / std_dev;
x2 = 0.6318 / std_dev;
x3 = 1.997 / std_dev;
x4 = 1.6803 / div;
x5 = 3.735 / div;
x6 = -0.6803 / div;
x7 = -0.2598 / div;
const gdouble div = sqrt (2 * G_PI) * std_dev;
const gdouble x0 = -1.783 / std_dev;
const gdouble x1 = -1.723 / std_dev;
const gdouble x2 = 0.6318 / std_dev;
const gdouble x3 = 1.997 / std_dev;
const gdouble x4 = 1.6803 / div;
const gdouble x5 = 3.735 / div;
const gdouble x6 = -0.6803 / div;
const gdouble x7 = -0.2598 / div;
gint i;
n_p [0] = x4 + x6;
n_p [1] = (exp(x1)*(x7*sin(x3)-(x6+2*x4)*cos(x3)) +
......@@ -1608,16 +1598,13 @@ make_rle_curve (gdouble sigma,
gint **p_sum,
gint *p_total)
{
gint *curve;
gdouble sigma2;
gdouble l;
gint temp;
gint i, n;
gint length;
gint *sum;
sigma2 = 2 * sigma * sigma;
l = sqrt (-sigma2 * log (1.0 / 255.0));
const gdouble sigma2 = 2 * sigma * sigma;
const gdouble l = sqrt (-sigma2 * log (1.0 / 255.0));
gint temp;
gint i, n;
gint length;
gint *sum;
gint *curve;
n = ceil (l) * 2;
if ((n % 2) == 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment