Commit d5d9640f authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

applied a patch by Tobias Lenz that makes use of the state that was added

2005-10-28  Sven Neumann  <sven@gimp.org>

	* app/base/siox.c: applied a patch by Tobias Lenz that makes use
	of the state that was added to SIOX in order to speed up the tool.
parent d6da6d0f
2005-10-28 Sven Neumann <sven@gimp.org>
* app/base/siox.c: applied a patch by Tobias Lenz that makes use
of the state that was added to SIOX in order to speed up the tool.
2005-10-28 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimppageselector.[ch]: added new signal "activate"
......
......@@ -40,6 +40,7 @@
#include "libgimpmath/gimpmath.h"
#include "base-types.h"
#include "base-enums.h"
#include "paint-funcs/paint-funcs.h"
#include "cpercep.h"
#include "pixel-region.h"
......@@ -825,105 +826,132 @@ siox_foreground_extract (SioxState *state,
siox_progress_update (progress_callback, progress_data, 0.0);
g_hash_table_foreach_remove (state->cache,
(GHRFunc) dummy_remove_hash, NULL);
/* count given foreground and background pixels */
pixel_region_init (&mapPR, mask, x, y, width, height, FALSE);
if (refinement & SIOX_REFINEMENT_CHANGE_SENSITIVITY)
{
refinement = SIOX_REFINEMENT_RECALCULATE;
}
else
{
if (! state->bgsig)
refinement |= SIOX_REFINEMENT_ADD_BACKGROUND;
for (pr = pixel_regions_register (1, &mapPR);
pr != NULL; pr = pixel_regions_process (pr))
if (! state->fgsig)
refinement |= SIOX_REFINEMENT_ADD_FOREGROUND;
}
if (refinement & (SIOX_REFINEMENT_ADD_FOREGROUND |
SIOX_REFINEMENT_ADD_BACKGROUND))
{
const guchar *map = mapPR.data;
g_hash_table_foreach_remove (state->cache,
(GHRFunc) dummy_remove_hash, NULL);
/* count given foreground and background pixels */
pixel_region_init (&mapPR, mask, x, y, width, height, FALSE);
for (row = 0; row < mapPR.h; row++)
for (pr = pixel_regions_register (1, &mapPR);
pr != NULL;
pr = pixel_regions_process (pr))
{
const guchar *m = map;
const guchar *map = mapPR.data;
for (col = 0; col < mapPR.w; col++, m++)
for (row = 0; row < mapPR.h; row++)
{
if (*m < SIOX_LOW)
surebgcount++;
else if (*m > SIOX_HIGH)
surefgcount++;
}
const guchar *m = map;
map += mapPR.rowstride;
for (col = 0; col < mapPR.w; col++, m++)
{
if (*m < SIOX_LOW)
surebgcount++;
else if (*m > SIOX_HIGH)
surefgcount++;
}
map += mapPR.rowstride;
}
}
}
#ifdef SIOX_DEBUG
g_printerr ("siox.c: usermask #surebg=%d #surefg=%d\n",
surebgcount, surefgcount);
g_printerr ("siox.c: usermask #surebg=%d #surefg=%d\n",
surebgcount, surefgcount);
#endif
surebg = g_new (lab, surebgcount);
surefg = g_new (lab, surefgcount);
i = 0;
j = 0;
surebg = g_new (lab, surebgcount);
surefg = g_new (lab, surefgcount);
siox_progress_update (progress_callback, progress_data, 0.1);
i = 0;
j = 0;
/* create inputs for color signatures */
pixel_region_init (&srcPR, state->pixels,
x - state->offset_x, y - state->offset_y,
width, height, FALSE);
pixel_region_init (&mapPR, mask,
x, y, width, height, FALSE);
siox_progress_update (progress_callback, progress_data, 0.1);
for (pr = pixel_regions_register (2, &srcPR, &mapPR);
pr != NULL; pr = pixel_regions_process (pr))
{
const guchar *src = srcPR.data;
const guchar *map = mapPR.data;
/* create inputs for color signatures */
pixel_region_init (&srcPR, state->pixels,
x - state->offset_x, y - state->offset_y,
width, height, FALSE);
pixel_region_init (&mapPR, mask,
x, y, width, height, FALSE);
for (row = 0; row < srcPR.h; row++)
for (pr = pixel_regions_register (2, &srcPR, &mapPR);
pr != NULL; pr = pixel_regions_process (pr))
{
const guchar *s = src;
const guchar *m = map;
const guchar *src = srcPR.data;
const guchar *map = mapPR.data;
for (col = 0; col < srcPR.w; col++, m++, s += state->bpp)
for (row = 0; row < srcPR.h; row++)
{
if (*m < SIOX_LOW)
{
calc_lab (s, state->bpp, state->colormap, surebg + i);
i++;
}
else if (*m > SIOX_HIGH)
const guchar *s = src;
const guchar *m = map;
for (col = 0; col < srcPR.w; col++, m++, s += state->bpp)
{
calc_lab (s, state->bpp, state->colormap, surefg + j);
j++;
if (*m < SIOX_LOW)
{
calc_lab (s, state->bpp, state->colormap, surebg + i);
i++;
}
else if (*m > SIOX_HIGH)
{
calc_lab (s, state->bpp, state->colormap, surefg + j);
j++;
}
}
}
src += srcPR.rowstride;
map += mapPR.rowstride;
src += srcPR.rowstride;
map += mapPR.rowstride;
}
}
}
siox_progress_update (progress_callback, progress_data, 0.2);
/* Create color signature for the background */
state->bgsig = create_signature (surebg, surebgcount,
&state->bgsiglen, limits,
state->bpp == 1 ?
SIOX_GRAY_DIMS : SIOX_COLOR_DIMS);
g_free (surebg);
siox_progress_update (progress_callback, progress_data, 0.2);
if (state->bgsiglen < 1)
{
g_free (surefg);
return;
}
if (refinement & SIOX_REFINEMENT_ADD_BACKGROUND)
{
/* Create color signature for the background */
state->bgsig = create_signature (surebg, surebgcount,
&state->bgsiglen, limits,
state->bpp == 1 ?
SIOX_GRAY_DIMS : SIOX_COLOR_DIMS);
g_free (surebg);
if (state->bgsiglen < 1)
{
g_free (surefg);
return;
}
}
siox_progress_update (progress_callback, progress_data, 0.3);
siox_progress_update (progress_callback, progress_data, 0.3);
/* Create color signature for the foreground */
state->fgsig = create_signature (surefg, surefgcount,
&state->fgsiglen, limits,
state->bpp == 1 ?
SIOX_GRAY_DIMS : SIOX_COLOR_DIMS);
g_free (surefg);
if (refinement & SIOX_REFINEMENT_ADD_FOREGROUND)
{
/* Create color signature for the foreground */
state->fgsig = create_signature (surefg, surefgcount,
&state->fgsiglen, limits,
state->bpp == 1 ?
SIOX_GRAY_DIMS : SIOX_COLOR_DIMS);
g_free (surefg);
}
}
siox_progress_update (progress_callback, progress_data, 0.4);
......
......@@ -195,6 +195,8 @@ gimp_page_selector_class_init (GimpPageSelectorClass *klass)
*
* The "activate" signal on GimpPageSelector is an action signal. It
* is emitted when a user double-clicks an item in the page selection.
*
* Since: GIMP 2.4
*/
selector_signals[ACTIVATE] =
g_signal_new ("activate",
......
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