gimp/plug-ins/common/oilify.c

943 lines
28 KiB
C
Raw Normal View History

1997-11-25 06:05:25 +08:00
/*
* This is a plug-in for GIMP.
1997-11-25 06:05:25 +08:00
*
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
* Copyright (C) 1996 Torsten Martinsen
* Copyright (C) 2007 Daniel Richard G.
1997-11-25 06:05:25 +08:00
*
* This program is free software: you can redistribute it and/or modify
1997-11-25 06:05:25 +08:00
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
1997-11-25 06:05:25 +08:00
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1997-11-25 06:05:25 +08:00
*/
#include "config.h"
#include <string.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include <libgimpmath/gimpmath.h>
1997-11-25 06:05:25 +08:00
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
#include "libgimp/stdplugins-intl.h"
#define PLUG_IN_PROC "plug-in-oilify"
#define PLUG_IN_ENHANCED_PROC "plug-in-oilify-enhanced"
#define PLUG_IN_BINARY "oilify"
#define PLUG_IN_ROLE "gimp-oilify"
#define SCALE_WIDTH 125
#define HISTSIZE 256
#define MODE_RGB 0
#define MODE_INTEN 1
1997-11-25 06:05:25 +08:00
typedef struct
{
gdouble mask_size;
gboolean use_mask_size_map;
gint mask_size_map;
gdouble exponent;
gboolean use_exponent_map;
gint exponent_map;
gint mode;
1997-11-25 06:05:25 +08:00
} OilifyVals;
/* Declare local functions.
*/
static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static void oilify (GimpDrawable *drawable,
GimpPreview *preview);
static gboolean oilify_dialog (GimpDrawable *drawable);
1997-11-25 06:05:25 +08:00
const GimpPlugInInfo PLUG_IN_INFO =
1997-11-25 06:05:25 +08:00
{
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
1997-11-25 06:05:25 +08:00
};
static OilifyVals ovals =
{
8.0, /* mask size */
FALSE, /* use mask-size map? */
-1, /* mask-size map */
8.0, /* exponent */
FALSE, /* use exponent map? */
-1, /* exponent map */
MODE_INTEN /* mode */
1997-11-25 06:05:25 +08:00
};
MAIN ()
static void
query (void)
1997-11-25 06:05:25 +08:00
{
static const GimpParamDef args[] =
1997-11-25 06:05:25 +08:00
{
{ GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
{ GIMP_PDB_IMAGE, "image", "Input image (unused)" },
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
{ GIMP_PDB_INT32, "mask-size", "Oil paint mask size" },
{ GIMP_PDB_INT32, "mode", "Algorithm { RGB (0), INTENSITY (1) }" }
1997-11-25 06:05:25 +08:00
};
static const GimpParamDef args_enhanced[] =
{
{ GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
{ GIMP_PDB_IMAGE, "image", "Input image (unused)" },
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
{ GIMP_PDB_INT32, "mode", "Algorithm { RGB (0), INTENSITY (1) }" },
{ GIMP_PDB_INT32, "mask-size", "Oil paint mask size" },
{ GIMP_PDB_DRAWABLE, "mask-size-map", "Mask size control map" },
{ GIMP_PDB_INT32, "exponent", "Oil paint exponent" },
{ GIMP_PDB_DRAWABLE, "exponent-map", "Exponent control map" }
};
gimp_install_procedure (PLUG_IN_PROC,
Bill Skaggs <weskaggs@primate.ucdavis.edu> * plug-ins/common/AlienMap2.c * plug-ins/common/CML_explorer.c * plug-ins/common/align_layers.c * plug-ins/common/animationplay.c * plug-ins/common/animoptimize.c * plug-ins/common/apply_lens.c * plug-ins/common/autocrop.c * plug-ins/common/autostretch_hsv.c * plug-ins/common/blinds.c * plug-ins/common/blur.c * plug-ins/common/borderaverage.c * plug-ins/common/bumpmap.c * plug-ins/common/c_astretch.c * plug-ins/common/cartoon.c * plug-ins/common/ccanalyze.c * plug-ins/common/channel_mixer.c * plug-ins/common/checkerboard.c * plug-ins/common/color_enhance.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/compose.c * plug-ins/common/convmatrix.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/decompose.c * plug-ins/common/deinterlace.c * plug-ins/common/depthmerge.c * plug-ins/common/despeckle.c * plug-ins/common/destripe.c * plug-ins/common/diffraction.c * plug-ins/common/displace.c * plug-ins/common/dog.c * plug-ins/common/edge.c * plug-ins/common/emboss.c * plug-ins/common/engrave.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/flarefx.c * plug-ins/common/fp.c * plug-ins/common/fractaltrace.c * plug-ins/common/gauss.c * plug-ins/common/gee.c * plug-ins/common/gee_zoom.c * plug-ins/common/glasstile.c * plug-ins/common/gnomeprint.c * plug-ins/common/gqbist.c * plug-ins/common/gradmap.c * plug-ins/common/grid.c * plug-ins/common/guillotine.c * plug-ins/common/hot.c * plug-ins/common/illusion.c * plug-ins/common/iwarp.c * plug-ins/common/jigsaw.c * plug-ins/common/laplace.c * plug-ins/common/lic.c * plug-ins/common/mail.c * plug-ins/common/mapcolor.c * plug-ins/common/max_rgb.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/neon.c * plug-ins/common/newsprint.c * plug-ins/common/nlfilt.c * plug-ins/common/noisify.c * plug-ins/common/normalize.c * plug-ins/common/nova.c * plug-ins/common/oilify.c * plug-ins/common/papertile.c * plug-ins/common/photocopy.c * plug-ins/common/pixelize.c * plug-ins/common/plasma.c * plug-ins/common/plugin-browser.c * plug-ins/common/polar.c * plug-ins/common/procedure-browser.c * plug-ins/common/randomize.c * plug-ins/common/retinex.c * plug-ins/common/ripple.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/screenshot.c * plug-ins/common/sel_gauss.c * plug-ins/common/semiflatten.c * plug-ins/common/sharpen.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/smooth_palette.c * plug-ins/common/snoise.c * plug-ins/common/sobel.c * plug-ins/common/softglow.c * plug-ins/common/sparkle.c * plug-ins/common/spheredesigner.c * plug-ins/common/spread.c * plug-ins/common/struc.c * plug-ins/common/threshold_alpha.c * plug-ins/common/tile.c * plug-ins/common/tileit.c * plug-ins/common/tiler.c * plug-ins/common/uniteditor.c * plug-ins/common/unsharp.c * plug-ins/common/video.c * plug-ins/common/vinvert.c * plug-ins/common/vpropagate.c * plug-ins/common/warp.c * plug-ins/common/waves.c * plug-ins/common/whirlpinch.c * plug-ins/common/wind.c * plug-ins/common/winprint.c * plug-ins/common/zealouscrop.c: Give "helpful" blurbs to menu- accessible plugins, and mark them for translation. Probably there is room for improvement in some of them. Still needs to be done for plug-ins not in "common".
2006-03-16 05:10:34 +08:00
N_("Smear colors to simulate an oil painting"),
"This function performs the well-known oil-paint "
"effect on the specified drawable.",
"Torsten Martinsen",
"Torsten Martinsen",
"1996",
N_("Oili_fy..."),
"RGB*, GRAY*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Filters/Artistic");
gimp_install_procedure (PLUG_IN_ENHANCED_PROC,
N_("Smear colors to simulate an oil painting"),
"This function performs the well-known oil-paint "
"effect on the specified drawable.",
"Torsten Martinsen, Daniel Richard G.",
"Torsten Martinsen, Daniel Richard G.",
"2007",
NULL,
"RGB*, GRAY*",
GIMP_PLUGIN,
G_N_ELEMENTS (args_enhanced), 0,
args_enhanced, NULL);
1997-11-25 06:05:25 +08:00
}
static void
run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals)
1997-11-25 06:05:25 +08:00
{
static GimpParam values[1];
GimpDrawable *drawable;
GimpRunMode run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
1997-11-25 06:05:25 +08:00
INIT_I18N ();
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
1997-11-25 06:05:25 +08:00
run_mode = param[0].data.d_int32;
/* Get the specified drawable */
drawable = gimp_drawable_get (param[2].data.d_drawable);
gimp_tile_cache_ntiles (2 * drawable->ntile_cols);
*nreturn_vals = 1;
*return_vals = values;
1997-11-25 06:05:25 +08:00
values[0].type = GIMP_PDB_STATUS;
1997-11-25 06:05:25 +08:00
values[0].data.d_status = status;
switch (run_mode)
{
case GIMP_RUN_INTERACTIVE:
1997-11-25 06:05:25 +08:00
/* Possibly retrieve data */
gimp_get_data (PLUG_IN_PROC, &ovals);
1997-11-25 06:05:25 +08:00
/* First acquire information with a dialog */
if (! oilify_dialog (drawable))
return;
1997-11-25 06:05:25 +08:00
break;
case GIMP_RUN_NONINTERACTIVE:
/* Interpret the arguments per the name used to invoke us */
if (! strcmp (name, PLUG_IN_PROC))
{
if (nparams != 5)
{
status = GIMP_PDB_CALLING_ERROR;
}
else
{
ovals.mask_size = (gdouble) param[3].data.d_int32;
ovals.mode = param[4].data.d_int32;
}
}
else if (! strcmp (name, PLUG_IN_ENHANCED_PROC))
{
if (nparams < 5 || nparams > 8)
{
status = GIMP_PDB_CALLING_ERROR;
}
else
{
ovals.mode = param[3].data.d_int32;
ovals.mask_size = (gdouble) param[4].data.d_int32;
if (nparams >= 6)
ovals.mask_size_map = param[5].data.d_int32;
if (nparams >= 7)
ovals.exponent = (gdouble) param[6].data.d_int32;
if (nparams == 8)
ovals.exponent_map = param[7].data.d_int32;
ovals.use_mask_size_map = ovals.mask_size_map >= 0;
ovals.use_exponent_map = ovals.exponent_map >= 0;
if (ovals.mask_size < 1.0 ||
ovals.exponent < 1.0 ||
(ovals.mode != MODE_INTEN && ovals.mode != MODE_RGB) ||
(ovals.mode == MODE_INTEN &&
! gimp_drawable_is_rgb (drawable->drawable_id)))
{
status = GIMP_PDB_CALLING_ERROR;
}
}
}
1997-11-25 06:05:25 +08:00
break;
case GIMP_RUN_WITH_LAST_VALS:
1997-11-25 06:05:25 +08:00
/* Possibly retrieve data */
gimp_get_data (PLUG_IN_PROC, &ovals);
1997-11-25 06:05:25 +08:00
break;
default:
break;
}
/* Make sure that the drawable is gray or RGB color */
if ((status == GIMP_PDB_SUCCESS) &&
(gimp_drawable_is_rgb (drawable->drawable_id) ||
gimp_drawable_is_gray (drawable->drawable_id)))
1997-11-25 06:05:25 +08:00
{
gimp_progress_init (_("Oil painting"));
oilify (drawable, NULL);
1997-11-25 06:05:25 +08:00
if (run_mode != GIMP_RUN_NONINTERACTIVE)
gimp_displays_flush ();
1997-11-25 06:05:25 +08:00
/* Store data */
if (run_mode == GIMP_RUN_INTERACTIVE)
gimp_set_data (PLUG_IN_PROC, &ovals, sizeof (OilifyVals));
1997-11-25 06:05:25 +08:00
}
else
{
/* gimp_message ("oilify: cannot operate on indexed color images"); */
status = GIMP_PDB_EXECUTION_ERROR;
1997-11-25 06:05:25 +08:00
}
values[0].data.d_status = status;
gimp_drawable_detach (drawable);
}
/*
* Helper function to read a sample from a mask-size/exponent map
*/
static inline gfloat
get_map_value (const guchar *src,
gint bpp)
{
gfloat value;
if (bpp >= 3)
value = GIMP_RGB_LUMINANCE (src[0], src[1], src[2]);
else
value = *src;
if (value < 1.0)
value = 1.0;
/* value should be in [0,1] */
value /= 255.0;
return value;
}
/*
* This is a special-case form of the powf() function, limited to integer
* exponents. It calculates e.g. x^13 as (x^8)*(x^4)*(x^1).
*
* x can be anything, y must be in [0,255]
*/
static inline gfloat
fast_powf (gfloat x, gint y)
{
gfloat value;
gfloat x_pow[8];
guint y_uint = (guint) y;
guint bitmask;
gint i;
if (y_uint & 0x01)
value = x;
else
value = 1.0;
x_pow[0] = x;
for (bitmask = 0x02, i = 1;
bitmask <= y_uint;
bitmask <<= 1, i++)
{
/* x_pow[i] == x_pow[i-1]^2 == x^(2^i) */
x_pow[i] = SQR (x_pow[i - 1]);
if (y_uint & bitmask)
value *= x_pow[i];
}
return value;
}
1997-11-25 06:05:25 +08:00
/*
* For each i in [0, HISTSIZE), hist[i] is the number of occurrences of the
* value i. Return a value in [0, HISTSIZE) weighted heavily toward the
* most frequent values in the histogram.
*
* Assuming that hist_max is the maximum number of occurrences for any
* one value in the histogram, the weight given to each value i is
*
* weight = (hist[i] / hist_max)^exponent
*
* (i.e. the normalized histogram frequency raised to some power)
1997-11-25 06:05:25 +08:00
*/
static inline guchar
weighted_average_value (gint hist[HISTSIZE], gfloat exponent)
1997-11-25 06:05:25 +08:00
{
gint i;
gint hist_max = 1;
gint exponent_int = 0;
gfloat sum = 0.0;
gfloat div = 1.0e-6;
gint value;
1997-11-25 06:05:25 +08:00
for (i = 0; i < HISTSIZE; i++)
hist_max = MAX (hist_max, hist[i]);
if ((exponent - floor (exponent)) < 0.001 && exponent <= 255.0)
exponent_int = (gint) exponent;
1997-11-25 06:05:25 +08:00
for (i = 0; i < HISTSIZE; i++)
{
gfloat ratio = (gfloat) hist[i] / (gfloat) hist_max;
gfloat weight;
1997-11-25 06:05:25 +08:00
if (exponent_int)
weight = fast_powf (ratio, exponent_int);
else
weight = pow (ratio, exponent);
sum += weight * (gfloat) i;
div += weight;
}
value = (gint) (sum / div);
return (guchar) CLAMP0255 (value);
}
/*
* For each i in [0, HISTSIZE), hist[i] is the number of occurrences of
* pixels with intensity i. hist_rgb[][i] is the average color of those
* pixels with intensity i, but with each channel multiplied by hist[i].
* Write to dest a pixel whose color is a weighted average of all the
* colors in hist_rgb[][], biased heavily toward those with the most
* frequently-occurring intensities (as noted in hist[]).
*
* The weight formula is the same as in weighted_average_value().
*/
static inline void
weighted_average_color (gint hist[HISTSIZE],
gint hist_rgb[4][HISTSIZE],
gfloat exponent,
guchar *dest,
gint bpp)
{
gint i, b;
gint hist_max = 1;
gint exponent_int = 0;
gfloat div = 1.0e-6;
gfloat color[4] = { 0.0, 0.0, 0.0, 0.0 };
for (i = 0; i < HISTSIZE; i++)
hist_max = MAX (hist_max, hist[i]);
if ((exponent - floor (exponent)) < 0.001 && exponent <= 255.0)
exponent_int = (gint) exponent;
for (i = 0; i < HISTSIZE; i++)
{
gfloat ratio = (gfloat) hist[i] / (gfloat) hist_max;
gfloat weight;
if (exponent_int)
weight = fast_powf (ratio, exponent_int);
else
weight = pow (ratio, exponent);
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 23:27:05 +08:00
if (hist[i] > 0)
for (b = 0; b < bpp; b++)
color[b] += weight * (gfloat) hist_rgb[b][i] / (gfloat) hist[i];
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 23:27:05 +08:00
div += weight;
}
for (b = 0; b < bpp; b++)
{
gint c = (gint) (color[b] / div);
dest[b] = (guchar) CLAMP0255 (c);
}
}
1997-11-25 06:05:25 +08:00
/*
* For all x and y as requested, replace the pixel at (x,y)
* with a weighted average of the most frequently occurring
* values in a circle of mask_size diameter centered at (x,y).
*/
static void
oilify (GimpDrawable *drawable,
GimpPreview *preview)
{
gboolean use_inten;
gboolean use_msmap = FALSE;
gboolean use_emap = FALSE;
GimpDrawable *mask_size_map_drawable = NULL;
GimpDrawable *exponent_map_drawable = NULL;
GimpPixelRgn mask_size_map_rgn;
GimpPixelRgn exponent_map_rgn;
gint msmap_bpp = 0;
gint emap_bpp = 0;
GimpPixelRgn dest_rgn;
GimpPixelRgn *regions[3];
gint n_regions;
gint bpp;
gint *sqr_lut;
gint x1, y1, x2, y2;
gint width, height;
gint Hist[HISTSIZE];
gint Hist_rgb[4][HISTSIZE];
gpointer pr;
gint progress, max_progress;
guchar *src_buf;
guchar *src_inten_buf = NULL;
gint i;
use_inten = (ovals.mode == MODE_INTEN);
/* Get the selection bounds */
if (preview)
{
gimp_preview_get_position (preview, &x1, &y1);
gimp_preview_get_size (preview, &width, &height);
x2 = x1 + width;
y2 = y1 + height;
}
else
{
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
width = x2 - x1;
height = y2 - y1;
}
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 23:27:05 +08:00
progress = 0;
max_progress = width * height;
bpp = drawable->bpp;
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 23:27:05 +08:00
/*
* Look-up-table implementation of the square function, for use in the
* VERY TIGHT inner loops
*/
{
gint lut_size = (gint) ovals.mask_size / 2 + 1;
sqr_lut = g_new (gint, lut_size);
for (i = 0; i < lut_size; i++)
sqr_lut[i] = SQR (i);
}
/* Get the map drawables, if applicable */
if (ovals.use_mask_size_map && ovals.mask_size_map >= 0)
{
use_msmap = TRUE;
mask_size_map_drawable = gimp_drawable_get (ovals.mask_size_map);
gimp_pixel_rgn_init (&mask_size_map_rgn, mask_size_map_drawable,
x1, y1, width, height, FALSE, FALSE);
msmap_bpp = mask_size_map_drawable->bpp;
}
if (ovals.use_exponent_map && ovals.exponent_map >= 0)
{
use_emap = TRUE;
exponent_map_drawable = gimp_drawable_get (ovals.exponent_map);
gimp_pixel_rgn_init (&exponent_map_rgn, exponent_map_drawable,
x1, y1, width, height, FALSE, FALSE);
emap_bpp = exponent_map_drawable->bpp;
}
gimp_pixel_rgn_init (&dest_rgn, drawable,
x1, y1, width, height, (preview == NULL), TRUE);
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 23:27:05 +08:00
{
GimpPixelRgn src_rgn;
gimp_pixel_rgn_init (&src_rgn, drawable,
x1, y1, width, height, FALSE, FALSE);
src_buf = g_new (guchar, width * height * bpp);
gimp_pixel_rgn_get_rect (&src_rgn, src_buf, x1, y1, width, height);
}
/*
* If we're working in intensity mode, then generate a separate intensity
* map of the source image. This way, we can avoid calculating the
* intensity of any given source pixel more than once.
*/
if (use_inten)
{
guchar *src;
guchar *dest;
src_inten_buf = g_new (guchar, width * height);
for (i = 0,
src = src_buf,
dest = src_inten_buf
;
i < (width * height)
;
i++,
src += bpp,
dest++)
{
*dest = (guchar) GIMP_RGB_LUMINANCE (src[0], src[1], src[2]);
}
}
n_regions = 0;
regions[n_regions++] = &dest_rgn;
if (use_msmap)
regions[n_regions++] = &mask_size_map_rgn;
if (use_emap)
regions[n_regions++] = &exponent_map_rgn;
for (pr = gimp_pixel_rgns_register2 (n_regions, regions);
pr != NULL;
pr = gimp_pixel_rgns_process (pr))
{
gint y;
guchar *dest_row;
guchar *src_msmap_row = NULL;
guchar *src_emap_row = NULL;
for (y = dest_rgn.y,
dest_row = dest_rgn.data,
src_msmap_row = mask_size_map_rgn.data, /* valid iff use_msmap */
src_emap_row = exponent_map_rgn.data /* valid iff use_emap */
;
y < (gint) (dest_rgn.y + dest_rgn.h)
;
y++,
dest_row += dest_rgn.rowstride,
src_msmap_row += mask_size_map_rgn.rowstride, /* valid iff use_msmap */
src_emap_row += exponent_map_rgn.rowstride) /* valid iff use_emap */
{
gint x;
guchar *dest;
guchar *src_msmap = NULL;
guchar *src_emap = NULL;
for (x = dest_rgn.x,
dest = dest_row,
src_msmap = src_msmap_row, /* valid iff use_msmap */
src_emap = src_emap_row /* valid iff use_emap */
;
x < (gint) (dest_rgn.x + dest_rgn.w)
;
x++,
dest += bpp,
src_msmap += msmap_bpp, /* valid iff use_msmap */
src_emap += emap_bpp) /* valid iff use_emap */
{
gint radius, radius_squared;
gfloat exponent;
gint mask_x1, mask_y1;
gint mask_x2, mask_y2;
gint mask_y;
gint src_offset;
guchar *src_row;
guchar *src_inten_row = NULL;
if (use_msmap)
{
gfloat factor = get_map_value (src_msmap, msmap_bpp);
radius = ROUND (factor * (0.5 * ovals.mask_size));
}
else
{
radius = (gint) ovals.mask_size / 2;
}
radius_squared = SQR (radius);
exponent = ovals.exponent;
if (use_emap)
exponent *= get_map_value (src_emap, emap_bpp);
if (use_inten)
memset (Hist, 0, sizeof (Hist));
memset (Hist_rgb, 0, sizeof (Hist_rgb));
mask_x1 = CLAMP ((x - radius), x1, x2);
mask_y1 = CLAMP ((y - radius), y1, y2);
mask_x2 = CLAMP ((x + radius + 1), x1, x2);
mask_y2 = CLAMP ((y + radius + 1), y1, y2);
src_offset = (mask_y1 - y1) * width + (mask_x1 - x1);
for (mask_y = mask_y1,
src_row = src_buf + src_offset * bpp,
src_inten_row = src_inten_buf + src_offset /* valid iff use_inten */
;
mask_y < mask_y2
;
mask_y++,
src_row += width * bpp,
src_inten_row += width) /* valid iff use_inten */
{
guchar *src;
guchar *src_inten = NULL;
gint dy_squared = sqr_lut[ABS (mask_y - y)];
gint mask_x;
for (mask_x = mask_x1,
src = src_row,
src_inten = src_inten_row /* valid iff use_inten */
;
mask_x < mask_x2
;
mask_x++,
src += bpp,
src_inten++) /* valid iff use_inten */
{
gint dx_squared = sqr_lut[ABS (mask_x - x)];
gint b;
/* Stay inside a circular mask area */
if ((dx_squared + dy_squared) > radius_squared)
continue;
if (use_inten)
{
gint inten = *src_inten;
++Hist[inten];
for (b = 0; b < bpp; b++)
Hist_rgb[b][inten] += src[b];
}
else
{
for (b = 0; b < bpp; b++)
++Hist_rgb[b][src[b]];
}
} /* for mask_x */
} /* for mask_y */
if (use_inten)
{
weighted_average_color (Hist, Hist_rgb, exponent, dest, bpp);
}
else
{
gint b;
for (b = 0; b < bpp; b++)
dest[b] = weighted_average_value (Hist_rgb[b], exponent);
}
} /* for x */
} /* for y */
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 23:27:05 +08:00
if (preview)
{
gimp_drawable_preview_draw_region (GIMP_DRAWABLE_PREVIEW (preview),
&dest_rgn);
}
else
{
progress += dest_rgn.w * dest_rgn.h;
gimp_progress_update ((gdouble) progress / (gdouble) max_progress);
}
} /* for pr */
/* Detach from the map drawables */
if (mask_size_map_drawable)
gimp_drawable_detach (mask_size_map_drawable);
if (exponent_map_drawable)
gimp_drawable_detach (exponent_map_drawable);
if (src_inten_buf)
g_free (src_inten_buf);
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 23:27:05 +08:00
g_free (src_buf);
g_free (sqr_lut);
if (!preview)
{
gimp_progress_update (1.0);
/* Update the oil-painted region */
gimp_drawable_flush (drawable);
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
gimp_drawable_update (drawable->drawable_id, x1, y1, width, height);
}
}
/*
* Return TRUE iff the specified drawable can be used as a mask-size /
* exponent map with the source image. The map and the image must have the
* same dimensions.
*/
static gboolean
oilify_map_constrain (gint32 image_id G_GNUC_UNUSED,
gint32 drawable_id,
gpointer data)
{
GimpDrawable *drawable = data;
return (gimp_drawable_width (drawable_id) == (gint) drawable->width &&
gimp_drawable_height (drawable_id) == (gint) drawable->height);
}
1997-11-25 06:05:25 +08:00
static gint
oilify_dialog (GimpDrawable *drawable)
1997-11-25 06:05:25 +08:00
{
GtkWidget *dialog;
GtkWidget *main_vbox;
GtkWidget *preview;
1997-11-25 06:05:25 +08:00
GtkWidget *table;
GtkWidget *toggle;
GtkWidget *combo;
2000-01-15 01:15:54 +08:00
GtkObject *adj;
gboolean can_use_mode_inten;
gboolean ret;
1997-11-25 06:05:25 +08:00
can_use_mode_inten = gimp_drawable_is_rgb (drawable->drawable_id);
1997-11-25 06:05:25 +08:00
if (! can_use_mode_inten && ovals.mode == MODE_INTEN)
ovals.mode = MODE_RGB;
gimp_ui_init (PLUG_IN_BINARY, FALSE);
dialog = gimp_dialog_new (_("Oilify"), PLUG_IN_ROLE,
NULL, 0,
gimp_standard_help_func, PLUG_IN_PROC,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
Added parent window API to the GimpProgress interface and to the libgimp 2005-09-09 Michael Natterer <mitch@gimp.org> Added parent window API to the GimpProgress interface and to the libgimp progress stuff. Might look strange, but does the right thing in almost all cases (image window, file dialog, script-fu dialog etc). Fixes bug #62988. * app/core/gimpprogress.[ch]: added GimpProgress::get_window() which should return a toplevel window ID if the progress is in a window that wants to be the transient parent of plug-in dialogs. * app/widgets/gimpwidgets-utils.[ch] (gimp_window_get_native): new function which returns the window handle of a GtkWindow's GdkWindow. * app/widgets/gimpfiledialog.c: implement ::get_window(). * app/display/gimpdisplay.[ch]: ditto. Removed window handle API. * app/gui/gui-vtable.c: changed accordingly. * libgimpbase/gimpbaseenums.[ch] (enum GimpProgressCommand): added GIMP_PROGRESS_COMMAND_GET_WINDOW. * app/plug-in/plug-in-progress.[ch] (plug_in_progress_get_window): new function. Also renamed some functions to match the GimpProgress interface, and not the legacy PDB procedure names. * tools/pdbgen/pdb/progress.pdb * app/core/gimppdbprogress.c: implement get_window() on both sides of the wire, keeping backward compatibility (hopefully). * libgimp/gimpprogress.[ch]: deprecated gimp_progress_install() and added gimp_progress_install_vtable() which takes a vtable with padding to be extensible. Added get_window() vtable entry and dispatch it accordingly. Also added pulse() which was implemented in a hackish way before. Everything is of course backward compatible. * libgimp/gimpprogressbar.c: inmplement the get_window() stuff so a plug-in dialog containing a progress can be the transient parent of another dialog in another plug-in. * libgimp/gimpui.[ch] (gimp_ui_get_progress_window): new function which returns a foreign GdkWindow of this plug-ins progress window. Renamed gimp_window_set_transient_for_default_display() to gimp_window_set_transient() and make it use the progress' window handle instead of the display's (which is the right thing to do in almost all cases). * libgimp/gimp.def * libgimp/gimpui.def: add the new functions. * tools/pdbgen/enums.pl * app/pdb/internal_procs.c * app/pdb/progress_cmds.c * libgimp/gimpprogress_pdb.[ch]: regenerated. * libgimp/gimpexport.c * plug-ins/*/*.c: follow API change.
2005-09-10 02:07:31 +08:00
gimp_window_set_transient (GTK_WINDOW (dialog));
2011-09-30 18:17:53 +08:00
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
main_vbox, TRUE, TRUE, 0);
gtk_widget_show (main_vbox);
preview = gimp_drawable_preview_new (drawable, NULL);
gtk_box_pack_start (GTK_BOX (main_vbox), preview, TRUE, TRUE, 0);
gtk_widget_show (preview);
g_signal_connect_swapped (preview, "invalidated",
G_CALLBACK (oilify), drawable);
table = gtk_table_new (7, 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);
gtk_widget_show (table);
1997-11-25 06:05:25 +08:00
/*
* Mask-size scale
*/
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
_("_Mask size:"), SCALE_WIDTH, 0,
ovals.mask_size, 3.0, 50.0, 1.0, 5.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
g_signal_connect (adj, "value-changed",
G_CALLBACK (gimp_double_adjustment_update),
&ovals.mask_size);
g_signal_connect_swapped (adj, "value-changed",
G_CALLBACK (gimp_preview_invalidate),
preview);
1997-11-25 06:05:25 +08:00
/*
* Mask-size map check button
*/
toggle = gtk_check_button_new_with_mnemonic (_("Use m_ask-size map:"));
gtk_table_attach (GTK_TABLE (table), toggle, 0, 3, 1, 2, GTK_FILL, 0, 0, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
ovals.use_mask_size_map);
gtk_widget_show (toggle);
g_signal_connect (toggle, "toggled",
G_CALLBACK (gimp_toggle_button_update),
&ovals.use_mask_size_map);
g_signal_connect_swapped (toggle, "toggled",
G_CALLBACK (gimp_preview_invalidate),
preview);
/*
* Mask-size map combo
*/
combo = gimp_drawable_combo_box_new (oilify_map_constrain, drawable);
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), ovals.mask_size_map,
G_CALLBACK (gimp_int_combo_box_get_active),
&ovals.mask_size_map);
g_signal_connect_swapped (combo, "changed",
G_CALLBACK (gimp_preview_invalidate),
preview);
gtk_table_attach (GTK_TABLE (table), combo, 0, 3, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_show (combo);
g_object_bind_property (toggle, "active",
combo, "sensitive",
G_BINDING_SYNC_CREATE);
/*
* Exponent scale
*/
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 3,
_("_Exponent:"), SCALE_WIDTH, 0,
ovals.exponent, 1.0, 20.0, 1.0, 4.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
g_signal_connect (adj, "value-changed",
G_CALLBACK (gimp_double_adjustment_update),
&ovals.exponent);
g_signal_connect_swapped (adj, "value-changed",
G_CALLBACK (gimp_preview_invalidate),
preview);
/*
* Exponent map check button
*/
toggle = gtk_check_button_new_with_mnemonic (_("Use e_xponent map:"));
gtk_table_attach (GTK_TABLE (table), toggle, 0, 3, 4, 5, GTK_FILL, 0, 0, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
ovals.use_exponent_map);
gtk_widget_show (toggle);
g_signal_connect (toggle, "toggled",
G_CALLBACK (gimp_toggle_button_update),
&ovals.use_exponent_map);
g_signal_connect_swapped (toggle, "toggled",
G_CALLBACK (gimp_preview_invalidate),
preview);
/*
* Exponent map combo
*/
combo = gimp_drawable_combo_box_new (oilify_map_constrain, drawable);
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), ovals.exponent_map,
G_CALLBACK (gimp_int_combo_box_get_active),
&ovals.exponent_map);
g_signal_connect_swapped (combo, "changed",
G_CALLBACK (gimp_preview_invalidate),
preview);
gtk_table_attach (GTK_TABLE (table), combo, 0, 3, 5, 6,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_show (combo);
g_object_bind_property (toggle, "active",
combo, "sensitive",
G_BINDING_SYNC_CREATE);
/*
* Intensity algorithm check button
*/
toggle = gtk_check_button_new_with_mnemonic (_("_Use intensity algorithm"));
gtk_table_attach (GTK_TABLE (table), toggle, 0, 3, 6, 7, GTK_FILL, 0, 0, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), ovals.mode);
gtk_widget_set_sensitive (toggle, can_use_mode_inten);
gtk_widget_show (toggle);
g_signal_connect (toggle, "toggled",
G_CALLBACK (gimp_toggle_button_update),
&ovals.mode);
g_signal_connect_swapped (toggle, "toggled",
G_CALLBACK (gimp_preview_invalidate),
preview);
gtk_widget_show (dialog);
1997-11-25 06:05:25 +08:00
ret = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
1997-11-25 06:05:25 +08:00
gtk_widget_destroy (dialog);
1997-11-25 06:05:25 +08:00
return ret;
}