gimp/plug-ins/common/whirl-pinch.c

674 lines
20 KiB
C
Raw Normal View History

/* GIMP - The GNU Image Manipulation Program
1997-11-25 06:05:25 +08:00
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Whirl and Pinch plug-in --- two common distortions in one place
* Copyright (C) 1997 Federico Mena Quintero
* federico@nuclecu.unam.mx
* Copyright (C) 1997 Scott Goehring
* scott@poverty.bloomington.in.us
*
* 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
*/
/* Version 2.09:
*
* - Another cool patch from Scott. The radius is now in [0.0, 2.0],
* with 1.0 being the default as usual. In addition to a minimal
* speed-up (one multiplication is eliminated in the calculation
* code), it is easier to think of nice round values instead of
* sqrt(2) :-)
*
* - Modified the way out-of-range pixels are handled. This time the
* plug-in handles `outside' pixels better; it paints them with the
* current background color (for images without transparency) or with
* a completely transparent background color (for images with
* transparency).
*/
/* Version 2.08:
*
* This is the first version of this plug-in. It is called 2.08
* because it came out of merging the old Whirl 2.08 and Pinch 2.08
* plug-ins. */
New file. * plug-ins/makefile.msc: New file. * plug-ins/*/*.c (Well, not really all files, but many): Portability fixes. Include config.h, and guard inclusion of POSIX and Unix headers like <unistd.h>, <dirent.h> and <sys/time.h>. Include <string.h> if functions from it are used. Use g_ntohl() and g_htonl() insteead of ntohl() and htonl(), thus no need to include <netinet/in.h>. Include <io.h> on Win32 when using open/read/write (which actually are defined as _open/_read/_write by glib.h). Define S_* macros if necessary on Win32. Define rint() and M_PI if necessary (these definitions should be factored out somewhere, no sense repeating them in lots of files). Open files in binary mode when needed. * plug-ins/FractalExplorer/FractalExplorer.c: Use g_malloc()/g_free(). Use g_strdup_printf(). * plug-ins/dbbrowser/dbbrowser.c: No need to include <X11/Xlib.h>. * plug-ins/destripe/destripe.c: Guard use of SIGBUS. * plug-ins/{flame/flame,hrz/hrz,pnm/pnm}.c: No need to check for NULL returns from g_malloc() and g_new() as they abort on failure. Use g_strdup_printf(). * plug-ins/gz/gz.c: Win32 version of running the subprocess. * plug-ins/hrz/hrz.c: Win32 version. Use more generic tests for non-Unix (OS/2 and Win32), for instance HAVE_MMAP. * plug-ins/script-fu/interp_slib.c: Win32 version of myruntime(). * plug-ins/script-fu/interp_sliba.c: Handle \\ (escaped backslahsh). * plug-ins/script-fu/script-fu-console.c: Bypass on Win32. * plug-ins/script-fu/script-fu-scripts.c: Portability fixes. Use g_strdup_printf() instead of separate malloc() and sprintf(). Use g_strescape() for strings being passed to Scheme. Some Win32-only stuff.
1999-05-29 09:28:24 +08:00
#include "config.h"
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "libgimp/stdplugins-intl.h"
1997-11-25 06:05:25 +08:00
#define PLUG_IN_PROC "plug-in-whirl-pinch"
Renamed tons of plug-ins to make more sense and to be consistent: 2008-03-24 Michael Natterer <mitch@gimp.org> Renamed tons of plug-ins to make more sense and to be consistent: * plug-ins/common/AlienMap2.c -> alien-map.c * plug-ins/common/CEL.c -> cel.c * plug-ins/common/CML_explorer.c -> cml-explorer.c * plug-ins/common/align_layers.c -> align-layers.c * plug-ins/common/animationplay.c -> animation-play.c * plug-ins/common/animoptimize.c -> animation-optimize.c * plug-ins/common/apply_lens.c -> lens-apply.c * plug-ins/common/autocrop.c -> crop-auto.c * plug-ins/common/autostretch_hsv.c -> contrast-stretch-hsv.c * plug-ins/common/borderaverage.c -> border-average.c * plug-ins/common/bumpmap.c -> bump-map.c * plug-ins/common/c_astretch.c -> contrast-stretch.c * plug-ins/common/ccanalyze.c -> color-cube-analyze.c * plug-ins/common/channel_mixer.c -> channel-mixer.c * plug-ins/common/color_enhance.c -> color-enhance.c * plug-ins/common/colortoalpha.c -> color-to-alpha.c * plug-ins/common/convmatrix.c -> convolution-matrix.c * plug-ins/common/curve_bend.c -> curve-bend.c * plug-ins/common/depthmerge.c -> depth-merge.c * plug-ins/common/dog.c -> edge-dog.c * plug-ins/common/exchange.c -> color-exchange.c * plug-ins/common/flarefx.c -> lens-flare.c * plug-ins/common/fp.c -> filter-pack.c * plug-ins/common/fractaltrace.c -> fractal-trace.c * plug-ins/common/gauss.c -> blur-gauss.c * plug-ins/common/gee_zoom.c -> gee-zoom.c * plug-ins/common/glasstile.c -> tile-glass.c * plug-ins/common/gqbist.c -> qbist.c * plug-ins/common/gradmap.c -> gradient-map.c * plug-ins/common/laplace.c -> edge-laplace.c * plug-ins/common/lens.c -> lens-distortion.c * plug-ins/common/lic.c -> van-gogh-lic.c * plug-ins/common/max_rgb.c -> max-rgb.c * plug-ins/common/mblur.c -> blur-motion.c * plug-ins/common/nlfilt.c -> nl-filter.c * plug-ins/common/noisify.c -> noise-rgb.c * plug-ins/common/normalize.c -> contrast-normalize.c * plug-ins/common/papertile.c -> tile-paper.c * plug-ins/common/polar.c -> polar-coords.c * plug-ins/common/randomize.c -> noise-randomize.c * plug-ins/common/redeye.c -> red-eye-removal.c * plug-ins/common/retinex.c -> contrast-retinex.c * plug-ins/common/sample_colorize.c -> sample-colorize.c * plug-ins/common/scatter_hsv.c -> noise-hsv.c * plug-ins/common/sel_gauss.c -> blur-gauss-selective.c * plug-ins/common/semiflatten.c -> semi-flatten.c * plug-ins/common/smooth_palette.c -> smooth-palette.c * plug-ins/common/snoise.c -> noise-solid.c * plug-ins/common/sobel.c -> edge-sobel.c * plug-ins/common/spheredesigner.c -> sphere-designer.c * plug-ins/common/spread.c -> noise-spread.c * plug-ins/common/struc.c -> apply-canvas.c * plug-ins/common/threshold_alpha.c -> threshold-alpha.c * plug-ins/common/tileit.c -> tile-small.c * plug-ins/common/tiler.c -> tile-seamless.c * plug-ins/common/uniteditor.c -> unit-editor.c * plug-ins/common/unsharp.c -> unsharp-mask.c * plug-ins/common/vinvert.c -> value-invert.c * plug-ins/common/vpropagate.c -> value-propagate.c * plug-ins/common/webbrowser.c -> web-browser.c * plug-ins/common/whirlpinch.c -> whirl-pinch.c * plug-ins/common/zealouscrop.c -> crop-zealous.c * plug-ins/common/plugin-defs.pl: changed accordingly. * plug-ins/common/Makefile.am: regenerated. svn path=/trunk/; revision=25192
2008-03-24 23:29:55 +08:00
#define PLUG_IN_BINARY "whirl-pinch"
1997-11-25 06:05:25 +08:00
#define PLUG_IN_VERSION "May 1997, 2.09"
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc 1999-09-01 Tor Lillqvist <tml@iki.fi> * app/appenv.h * libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc from app/appenv.h here, so plug-ins can use them, too. Remove some commented-out old stuff in appenv.h. * libgimp/gimp.h: Include gimpmath.h. * libgimp/gimp.c (gimp_main): Win32: Don't install signal handlers, we can't do anything useful in the handler ourselves anyway (it would be nice to print out a backtrace, but that seems pretty hard to do, even if not impossible). Let Windows inform the user about the crash. If the plug-in was compiled with MSVC, and the user also has it, she is offered a chance to start the debugger automatically anyway. * app/*several*.c: Include gimpmath.h for G_PI etc. Don't include <math.h>, as gimpmath.h includes it. * plug-ins/*/*many*.c: Include config.h. Don't include <math.h>. Remove all the duplicated definitions of G_PI and rint(). Use RINT() instead of rint(). * app/app_procs.[ch]: app_exit() takes a gboolean. * app/batch.c * app/commands.c * app/interface.c: Call app_exit() with FALSE or TRUE. * app/main.c (on_error): Call gimp_fatal_error. (main): Don't install any signal handler on Win32 here, either. * app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format the message and call MessageBox with it. g_on_error_query doesn't do anything useful on Win32, and printf'ing a message to stdout or stderr doesn't do anything, either, in a windowing application.
1999-09-02 04:30:56 +08:00
/***** Magic numbers *****/
1997-11-25 06:05:25 +08:00
#define SCALE_WIDTH 200
/***** Types *****/
typedef struct
{
gdouble whirl;
gdouble pinch;
gdouble radius;
1997-11-25 06:05:25 +08:00
} whirl_pinch_vals_t;
/***** Prototypes *****/
static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static void whirl_pinch (GimpDrawable *drawable);
static int calc_undistorted_coords (double wx,
double wy,
double whirl,
double pinch,
double *x,
double *y);
static gboolean whirl_pinch_dialog (GimpDrawable *drawable);
static void dialog_update_preview (GimpDrawable *drawable,
GimpPreview *preview);
1997-11-25 06:05:25 +08:00
/***** Variables *****/
const GimpPlugInInfo PLUG_IN_INFO =
{
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run /* run_proc */
};
static whirl_pinch_vals_t wpvals =
{
90.0, /* whirl */
0.0, /* pinch */
1.0 /* radius */
};
1997-11-25 06:05:25 +08:00
static gint img_bpp, img_has_alpha;
1997-11-25 06:05:25 +08:00
static gint sel_x1, sel_y1, sel_x2, sel_y2;
static gint sel_width, sel_height;
static double cen_x, cen_y;
static double scale_x, scale_y;
static double radius, radius2;
/***** Functions *****/
MAIN()
static void
query (void)
1997-11-25 06:05:25 +08:00
{
static const GimpParamDef args[] =
{
{ GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
{ GIMP_PDB_IMAGE, "image", "Input image" },
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
{ GIMP_PDB_FLOAT, "whirl", "Whirl angle (degrees)" },
{ GIMP_PDB_FLOAT, "pinch", "Pinch amount" },
{ GIMP_PDB_FLOAT, "radius", "Radius (1.0 is the largest circle that fits in the image, and 2.0 goes all the way to the corners)" }
};
gimp_install_procedure (PLUG_IN_PROC,
N_("Distort an image by whirling and pinching"),
"Distorts the image by whirling and pinching, which "
"are two common center-based, circular distortions. "
"Whirling is like projecting the image onto the "
"surface of water in a toilet and flushing. "
"Pinching is similar to projecting the image onto "
"an elastic surface and pressing or pulling on the "
"center of the surface.",
"Federico Mena Quintero and Scott Goehring",
"Federico Mena Quintero and Scott Goehring",
PLUG_IN_VERSION,
N_("W_hirl and Pinch..."),
"RGB*, GRAY*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Filters/Distorts");
}
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];
GimpRunMode run_mode;
GimpPDBStatusType status;
double xhsiz, yhsiz;
GimpDrawable *drawable;
status = GIMP_PDB_SUCCESS;
run_mode = param[0].data.d_int32;
INIT_I18N ();
*nreturn_vals = 1;
*return_vals = values;
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = status;
/* Get the active drawable info */
drawable = gimp_drawable_get (param[2].data.d_drawable);
img_bpp = gimp_drawable_bpp (drawable->drawable_id);
img_has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
if (! gimp_drawable_mask_intersect (drawable->drawable_id,
&sel_x1, &sel_y1,
&sel_width, &sel_height))
{
g_message (_("Region affected by plug-in is empty"));
return;
}
/* Set the tile cache size */
gimp_tile_cache_ntiles (2 * drawable->ntile_cols);
/* Calculate scaling parameters */
sel_x2 = sel_x1 + sel_width;
sel_y2 = sel_y1 + sel_height;
cen_x = (double) (sel_x1 + sel_x2 - 1) / 2.0;
cen_y = (double) (sel_y1 + sel_y2 - 1) / 2.0;
xhsiz = (double) (sel_width - 1) / 2.0;
yhsiz = (double) (sel_height - 1) / 2.0;
if (xhsiz < yhsiz)
{
scale_x = yhsiz / xhsiz;
scale_y = 1.0;
}
else if (xhsiz > yhsiz)
{
scale_x = 1.0;
scale_y = xhsiz / yhsiz;
}
else
{
scale_x = 1.0;
scale_y = 1.0;
}
radius = MAX(xhsiz, yhsiz);
/* See how we will run */
switch (run_mode)
{
case GIMP_RUN_INTERACTIVE:
/* Possibly retrieve data */
gimp_get_data (PLUG_IN_PROC, &wpvals);
/* Get information from the dialog */
if (!whirl_pinch_dialog (drawable))
return;
break;
case GIMP_RUN_NONINTERACTIVE:
/* Make sure all the arguments are present */
if (nparams != 6)
{
status = GIMP_PDB_CALLING_ERROR;
}
else
{
wpvals.whirl = param[3].data.d_float;
wpvals.pinch = param[4].data.d_float;
wpvals.radius = param[5].data.d_float;
}
break;
case GIMP_RUN_WITH_LAST_VALS:
/* Possibly retrieve data */
gimp_get_data (PLUG_IN_PROC, &wpvals);
break;
default:
break;
}
/* Distort the image */
if ((status == GIMP_PDB_SUCCESS) &&
(gimp_drawable_is_rgb (drawable->drawable_id) ||
gimp_drawable_is_gray (drawable->drawable_id)))
{
/* Run! */
whirl_pinch (drawable);
/* If run mode is interactive, flush displays */
if (run_mode != GIMP_RUN_NONINTERACTIVE)
gimp_displays_flush ();
/* Store data */
if (run_mode == GIMP_RUN_INTERACTIVE)
gimp_set_data (PLUG_IN_PROC, &wpvals, sizeof (whirl_pinch_vals_t));
}
else if (status == GIMP_PDB_SUCCESS)
status = GIMP_PDB_EXECUTION_ERROR;
values[0].data.d_status = status;
gimp_drawable_detach (drawable);
}
1997-11-25 06:05:25 +08:00
static void
whirl_pinch (GimpDrawable *drawable)
1997-11-25 06:05:25 +08:00
{
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
GimpPixelRgn dest_rgn;
gint progress, max_progress;
guchar *top_row, *bot_row;
guchar *top_p, *bot_p;
gint row, col;
guchar **pixel;
gdouble whirl;
gdouble cx, cy;
gint ix, iy;
gint i;
GimpPixelFetcher *pft, *pfb;
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
GimpRGB background;
/* Initialize rows */
top_row = g_new (guchar, img_bpp * sel_width);
bot_row = g_new (guchar, img_bpp * sel_width);
pixel = g_new (guchar *, 4);
for (i = 0; i < 4; i++)
pixel[i] = g_new (guchar, 4);
/* Initialize pixel region */
gimp_pixel_rgn_init (&dest_rgn, drawable,
sel_x1, sel_y1, sel_width, sel_height, TRUE, TRUE);
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
pft = gimp_pixel_fetcher_new (drawable, FALSE);
pfb = gimp_pixel_fetcher_new (drawable, FALSE);
tools/pdbgen/Makefile.am tools/pdbgen/groups.pl removed the "Palette" pdb 2004-09-22 Michael Natterer <mitch@gimp.org> * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/palette.pdb: removed the "Palette" pdb group... * tools/pdbgen/pdb/context.pdb: and added its functions to the "Context" namespace instead. * app/pdb/Makefile.am * app/pdb/palette_cmds.c: removed. * app/pdb/procedural_db.c: added them to the pdb_compat hash table. * libgimp/Makefile.am * libgimp/gimppalette_pdb.[ch]: removed. * libgimp/gimppalette.[ch]: new files holding compat functions which call gimp_context_*() functions. * libgimp/gimp.h * libgimp/gimpui.c: changed accordingly. * app/pdb/context_cmds.c * app/pdb/internal_procs.c * libgimp/gimp_pdb.h * libgimp/gimpcontext_pdb.[ch]: regenerated. * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_preview.c * plug-ins/common/apply_lens.c * plug-ins/common/blinds.c * plug-ins/common/borderaverage.c * plug-ins/common/checkerboard.c * plug-ins/common/colortoalpha.c * plug-ins/common/cubism.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/gif.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/mblur.c * plug-ins/common/mng.c * plug-ins/common/mosaic.c * plug-ins/common/papertile.c * plug-ins/common/png.c * plug-ins/common/polar.c * plug-ins/common/semiflatten.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/vpropagate.c * plug-ins/common/warp.c * plug-ins/common/whirlpinch.c * plug-ins/gfig/gfig-style.c * plug-ins/gfli/gfli.c * plug-ins/ifscompose/ifscompose.c * plug-ins/maze/handy.c * plug-ins/pagecurl/pagecurl.c * plug-ins/pygimp/gimpmodule.c * plug-ins/script-fu/scripts/*.scm: changed accordingly.
2004-09-23 02:43:09 +08:00
gimp_context_get_background (&background);
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
gimp_pixel_fetcher_set_bg_color (pft, &background);
gimp_pixel_fetcher_set_bg_color (pfb, &background);
2004-04-03 05:32:44 +08:00
if (gimp_drawable_has_alpha (drawable->drawable_id))
{
gimp_pixel_fetcher_set_edge_mode (pft, GIMP_PIXEL_FETCHER_EDGE_BLACK);
gimp_pixel_fetcher_set_edge_mode (pfb, GIMP_PIXEL_FETCHER_EDGE_BLACK);
}
else
{
gimp_pixel_fetcher_set_edge_mode (pft, GIMP_PIXEL_FETCHER_EDGE_BACKGROUND);
gimp_pixel_fetcher_set_edge_mode (pfb, GIMP_PIXEL_FETCHER_EDGE_BACKGROUND);
}
progress = 0;
max_progress = sel_width * sel_height;
gimp_progress_init (_("Whirling and pinching"));
whirl = wpvals.whirl * G_PI / 180;
radius2 = radius * radius * wpvals.radius;
for (row = sel_y1; row <= ((sel_y1 + sel_y2) / 2); row++)
{
top_p = top_row;
bot_p = bot_row + img_bpp * (sel_width - 1);
for (col = sel_x1; col < sel_x2; col++)
{
if (calc_undistorted_coords (col, row, whirl, wpvals.pinch, &cx, &cy))
{
/* We are inside the distortion area */
/* Top */
if (cx >= 0.0)
ix = (int) cx;
else
ix = -((int) -cx + 1);
if (cy >= 0.0)
iy = (int) cy;
else
iy = -((int) -cy + 1);
1997-11-25 06:05:25 +08:00
gimp_pixel_fetcher_get_pixel (pft, ix, iy, pixel[0]);
gimp_pixel_fetcher_get_pixel (pft, ix + 1, iy, pixel[1]);
gimp_pixel_fetcher_get_pixel (pft, ix, iy + 1, pixel[2]);
gimp_pixel_fetcher_get_pixel (pft, ix + 1, iy + 1, pixel[3]);
1997-11-25 06:05:25 +08:00
gimp_bilinear_pixels_8 (top_p, cx, cy, img_bpp, img_has_alpha,
pixel);
top_p += img_bpp;
/* Bottom */
1997-11-25 06:05:25 +08:00
cx = cen_x + (cen_x - cx);
cy = cen_y + (cen_y - cy);
1997-11-25 06:05:25 +08:00
if (cx >= 0.0)
ix = (int) cx;
else
ix = -((int) -cx + 1);
1997-11-25 06:05:25 +08:00
if (cy >= 0.0)
iy = (int) cy;
else
iy = -((int) -cy + 1);
1997-11-25 06:05:25 +08:00
gimp_pixel_fetcher_get_pixel (pfb, ix, iy, pixel[0]);
gimp_pixel_fetcher_get_pixel (pfb, ix + 1, iy, pixel[1]);
gimp_pixel_fetcher_get_pixel (pfb, ix, iy + 1, pixel[2]);
gimp_pixel_fetcher_get_pixel (pfb, ix + 1, iy + 1, pixel[3]);
1997-11-25 06:05:25 +08:00
gimp_bilinear_pixels_8 (bot_p, cx, cy, img_bpp, img_has_alpha,
pixel);
bot_p -= img_bpp;
}
else
{
/* We are outside the distortion area;
* just copy the source pixels
*/
1997-11-25 06:05:25 +08:00
/* Top */
1997-11-25 06:05:25 +08:00
gimp_pixel_fetcher_get_pixel (pft, col, row, pixel[0]);
1997-11-25 06:05:25 +08:00
for (i = 0; i < img_bpp; i++)
*top_p++ = pixel[0][i];
1997-11-25 06:05:25 +08:00
/* Bottom */
1997-11-25 06:05:25 +08:00
gimp_pixel_fetcher_get_pixel (pfb,
(sel_x2 - 1) - (col - sel_x1),
(sel_y2 - 1) - (row - sel_y1),
pixel[0]);
1997-11-25 06:05:25 +08:00
for (i = 0; i < img_bpp; i++)
*bot_p++ = pixel[0][i];
1997-11-25 06:05:25 +08:00
bot_p -= 2 * img_bpp; /* We move backwards! */
}
}
1997-11-25 06:05:25 +08:00
/* Paint rows to image */
1997-11-25 06:05:25 +08:00
gimp_pixel_rgn_set_row (&dest_rgn, top_row, sel_x1, row, sel_width);
gimp_pixel_rgn_set_row (&dest_rgn, bot_row,
sel_x1, (sel_y2 - 1) - (row - sel_y1), sel_width);
1997-11-25 06:05:25 +08:00
/* Update progress */
1997-11-25 06:05:25 +08:00
progress += sel_width * 2;
gimp_progress_update ((double) progress / max_progress);
}
1997-11-25 06:05:25 +08:00
gimp_pixel_fetcher_destroy (pft);
gimp_pixel_fetcher_destroy (pfb);
1997-11-25 06:05:25 +08:00
for (i = 0; i < 4; i++)
g_free (pixel[i]);
g_free (pixel);
g_free (top_row);
g_free (bot_row);
1997-11-25 06:05:25 +08:00
gimp_drawable_flush (drawable);
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
gimp_drawable_update (drawable->drawable_id,
sel_x1, sel_y1, sel_width, sel_height);
}
1997-11-25 06:05:25 +08:00
static gint
calc_undistorted_coords (gdouble wx,
gdouble wy,
gdouble whirl,
gdouble pinch,
gdouble *x,
gdouble *y)
1997-11-25 06:05:25 +08:00
{
gdouble dx, dy;
gdouble d, factor;
gdouble dist;
gdouble ang, sina, cosa;
gint inside;
1997-11-25 06:05:25 +08:00
/* Distances to center, scaled */
1997-11-25 06:05:25 +08:00
dx = (wx - cen_x) * scale_x;
dy = (wy - cen_y) * scale_y;
1997-11-25 06:05:25 +08:00
/* Distance^2 to center of *circle* (scaled ellipse) */
1997-11-25 06:05:25 +08:00
d = dx * dx + dy * dy;
1997-11-25 06:05:25 +08:00
/* If we are inside circle, then distort.
* Else, just return the same position
*/
1997-11-25 06:05:25 +08:00
inside = (d < radius2);
1997-11-25 06:05:25 +08:00
if (inside)
{
dist = sqrt(d / wpvals.radius) / radius;
1997-11-25 06:05:25 +08:00
/* Pinch */
1997-11-25 06:05:25 +08:00
factor = pow (sin (G_PI_2 * dist), -pinch);
1997-11-25 06:05:25 +08:00
dx *= factor;
dy *= factor;
1997-11-25 06:05:25 +08:00
/* Whirl */
1997-11-25 06:05:25 +08:00
factor = 1.0 - dist;
1997-11-25 06:05:25 +08:00
ang = whirl * factor * factor;
1997-11-25 06:05:25 +08:00
sina = sin (ang);
cosa = cos (ang);
1997-11-25 06:05:25 +08:00
*x = (cosa * dx - sina * dy) / scale_x + cen_x;
*y = (sina * dx + cosa * dy) / scale_y + cen_y;
}
else
{
*x = wx;
*y = wy;
}
1997-11-25 06:05:25 +08:00
return inside;
}
1997-11-25 06:05:25 +08:00
static gboolean
whirl_pinch_dialog (GimpDrawable *drawable)
{
GtkWidget *dialog;
GtkWidget *main_vbox;
GtkWidget *preview;
GtkWidget *table;
GtkObject *adj;
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
gboolean run;
1997-11-25 06:05:25 +08:00
gimp_ui_init (PLUG_IN_BINARY, TRUE);
1997-11-25 06:05:25 +08:00
dialog = gimp_dialog_new (_("Whirl and Pinch"), PLUG_IN_BINARY,
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
NULL, 0,
gimp_standard_help_func, PLUG_IN_PROC,
1997-11-25 06:05:25 +08:00
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
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
1997-11-25 06:05:25 +08:00
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
NULL);
1997-11-25 06:05:25 +08:00
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));
main_vbox = gtk_vbox_new (FALSE, 12);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
main_vbox);
gtk_widget_show (main_vbox);
preview = gimp_zoom_preview_new (drawable);
gtk_box_pack_start (GTK_BOX (main_vbox), preview, TRUE, TRUE, 0);
gtk_widget_show (preview);
g_signal_connect_swapped (preview, "invalidated",
G_CALLBACK (dialog_update_preview),
drawable);
1997-11-25 06:05:25 +08:00
/* Controls */
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);
gtk_widget_show (table);
1997-11-25 06:05:25 +08:00
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
_("_Whirl angle:"), SCALE_WIDTH, 7,
wpvals.whirl, -720.0, 720.0, 1.0, 15.0, 2,
FALSE, -3600.0, 3600.0,
NULL, NULL);
g_signal_connect (adj, "value-changed",
G_CALLBACK (gimp_double_adjustment_update),
&wpvals.whirl);
g_signal_connect_swapped (adj, "value-changed",
G_CALLBACK (gimp_preview_invalidate),
preview);
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
_("_Pinch amount:"), SCALE_WIDTH, 7,
wpvals.pinch, -1.0, 1.0, 0.01, 0.1, 3,
TRUE, 0, 0,
NULL, NULL);
g_signal_connect (adj, "value-changed",
G_CALLBACK (gimp_double_adjustment_update),
&wpvals.pinch);
g_signal_connect_swapped (adj, "value-changed",
G_CALLBACK (gimp_preview_invalidate),
preview);
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 2,
_("_Radius:"), SCALE_WIDTH, 7,
wpvals.radius, 0.0, 2.0, 0.01, 0.1, 3,
TRUE, 0, 0,
NULL, NULL);
g_signal_connect (adj, "value-changed",
G_CALLBACK (gimp_double_adjustment_update),
&wpvals.radius);
g_signal_connect_swapped (adj, "value-changed",
G_CALLBACK (gimp_preview_invalidate),
preview);
1997-11-25 06:05:25 +08:00
/* Done */
1997-11-25 06:05:25 +08:00
gtk_widget_show (dialog);
1997-11-25 06:05:25 +08:00
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
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
gtk_widget_destroy (dialog);
1997-11-25 06:05:25 +08:00
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
return run;
}
1997-11-25 06:05:25 +08:00
static void
dialog_update_preview (GimpDrawable *drawable,
GimpPreview *preview)
1997-11-25 06:05:25 +08:00
{
gdouble cx, cy;
gint x, y;
gint sx, sy;
gint width, height;
guchar *pixel;
GimpRGB background;
guchar *dest;
gint j;
gint bpp;
GimpPixelFetcher *pft;
guchar in_pixels[4][4];
guchar *in_values[4];
gdouble whirl;
1997-11-25 06:05:25 +08:00
whirl = wpvals.whirl * G_PI / 180.0;
radius2 = radius * radius * wpvals.radius;
1997-11-25 06:05:25 +08:00
for (j = 0; j < 4; j++)
in_values[j] = in_pixels[j];
pft = gimp_pixel_fetcher_new (drawable, FALSE);
gimp_context_get_background (&background);
gimp_rgb_set_alpha (&background, 0.0);
gimp_pixel_fetcher_set_bg_color (pft, &background);
gimp_pixel_fetcher_set_edge_mode (pft, GIMP_PIXEL_FETCHER_EDGE_SMEAR);
1997-11-25 06:05:25 +08:00
dest = gimp_zoom_preview_get_source (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bpp);
1997-11-25 06:05:25 +08:00
pixel = dest;
1997-11-25 06:05:25 +08:00
for (y = 0; y < height; y++)
{
for (x = 0; x < width; x++)
{
gimp_preview_untransform (preview, x, y, &sx, &sy);
calc_undistorted_coords ((gdouble)sx, (gdouble)sy,
whirl, wpvals.pinch,
&cx, &cy);
1997-11-25 06:05:25 +08:00
gimp_pixel_fetcher_get_pixel (pft, cx, cy, in_pixels[0]);
gimp_pixel_fetcher_get_pixel (pft, cx + 1, cy, in_pixels[1]);
gimp_pixel_fetcher_get_pixel (pft, cx, cy + 1, in_pixels[2]);
gimp_pixel_fetcher_get_pixel (pft, cx + 1, cy + 1, in_pixels[3]);
1997-11-25 06:05:25 +08:00
gimp_bilinear_pixels_8 (pixel, cx, cy, bpp,
img_has_alpha, in_values);
1997-11-25 06:05:25 +08:00
pixel += bpp;
}
}
1997-11-25 06:05:25 +08:00
gimp_pixel_fetcher_destroy (pft);
1997-11-25 06:05:25 +08:00
gimp_preview_draw_buffer (preview, dest, width * bpp);
g_free (dest);
}