From e65ec123967659d0c641f875c97e2c0b5a3023fd Mon Sep 17 00:00:00 2001 From: David Odin Date: Sat, 13 Nov 2004 14:52:23 +0000 Subject: [PATCH] use a GimpAspectPreview instead of a GimpDrawablePreview. Fixes bug * plug-ins/common/retinex.c: use a GimpAspectPreview instead of a GimpDrawablePreview. Fixes bug #157915. Also fixed the funny behaviour of the progress bar. --- ChangeLog | 6 ++++ plug-ins/common/retinex.c | 63 ++++++++++++++++++++------------------ plug-ins/gfig/gfig-style.h | 1 + 3 files changed, 40 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 40c6849a08..5cf8d60abe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-11-13 DindinX + + * plug-ins/common/retinex.c: use a GimpAspectPreview instead of a + GimpDrawablePreview. Fixes bug #157915. Also fixed the funny behaviour + of the progress bar. + 2004-11-13 Sven Neumann * libgimpbase/gimputils.c (gimp_strip_uline): changed based on a diff --git a/plug-ins/common/retinex.c b/plug-ins/common/retinex.c index b9e3597e40..88d0b5abd0 100644 --- a/plug-ins/common/retinex.c +++ b/plug-ins/common/retinex.c @@ -299,7 +299,7 @@ retinex_dialog (GimpDrawable *drawable) gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), main_vbox); gtk_widget_show (main_vbox); - preview = gimp_drawable_preview_new (drawable, &rvals.preview); + preview = gimp_aspect_preview_new (drawable, &rvals.preview); gtk_box_pack_start_defaults (GTK_BOX (main_vbox), preview); gtk_widget_show (preview); @@ -405,40 +405,42 @@ retinex (GimpDrawable *drawable, guchar *psrc = NULL; GimpPixelRgn dst_rgn, src_rgn; + bytes = drawable->bpp; + /* * Get the size of the current image or its selection. */ if (preview) { - gimp_preview_get_position (preview, &x, &y); gimp_preview_get_size (preview, &width, &height); + src = gimp_drawable_get_thumbnail_data (drawable->drawable_id, + &width, &height, &bytes); } - else if (! gimp_drawable_mask_intersect (drawable->drawable_id, - &x, &y, &width, &height)) + else { - return; + if (! gimp_drawable_mask_intersect (drawable->drawable_id, + &x, &y, &width, &height)) + return; + + /* Allocate memory */ + size = width * height * bytes; + src = g_try_malloc (sizeof (guchar) * size); + + if (src == NULL) + { + g_warning ("Failed to allocate memory"); + return; + } + + memset (src, 0, sizeof (guchar) * size); + + /* Fill allocated memory with pixel data */ + gimp_pixel_rgn_init (&src_rgn, drawable, + x, y, width, height, + FALSE, FALSE); + gimp_pixel_rgn_get_rect (&src_rgn, src, x, y, width, height); } - bytes = drawable->bpp; - - /* Allocate memory */ - size = width * height * bytes; - src = g_try_malloc (sizeof (guchar) * size); - - if (src == NULL) - { - g_warning ("Failed to allocate memory"); - return; - } - - memset (src, 0, sizeof (guchar) * size); - - /* Fill allocated memory with pixel data */ - gimp_pixel_rgn_init (&src_rgn, drawable, - x, y, width, height, - FALSE, FALSE); - gimp_pixel_rgn_get_rect (&src_rgn, src, x, y, width, height); - /* Algorithm for Multi-scale Retinex with color Restoration (MSRCR). */ @@ -638,11 +640,12 @@ MSRCR (guchar *src, gint width, gint height, gint bytes, gboolean preview_mode) gfloat alpha; gfloat gain; gfloat offset; + gdouble max_preview; if (!preview_mode) { gimp_progress_init (_("Retinex: Filtering...")); - gimp_progress_update (1.0 / ((rvals.nscales * 3) + 3)); + max_preview = 3 * rvals.nscales; } /* Allocate all the memory needed for algorithm*/ @@ -738,8 +741,8 @@ MSRCR (guchar *src, gint width, gint height, gint bytes, gboolean preview_mode) } if (!preview_mode) - gimp_progress_update ((1.0 + ((scale + 1) * (channel + 1))) / - ((rvals.nscales * 3) + 3)); + gimp_progress_update ((channel * rvals.nscales + scale) / + max_preview); } } g_free(in); @@ -769,9 +772,9 @@ MSRCR (guchar *src, gint width, gint height, gint bytes, gboolean preview_mode) pdst[2] = gain * ((log(alpha * (psrc[2]+1.)) - logl) * pdst[2]) + offset; } - if (!preview_mode) +/* if (!preview_mode) gimp_progress_update ((2.0 + (rvals.nscales * 3)) / - ((rvals.nscales * 3) + 3)); + ((rvals.nscales * 3) + 3));*/ /* Adapt the dynamics of the colors according to the statistics of the first and second order. diff --git a/plug-ins/gfig/gfig-style.h b/plug-ins/gfig/gfig-style.h index bbd3d8ab48..dedf107c7c 100644 --- a/plug-ins/gfig/gfig-style.h +++ b/plug-ins/gfig/gfig-style.h @@ -47,6 +47,7 @@ struct _Style GimpRGB foreground; GimpRGB background; gboolean reverselines; + gint ref_count; }; void set_foreground_callback (GimpColorButton *button,