1997-11-25 06:05:25 +08:00
|
|
|
/* Sparkle --- image filter plug-in for The Gimp image manipulation program
|
1999-09-04 07:14:44 +08:00
|
|
|
* Copyright (C) 1996 by John Beale; ported to Gimp by Michael J. Hammel;
|
2003-09-17 20:53:52 +08:00
|
|
|
*
|
1999-09-04 07:14:44 +08:00
|
|
|
* It has been optimized a little, bugfixed and modified by Martin Weber
|
2003-09-17 20:53:52 +08:00
|
|
|
* for additional functionality. Also bugfixed by Seth Burgess (9/17/03)
|
2003-09-17 13:21:08 +08:00
|
|
|
* to take rowstrides into account when selections are present (bug #50911).
|
|
|
|
* Attempted reformatting.
|
1997-11-25 06:05:25 +08:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (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, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*
|
|
|
|
* You can contact Michael at mjhammel@csn.net
|
2000-01-19 22:57:19 +08:00
|
|
|
* You can contact Martin at martweb@gmx.net
|
2003-09-17 13:21:08 +08:00
|
|
|
* You can contact Seth at sjburges@gimp.org
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2003-09-17 13:21:08 +08:00
|
|
|
* Sparkle 1.27 - simulate pixel bloom and diffraction effects
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
|
|
|
|
2000-01-08 23:23:28 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2000-02-07 23:49:54 +08:00
|
|
|
#include <string.h>
|
Include config.h, guard inclusion of <unistd.h>.
1999-09-14 Tor Lillqvist <tml@iki.fi>
* app/brush_select.c: Include config.h, guard inclusion of
<unistd.h>.
* app/gimpcontextpreview.c: Include config.h, <string.h> and
appenv.h.
* app/xinput_airbrush.c: Include config.h, <stdio.h>, appenv.h and
libgimp/gimpmath.h. Use G_PI.
* app/makefile.{cygwin,msc}: Updates.
* plug-ins/makefile.{cygwin,msc}: Add the unofficial sel_gauss
plug-in. Add new object files for FractalExplorer and
gimpressionist.
* plug-ins/common/iwarp.c (iwarp_deform): Combine two loops over
the same xi, yi area into one. Remove the then actually unused
deform_area_vectors array. Only one element of the array was used
for each x,yi loop.
* plug-ins/common/sparkle.c: Don't include <math.h>,
libgimp/gimpmath.h includes it. Use G_PI.
1999-09-15 05:20:04 +08:00
|
|
|
|
2000-01-08 23:23:28 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
|
|
|
|
2000-01-08 01:18:44 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-02 04:22:55 +08:00
|
|
|
|
2003-09-17 20:53:52 +08:00
|
|
|
#define SCALE_WIDTH 175
|
|
|
|
#define ENTRY_WIDTH 7
|
|
|
|
#define MAX_CHANNELS 4
|
|
|
|
#define PSV 2 /* point spread value */
|
|
|
|
#define EPSILON 0.001
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-09-17 20:53:52 +08:00
|
|
|
#define NATURAL 0
|
|
|
|
#define FOREGROUND 1
|
|
|
|
#define BACKGROUND 2
|
1999-09-04 07:14:44 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
2003-09-17 20:53:52 +08:00
|
|
|
gdouble lum_threshold;
|
|
|
|
gdouble flare_inten;
|
|
|
|
gdouble spike_len;
|
|
|
|
gdouble spike_pts;
|
|
|
|
gdouble spike_angle;
|
|
|
|
gdouble density;
|
|
|
|
gdouble opacity;
|
|
|
|
gdouble random_hue;
|
|
|
|
gdouble random_saturation;
|
|
|
|
gboolean preserve_luminosity;
|
|
|
|
gboolean inverse;
|
|
|
|
gboolean border;
|
|
|
|
gint colortype;
|
1997-11-25 06:05:25 +08:00
|
|
|
} SparkleVals;
|
|
|
|
|
|
|
|
|
|
|
|
/* Declare local functions.
|
|
|
|
*/
|
1999-09-04 07:14:44 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void query (void);
|
2003-07-02 21:00:16 +08:00
|
|
|
static void run (const gchar *name,
|
2003-09-17 20:53:52 +08:00
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals);
|
2000-01-16 23:38:38 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static gint sparkle_dialog (void);
|
2000-01-16 23:38:38 +08:00
|
|
|
|
2003-09-17 20:53:52 +08:00
|
|
|
static gint compute_luminosity (const guchar *pixel,
|
|
|
|
gboolean gray,
|
|
|
|
gboolean has_alpha);
|
2000-08-22 09:26:57 +08:00
|
|
|
static gint compute_lum_threshold (GimpDrawable *drawable,
|
2003-09-17 20:53:52 +08:00
|
|
|
gdouble percentile);
|
2000-08-22 09:26:57 +08:00
|
|
|
static void sparkle (GimpDrawable *drawable,
|
2003-09-17 20:53:52 +08:00
|
|
|
gint threshold);
|
2000-08-22 09:26:57 +08:00
|
|
|
static void fspike (GimpPixelRgn *src_rgn,
|
2003-09-17 20:53:52 +08:00
|
|
|
GimpPixelRgn *dest_rgn,
|
|
|
|
gint x1,
|
|
|
|
gint y1,
|
|
|
|
gint x2,
|
|
|
|
gint y2,
|
|
|
|
gint xr,
|
|
|
|
gint yr,
|
|
|
|
gint tile_width,
|
|
|
|
gint tile_height,
|
|
|
|
gdouble inten,
|
|
|
|
gdouble length,
|
|
|
|
gdouble angle,
|
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c
2002-11-20 Dave Neary <bolsh@gimp.org>
* configure.in
* app/core/gimpbrushpipe.c
* app/gui/about-dialog.c
* app/paint-funcs/paint-funcs-generic.h
* app/paint-funcs/paint-funcs.c
* libgimpmath/gimpmath.h
* libgimpwidgets/gimpwidgets.c
* plug-ins/common/CML_explorer.c
* plug-ins/common/blur.c
* plug-ins/common/cubism.c
* plug-ins/common/gee.c
* plug-ins/common/gee_zoom.c
* plug-ins/common/gqbist.c
* plug-ins/common/jigsaw.c
* plug-ins/common/lic.c
* plug-ins/common/noisify.c
* plug-ins/common/nova.c
* plug-ins/common/papertile.c
* plug-ins/common/plasma.c
* plug-ins/common/randomize.c
* plug-ins/common/sample_colorize.c
* plug-ins/common/scatter_hsv.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/sparkle.c
* plug-ins/common/spheredesigner.c
* plug-ins/common/spread.c
* plug-ins/common/warp.c
* plug-ins/common/wind.c
* plug-ins/flame/cmap.c
* plug-ins/flame/flame.c
* plug-ins/flame/libifs.c
* plug-ins/gflare/gflare.c
* plug-ins/gimpressionist/gimpressionist.c
* plug-ins/gimpressionist/gimpressionist.h
* plug-ins/gimpressionist/plasma.c
* plug-ins/gimpressionist/repaint.c
* plug-ins/ifscompose/ifscompose_utils.c
* plug-ins/maze/algorithms.c
* plug-ins/maze/maze.c
* plug-ins/maze/maze.h
* plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX,
G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(),
srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand*
equivalent. Programs which require seed setting for reproducible
results, and anything in the core, gets a dedicated GRand * for
the lifetime required. Programs which only ever used random
numbers for tossing a coin, rolling a dice, etc use g_random
functions. For the rest, judgement was used. Where it was easy, a
GRand * object was used and g_rand_* functions were
preferred. This fixes bug #67386 in HEAD.
2002-11-20 17:27:48 +08:00
|
|
|
GRand *gr);
|
2002-01-04 01:55:00 +08:00
|
|
|
static GimpTile * rpnt (GimpDrawable *drawable,
|
2003-09-17 20:53:52 +08:00
|
|
|
GimpTile *tile,
|
|
|
|
gint x1,
|
|
|
|
gint y1,
|
|
|
|
gint x2,
|
|
|
|
gint y2,
|
|
|
|
gdouble xr,
|
|
|
|
gdouble yr,
|
|
|
|
gint tile_width,
|
|
|
|
gint tile_height,
|
|
|
|
gint *row,
|
|
|
|
gint *col,
|
|
|
|
gint bytes,
|
|
|
|
gdouble inten,
|
|
|
|
guchar color[MAX_CHANNELS]);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
GimpPlugInInfo PLUG_IN_INFO =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-02-03 01:59:44 +08:00
|
|
|
NULL, /* init_proc */
|
|
|
|
NULL, /* quit_proc */
|
|
|
|
query, /* query_proc */
|
|
|
|
run, /* run_proc */
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static SparkleVals svals =
|
|
|
|
{
|
2000-02-03 01:59:44 +08:00
|
|
|
0.001, /* luminosity threshold */
|
2003-09-17 20:53:52 +08:00
|
|
|
0.5, /* flare intensity */
|
|
|
|
20.0, /* spike length */
|
|
|
|
4.0, /* spike points */
|
|
|
|
15.0, /* spike angle */
|
|
|
|
1.0, /* spike density */
|
|
|
|
0.0, /* opacity */
|
|
|
|
0.0, /* random hue */
|
|
|
|
0.0, /* random saturation */
|
|
|
|
FALSE, /* preserve_luminosity */
|
|
|
|
FALSE, /* inverse */
|
|
|
|
FALSE, /* border */
|
|
|
|
NATURAL /* colortype */
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static gint num_sparkles;
|
|
|
|
|
|
|
|
|
|
|
|
MAIN ()
|
|
|
|
|
|
|
|
static void
|
2000-01-08 23:23:28 +08:00
|
|
|
query (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
static GimpParamDef args[] =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
|
|
|
|
{ GIMP_PDB_IMAGE, "image", "Input image (unused)" },
|
|
|
|
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
|
|
|
|
{ GIMP_PDB_FLOAT, "lum_threshold", "Luminosity threshold (0.0 - 1.0)" },
|
|
|
|
{ GIMP_PDB_FLOAT, "flare_inten", "Flare intensity (0.0 - 1.0)" },
|
|
|
|
{ GIMP_PDB_INT32, "spike_len", "Spike length (in pixels)" },
|
|
|
|
{ GIMP_PDB_INT32, "spike_pts", "# of spike points" },
|
|
|
|
{ GIMP_PDB_INT32, "spike_angle", "Spike angle (0-360 degrees, -1: random)" },
|
|
|
|
{ GIMP_PDB_FLOAT, "density", "Spike density (0.0 - 1.0)" },
|
|
|
|
{ GIMP_PDB_FLOAT, "opacity", "Opacity (0.0 - 1.0)" },
|
|
|
|
{ GIMP_PDB_FLOAT, "random_hue", "Random hue (0.0 - 1.0)" },
|
|
|
|
{ GIMP_PDB_FLOAT, "random_saturation", "Random saturation (0.0 - 1.0)" },
|
|
|
|
{ GIMP_PDB_INT32, "preserve_luminosity", "Preserve luminosity (TRUE/FALSE)" },
|
2003-09-17 20:53:52 +08:00
|
|
|
{ GIMP_PDB_INT32, "inverse", "Inverse (TRUE/FALSE)" },
|
2000-08-22 09:26:57 +08:00
|
|
|
{ GIMP_PDB_INT32, "border", "Add border (TRUE/FALSE)" },
|
|
|
|
{ GIMP_PDB_INT32, "colortype", "Color of sparkles: { NATURAL (0), FOREGROUND (1), BACKGROUND (2) }" }
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
gimp_install_procedure ("plug_in_sparkle",
|
2003-09-17 13:21:08 +08:00
|
|
|
"Simulates pixel bloom and diffraction effects",
|
|
|
|
"Uses a percentage based luminoisty threhsold to find "
|
|
|
|
"candidate pixels for adding some sparkles (spikes). ",
|
|
|
|
"John Beale, & (ported to GIMP v0.54) Michael J. Hammel & ted to GIMP v1.0) & Seth Burgess & Spencer Kimball",
|
|
|
|
"John Beale",
|
|
|
|
"Version 1.27, September 2003",
|
|
|
|
N_("<Image>/Filters/Light Effects/_Sparkle..."),
|
|
|
|
"RGB*, GRAY*",
|
|
|
|
GIMP_PLUGIN,
|
|
|
|
G_N_ELEMENTS (args), 0,
|
|
|
|
args, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-07-02 21:00:16 +08:00
|
|
|
run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-01-04 01:55:00 +08:00
|
|
|
static GimpParam values[1];
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
GimpRunMode run_mode;
|
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
|
|
|
gint threshold, x1, y1, x2, y2;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
run_mode = param[0].data.d_int32;
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
INIT_I18N ();
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
*nreturn_vals = 1;
|
2002-01-04 01:55:00 +08:00
|
|
|
*return_vals = values;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-01-04 01:55:00 +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)
|
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_INTERACTIVE:
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Possibly retrieve data */
|
|
|
|
gimp_get_data ("plug_in_sparkle", &svals);
|
|
|
|
|
|
|
|
/* First acquire information with a dialog */
|
|
|
|
if (! sparkle_dialog ())
|
2003-09-17 13:21:08 +08:00
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_NONINTERACTIVE:
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Make sure all the arguments are there! */
|
1999-09-04 07:14:44 +08:00
|
|
|
if (nparams != 16)
|
2003-09-17 13:21:08 +08:00
|
|
|
{
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
}
|
2000-02-03 01:59:44 +08:00
|
|
|
else
|
2003-09-17 13:21:08 +08:00
|
|
|
{
|
|
|
|
svals.lum_threshold = param[3].data.d_float;
|
|
|
|
svals.flare_inten = param[4].data.d_float;
|
|
|
|
svals.spike_len = param[5].data.d_int32;
|
|
|
|
svals.spike_pts = param[6].data.d_int32;
|
|
|
|
svals.spike_angle = param[7].data.d_int32;
|
|
|
|
svals.density = param[8].data.d_float;
|
|
|
|
svals.opacity = param[9].data.d_float;
|
|
|
|
svals.random_hue = param[10].data.d_float;
|
|
|
|
svals.random_saturation = param[11].data.d_float;
|
|
|
|
svals.preserve_luminosity = (param[12].data.d_int32) ? TRUE : FALSE;
|
2003-09-17 20:53:52 +08:00
|
|
|
svals.inverse = (param[13].data.d_int32) ? TRUE : FALSE;
|
2003-09-17 13:21:08 +08:00
|
|
|
svals.border = (param[14].data.d_int32) ? TRUE : FALSE;
|
|
|
|
svals.colortype = param[15].data.d_int32;
|
|
|
|
|
|
|
|
if (svals.lum_threshold < 0.0 || svals.lum_threshold > 1.0)
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
else if (svals.flare_inten < 0.0 || svals.flare_inten > 1.0)
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
else if (svals.spike_len < 0)
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
else if (svals.spike_pts < 0)
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
else if (svals.spike_angle < -1 || svals.spike_angle > 360)
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
else if (svals.density < 0.0 || svals.density > 1.0)
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
else if (svals.opacity < 0.0 || svals.opacity > 1.0)
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
else if (svals.random_hue < 0.0 || svals.random_hue > 1.0)
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
else if (svals.random_saturation < 0.0 ||
|
|
|
|
svals.random_saturation > 1.0)
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
else if (svals.colortype < NATURAL || svals.colortype > BACKGROUND)
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_WITH_LAST_VALS:
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Possibly retrieve data */
|
|
|
|
gimp_get_data ("plug_in_sparkle", &svals);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the specified drawable */
|
|
|
|
drawable = gimp_drawable_get (param[2].data.d_drawable);
|
|
|
|
|
|
|
|
/* Make sure that the drawable is gray or RGB color */
|
2001-06-15 04:07:38 +08:00
|
|
|
if (gimp_drawable_is_rgb (drawable->drawable_id) ||
|
|
|
|
gimp_drawable_is_gray (drawable->drawable_id))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-02-03 01:59:44 +08:00
|
|
|
gimp_progress_init (_("Sparkling..."));
|
1999-09-04 07:14:44 +08:00
|
|
|
gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width () + 1));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-09-17 20:53:52 +08:00
|
|
|
if (svals.border)
|
1999-09-04 07:14:44 +08:00
|
|
|
{
|
2003-09-17 20:53:52 +08:00
|
|
|
gimp_drawable_mask_bounds (drawable->drawable_id,
|
|
|
|
&x1, &y1, &x2, &y2);
|
1999-09-04 07:14:44 +08:00
|
|
|
num_sparkles = 2 * (x2 - x1 + y2 - y1);
|
|
|
|
threshold = 255;
|
2003-09-17 20:53:52 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* compute the luminosity which exceeds the luminosity threshold */
|
|
|
|
threshold = compute_lum_threshold (drawable, svals.lum_threshold);
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
sparkle (drawable, threshold);
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
if (run_mode != GIMP_RUN_NONINTERACTIVE)
|
2003-09-17 13:21:08 +08:00
|
|
|
gimp_displays_flush ();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Store mvals data */
|
2000-08-22 09:26:57 +08:00
|
|
|
if (run_mode == GIMP_RUN_INTERACTIVE)
|
2003-09-17 13:21:08 +08:00
|
|
|
gimp_set_data ("plug_in_sparkle", &svals, sizeof (SparkleVals));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-09-04 07:14:44 +08:00
|
|
|
/* gimp_message ("sparkle: cannot operate on indexed color images"); */
|
2000-08-22 09:26:57 +08:00
|
|
|
status = GIMP_PDB_EXECUTION_ERROR;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
values[0].data.d_status = status;
|
|
|
|
|
|
|
|
gimp_drawable_detach (drawable);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
2000-01-08 23:23:28 +08:00
|
|
|
sparkle_dialog (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
GtkWidget *dlg;
|
2000-01-08 23:23:28 +08:00
|
|
|
GtkWidget *main_vbox;
|
|
|
|
GtkWidget *vbox;
|
2000-01-18 01:02:26 +08:00
|
|
|
GtkWidget *hbox;
|
1997-11-25 06:05:25 +08:00
|
|
|
GtkWidget *table;
|
1999-09-04 07:14:44 +08:00
|
|
|
GtkWidget *toggle;
|
2000-01-08 23:23:28 +08:00
|
|
|
GtkWidget *sep;
|
2000-01-31 11:13:02 +08:00
|
|
|
GtkWidget *r1, *r2, *r3;
|
1997-11-25 06:05:25 +08:00
|
|
|
GtkObject *scale_data;
|
2003-11-06 23:27:05 +08:00
|
|
|
gboolean run;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-02 04:22:55 +08:00
|
|
|
gimp_ui_init ("sparkle", FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-08 23:23:28 +08:00
|
|
|
dlg = gimp_dialog_new (_("Sparkle"), "sparkle",
|
2003-11-06 23:27:05 +08:00
|
|
|
NULL, 0,
|
|
|
|
gimp_standard_help_func, "filters/sparkle.html",
|
2002-01-04 01:55:00 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
2000-01-08 23:23:28 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* parameter settings */
|
2003-09-17 13:21:08 +08:00
|
|
|
main_vbox = gimp_parameter_settings_new (GTK_DIALOG (dlg)->vbox, 0, 0);
|
2000-01-08 23:23:28 +08:00
|
|
|
|
2000-01-16 23:38:38 +08:00
|
|
|
table = gtk_table_new (9, 3, FALSE);
|
2000-01-08 23:23:28 +08:00
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (table);
|
1999-09-04 07:14:44 +08:00
|
|
|
|
2000-01-16 23:38:38 +08:00
|
|
|
scale_data =
|
|
|
|
gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
|
2003-09-17 13:21:08 +08:00
|
|
|
_("Luminosity _Threshold:"), SCALE_WIDTH, ENTRY_WIDTH,
|
|
|
|
svals.lum_threshold, 0.0, 0.1, 0.001, 0.01, 3,
|
|
|
|
TRUE, 0, 0,
|
|
|
|
_("Adjust the Luminosity Threshold"), NULL);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (scale_data, "value_changed",
|
2002-01-04 01:55:00 +08:00
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
|
|
|
&svals.lum_threshold);
|
2000-01-16 23:38:38 +08:00
|
|
|
|
|
|
|
scale_data =
|
|
|
|
gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
|
2003-09-17 13:21:08 +08:00
|
|
|
_("F_lare Intensity:"), SCALE_WIDTH, ENTRY_WIDTH,
|
|
|
|
svals.flare_inten, 0.0, 1.0, 0.01, 0.1, 2,
|
|
|
|
TRUE, 0, 0,
|
|
|
|
_("Adjust the Flare Intensity"), NULL);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (scale_data, "value_changed",
|
2002-01-04 01:55:00 +08:00
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
|
|
|
&svals.flare_inten);
|
2000-01-16 23:38:38 +08:00
|
|
|
|
|
|
|
scale_data =
|
|
|
|
gimp_scale_entry_new (GTK_TABLE (table), 0, 2,
|
2003-09-17 13:21:08 +08:00
|
|
|
_("_Spike Length:"), SCALE_WIDTH, ENTRY_WIDTH,
|
|
|
|
svals.spike_len, 1, 100, 1, 10, 0,
|
|
|
|
TRUE, 0, 0,
|
|
|
|
_("Adjust the Spike Length"), NULL);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (scale_data, "value_changed",
|
2002-01-04 01:55:00 +08:00
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
|
|
|
&svals.spike_len);
|
2000-01-16 23:38:38 +08:00
|
|
|
|
|
|
|
scale_data =
|
|
|
|
gimp_scale_entry_new (GTK_TABLE (table), 0, 3,
|
2003-09-17 13:21:08 +08:00
|
|
|
_("Sp_ike Points:"), SCALE_WIDTH, ENTRY_WIDTH,
|
|
|
|
svals.spike_pts, 0, 16, 1, 4, 0,
|
|
|
|
TRUE, 0, 0,
|
|
|
|
_("Adjust the Number of Spikes"), NULL);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (scale_data, "value_changed",
|
2002-01-04 01:55:00 +08:00
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
|
|
|
&svals.spike_pts);
|
2000-01-16 23:38:38 +08:00
|
|
|
|
|
|
|
scale_data =
|
|
|
|
gimp_scale_entry_new (GTK_TABLE (table), 0, 4,
|
2003-09-17 13:21:08 +08:00
|
|
|
_("Spi_ke Angle (-1: Random):"), SCALE_WIDTH, ENTRY_WIDTH,
|
|
|
|
svals.spike_angle, -1, 360, 1, 15, 0,
|
|
|
|
TRUE, 0, 0,
|
|
|
|
_("Adjust the Spike Angle "
|
|
|
|
"(-1 means a Random Angle is choosen)"), NULL);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (scale_data, "value_changed",
|
2002-01-04 01:55:00 +08:00
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
|
|
|
&svals.spike_angle);
|
2000-01-08 23:23:28 +08:00
|
|
|
|
2000-01-16 23:38:38 +08:00
|
|
|
scale_data =
|
|
|
|
gimp_scale_entry_new (GTK_TABLE (table), 0, 5,
|
2003-09-17 13:21:08 +08:00
|
|
|
_("Spik_e Density:"), SCALE_WIDTH, ENTRY_WIDTH,
|
|
|
|
svals.density, 0.0, 1.0, 0.01, 0.1, 2,
|
|
|
|
TRUE, 0, 0,
|
|
|
|
_("Adjust the Spike Density"), NULL);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (scale_data, "value_changed",
|
2002-01-04 01:55:00 +08:00
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
|
|
|
&svals.density);
|
2000-01-16 23:38:38 +08:00
|
|
|
|
|
|
|
scale_data =
|
|
|
|
gimp_scale_entry_new (GTK_TABLE (table), 0, 6,
|
2003-09-17 13:21:08 +08:00
|
|
|
_("Op_acity:"), SCALE_WIDTH, ENTRY_WIDTH,
|
|
|
|
svals.opacity, 0.0, 1.0, 0.01, 0.1, 2,
|
|
|
|
TRUE, 0, 0,
|
|
|
|
_("Adjust the Opacity of the Spikes"), NULL);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (scale_data, "value_changed",
|
2002-01-04 01:55:00 +08:00
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
|
|
|
&svals.opacity);
|
2000-01-16 23:38:38 +08:00
|
|
|
|
|
|
|
scale_data =
|
|
|
|
gimp_scale_entry_new (GTK_TABLE (table), 0, 7,
|
2003-09-17 13:21:08 +08:00
|
|
|
_("_Random Hue:"), SCALE_WIDTH, ENTRY_WIDTH,
|
|
|
|
svals.random_hue, 0.0, 1.0, 0.01, 0.1, 2,
|
|
|
|
TRUE, 0, 0,
|
|
|
|
_("Adjust the Value how much the Hue should "
|
|
|
|
"be changed randomly"), NULL);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (scale_data, "value_changed",
|
2002-01-04 01:55:00 +08:00
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
|
|
|
&svals.random_hue);
|
2000-01-08 23:23:28 +08:00
|
|
|
|
2000-01-16 23:38:38 +08:00
|
|
|
scale_data =
|
|
|
|
gimp_scale_entry_new (GTK_TABLE (table), 0, 8,
|
2003-09-17 13:21:08 +08:00
|
|
|
_("Rando_m Saturation:"), SCALE_WIDTH, ENTRY_WIDTH,
|
|
|
|
svals.random_saturation, 0.0, 1.0, 0.01, 0.1, 2,
|
|
|
|
TRUE, 0, 0,
|
|
|
|
_("Adjust the Value how much the Saturation should "
|
|
|
|
"be changed randomly"), NULL);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (scale_data, "value_changed",
|
2002-01-04 01:55:00 +08:00
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
|
|
|
&svals.random_saturation);
|
2000-01-08 23:23:28 +08:00
|
|
|
|
|
|
|
sep = gtk_hseparator_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), sep, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (sep);
|
1999-09-04 07:14:44 +08:00
|
|
|
|
2000-01-18 01:02:26 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2000-01-31 11:13:02 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 1);
|
2000-01-18 01:02:26 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
|
2000-01-08 23:23:28 +08:00
|
|
|
gtk_widget_show (vbox);
|
1999-09-04 07:14:44 +08:00
|
|
|
|
2002-05-28 01:25:30 +08:00
|
|
|
toggle = gtk_check_button_new_with_mnemonic (_("_Preserve Luminosity"));
|
2000-01-08 23:23:28 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
|
2000-08-28 08:42:32 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
|
2003-09-17 13:21:08 +08:00
|
|
|
svals.preserve_luminosity);
|
1999-09-04 07:14:44 +08:00
|
|
|
gtk_widget_show (toggle);
|
2002-01-04 01:55:00 +08:00
|
|
|
|
2003-09-17 20:53:52 +08:00
|
|
|
gimp_help_set_help_data (toggle,
|
|
|
|
_("Should the Luminosity be preserved?"), NULL);
|
1999-09-04 07:14:44 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (toggle, "toggled",
|
2002-01-04 01:55:00 +08:00
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
&svals.preserve_luminosity);
|
|
|
|
|
2002-05-28 01:25:30 +08:00
|
|
|
toggle = gtk_check_button_new_with_mnemonic (_("In_verse"));
|
2000-01-08 23:23:28 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
|
2003-09-17 20:53:52 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), svals.inverse);
|
1999-09-04 07:14:44 +08:00
|
|
|
gtk_widget_show (toggle);
|
2002-01-04 01:55:00 +08:00
|
|
|
|
2003-09-17 20:53:52 +08:00
|
|
|
gimp_help_set_help_data (toggle,
|
|
|
|
_("Should an Inverse Effect be done?"), NULL);
|
2000-01-08 23:23:28 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (toggle, "toggled",
|
2002-01-04 01:55:00 +08:00
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
2003-09-17 20:53:52 +08:00
|
|
|
&svals.inverse);
|
2002-01-04 01:55:00 +08:00
|
|
|
|
2002-05-28 01:25:30 +08:00
|
|
|
toggle = gtk_check_button_new_with_mnemonic (_("A_dd Border"));
|
2000-01-08 23:23:28 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
|
2000-08-28 08:42:32 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), svals.border);
|
1999-09-04 07:14:44 +08:00
|
|
|
gtk_widget_show (toggle);
|
2002-01-04 01:55:00 +08:00
|
|
|
|
2000-01-08 23:23:28 +08:00
|
|
|
gimp_help_set_help_data (toggle,
|
2003-09-17 20:53:52 +08:00
|
|
|
_("Draw a Border of Spikes around the Image"), NULL);
|
1999-09-04 07:14:44 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (toggle, "toggled",
|
2002-01-04 01:55:00 +08:00
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
&svals.border);
|
|
|
|
|
2000-01-18 01:02:26 +08:00
|
|
|
sep = gtk_vseparator_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), sep, FALSE, FALSE, 0);
|
2000-01-08 23:23:28 +08:00
|
|
|
gtk_widget_show (sep);
|
1999-09-04 07:14:44 +08:00
|
|
|
|
2000-01-08 23:23:28 +08:00
|
|
|
/* colortype */
|
2002-01-04 01:55:00 +08:00
|
|
|
vbox = gimp_radio_group_new2 (FALSE, NULL,
|
|
|
|
G_CALLBACK (gimp_radio_button_update),
|
|
|
|
&svals.colortype,
|
|
|
|
GINT_TO_POINTER (svals.colortype),
|
1999-09-04 07:14:44 +08:00
|
|
|
|
2002-05-28 01:25:30 +08:00
|
|
|
_("_Natural Color"),
|
2002-01-04 01:55:00 +08:00
|
|
|
GINT_TO_POINTER (NATURAL), &r1,
|
|
|
|
|
2002-05-28 01:25:30 +08:00
|
|
|
_("_Foreground Color"),
|
2002-01-04 01:55:00 +08:00
|
|
|
GINT_TO_POINTER (FOREGROUND), &r2,
|
|
|
|
|
2002-05-28 01:25:30 +08:00
|
|
|
_("_Background Color"),
|
2002-01-04 01:55:00 +08:00
|
|
|
GINT_TO_POINTER (BACKGROUND), &r3,
|
|
|
|
|
|
|
|
NULL);
|
1999-09-04 07:14:44 +08:00
|
|
|
|
2000-01-31 11:13:02 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
|
|
|
gimp_help_set_help_data (r1, _("Use the Color of the Image"), NULL);
|
|
|
|
gimp_help_set_help_data (r2, _("Use the Foreground Color"), NULL);
|
|
|
|
gimp_help_set_help_data (r3, _("Use the Background Color"), NULL);
|
1999-09-04 07:14:44 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_show (dlg);
|
|
|
|
|
2003-11-12 02:11:56 +08:00
|
|
|
run = (gimp_dialog_run (GIMP_DIALOG (dlg)) == GTK_RESPONSE_OK);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
|
|
|
gtk_widget_destroy (dlg);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
return run;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
2003-09-17 20:53:52 +08:00
|
|
|
compute_luminosity (const guchar *pixel,
|
|
|
|
gboolean gray,
|
|
|
|
gboolean has_alpha)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-09-04 07:14:44 +08:00
|
|
|
gint pixel0, pixel1, pixel2;
|
|
|
|
|
2003-09-17 20:53:52 +08:00
|
|
|
if (svals.inverse)
|
1999-09-04 07:14:44 +08:00
|
|
|
{
|
|
|
|
pixel0 = 255 - pixel[0];
|
|
|
|
pixel1 = 255 - pixel[1];
|
|
|
|
pixel2 = 255 - pixel[2];
|
|
|
|
}
|
2003-09-17 20:53:52 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
pixel0 = pixel[0];
|
|
|
|
pixel1 = pixel[1];
|
|
|
|
pixel2 = pixel[2];
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (gray)
|
|
|
|
{
|
|
|
|
if (has_alpha)
|
2003-09-17 13:21:08 +08:00
|
|
|
return (pixel0 * pixel1) / 255;
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2003-09-17 13:21:08 +08:00
|
|
|
return (pixel0);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gint min, max;
|
|
|
|
|
1999-09-04 07:14:44 +08:00
|
|
|
min = MIN (pixel0, pixel1);
|
|
|
|
min = MIN (min, pixel2);
|
|
|
|
max = MAX (pixel0, pixel1);
|
|
|
|
max = MAX (max, pixel2);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (has_alpha)
|
2003-09-17 13:21:08 +08:00
|
|
|
return ((min + max) * pixel[3]) / 510;
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2003-09-17 13:21:08 +08:00
|
|
|
return (min + max) / 2;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
2000-08-22 09:26:57 +08:00
|
|
|
compute_lum_threshold (GimpDrawable *drawable,
|
2003-09-17 20:53:52 +08:00
|
|
|
gdouble percentile)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
GimpPixelRgn src_rgn;
|
2003-09-17 20:53:52 +08:00
|
|
|
gpointer pr;
|
|
|
|
gint values[256];
|
|
|
|
gint total, sum;
|
|
|
|
gboolean gray;
|
|
|
|
gboolean has_alpha;
|
|
|
|
gint i;
|
|
|
|
gint x1, y1, x2, y2;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* zero out the luminosity values array */
|
2000-02-03 01:59:44 +08:00
|
|
|
memset (values, 0, sizeof (gint) * 256);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-06-15 04:07:38 +08:00
|
|
|
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
2003-09-17 20:53:52 +08:00
|
|
|
|
2001-06-15 04:07:38 +08:00
|
|
|
gray = gimp_drawable_is_gray (drawable->drawable_id);
|
|
|
|
has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-02-03 01:59:44 +08:00
|
|
|
gimp_pixel_rgn_init (&src_rgn, drawable,
|
2003-09-17 20:53:52 +08:00
|
|
|
x1, y1, (x2 - x1), (y2 - y1), FALSE, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-02-03 01:59:44 +08:00
|
|
|
for (pr = gimp_pixel_rgns_register (1, &src_rgn);
|
|
|
|
pr != NULL;
|
|
|
|
pr = gimp_pixel_rgns_process (pr))
|
2003-09-17 13:21:08 +08:00
|
|
|
{
|
2003-09-17 20:53:52 +08:00
|
|
|
const guchar *src, *s;
|
|
|
|
gint sx, sy;
|
|
|
|
|
|
|
|
src = src_rgn.data;
|
|
|
|
|
|
|
|
for (sy = 0; sy < src_rgn.h; sy++)
|
|
|
|
{
|
|
|
|
s = src;
|
|
|
|
|
|
|
|
for (sx = 0; sx < src_rgn.w; sx++)
|
2003-09-17 13:21:08 +08:00
|
|
|
{
|
2003-09-17 20:53:52 +08:00
|
|
|
values [compute_luminosity (s, gray, has_alpha)]++;
|
|
|
|
s += src_rgn.bpp;
|
2003-09-17 13:21:08 +08:00
|
|
|
}
|
2003-09-17 20:53:52 +08:00
|
|
|
|
|
|
|
src += src_rgn.rowstride;
|
2003-09-17 13:21:08 +08:00
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
total = (x2 - x1) * (y2 - y1);
|
|
|
|
sum = 0;
|
|
|
|
|
|
|
|
for (i = 255; i >= 0; i--)
|
|
|
|
{
|
|
|
|
sum += values[i];
|
2000-01-19 22:57:19 +08:00
|
|
|
if ((gdouble) sum > percentile * (gdouble) total)
|
2003-09-17 13:21:08 +08:00
|
|
|
{
|
|
|
|
num_sparkles = sum;
|
|
|
|
return i;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-08-22 09:26:57 +08:00
|
|
|
sparkle (GimpDrawable *drawable,
|
2003-09-17 20:53:52 +08:00
|
|
|
gint threshold)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
GimpPixelRgn src_rgn, dest_rgn;
|
2003-09-17 20:53:52 +08:00
|
|
|
gdouble nfrac, length, inten, spike_angle;
|
|
|
|
gint cur_progress, max_progress;
|
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
gint lum, x, y, b;
|
|
|
|
gboolean gray, has_alpha;
|
|
|
|
gint alpha;
|
|
|
|
gpointer pr;
|
|
|
|
gint tile_width, tile_height;
|
|
|
|
GRand *gr;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c
2002-11-20 Dave Neary <bolsh@gimp.org>
* configure.in
* app/core/gimpbrushpipe.c
* app/gui/about-dialog.c
* app/paint-funcs/paint-funcs-generic.h
* app/paint-funcs/paint-funcs.c
* libgimpmath/gimpmath.h
* libgimpwidgets/gimpwidgets.c
* plug-ins/common/CML_explorer.c
* plug-ins/common/blur.c
* plug-ins/common/cubism.c
* plug-ins/common/gee.c
* plug-ins/common/gee_zoom.c
* plug-ins/common/gqbist.c
* plug-ins/common/jigsaw.c
* plug-ins/common/lic.c
* plug-ins/common/noisify.c
* plug-ins/common/nova.c
* plug-ins/common/papertile.c
* plug-ins/common/plasma.c
* plug-ins/common/randomize.c
* plug-ins/common/sample_colorize.c
* plug-ins/common/scatter_hsv.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/sparkle.c
* plug-ins/common/spheredesigner.c
* plug-ins/common/spread.c
* plug-ins/common/warp.c
* plug-ins/common/wind.c
* plug-ins/flame/cmap.c
* plug-ins/flame/flame.c
* plug-ins/flame/libifs.c
* plug-ins/gflare/gflare.c
* plug-ins/gimpressionist/gimpressionist.c
* plug-ins/gimpressionist/gimpressionist.h
* plug-ins/gimpressionist/plasma.c
* plug-ins/gimpressionist/repaint.c
* plug-ins/ifscompose/ifscompose_utils.c
* plug-ins/maze/algorithms.c
* plug-ins/maze/maze.c
* plug-ins/maze/maze.h
* plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX,
G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(),
srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand*
equivalent. Programs which require seed setting for reproducible
results, and anything in the core, gets a dedicated GRand * for
the lifetime required. Programs which only ever used random
numbers for tossing a coin, rolling a dice, etc use g_random
functions. For the rest, judgement was used. Where it was easy, a
GRand * object was used and g_rand_* functions were
preferred. This fixes bug #67386 in HEAD.
2002-11-20 17:27:48 +08:00
|
|
|
gr = g_rand_new ();
|
2003-09-17 20:53:52 +08:00
|
|
|
|
2001-06-15 04:07:38 +08:00
|
|
|
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
2003-09-17 20:53:52 +08:00
|
|
|
|
2001-06-15 04:07:38 +08:00
|
|
|
gray = gimp_drawable_is_gray (drawable->drawable_id);
|
|
|
|
has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
1997-11-25 06:05:25 +08:00
|
|
|
alpha = (has_alpha) ? drawable->bpp - 1 : drawable->bpp;
|
2003-09-17 20:53:52 +08:00
|
|
|
|
1999-09-04 07:14:44 +08:00
|
|
|
tile_width = gimp_tile_width();
|
|
|
|
tile_height = gimp_tile_height();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* initialize the progress dialog */
|
|
|
|
cur_progress = 0;
|
|
|
|
max_progress = num_sparkles;
|
|
|
|
|
2003-09-17 13:21:08 +08:00
|
|
|
/* copy what is already there */
|
2000-02-03 01:59:44 +08:00
|
|
|
gimp_pixel_rgn_init (&src_rgn, drawable,
|
2003-09-17 20:53:52 +08:00
|
|
|
x1, y1, (x2 - x1), (y2 - y1), FALSE, FALSE);
|
2000-02-03 01:59:44 +08:00
|
|
|
gimp_pixel_rgn_init (&dest_rgn, drawable,
|
2003-09-17 20:53:52 +08:00
|
|
|
x1, y1, (x2 - x1), (y2 - y1), TRUE, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-02-03 01:59:44 +08:00
|
|
|
for (pr = gimp_pixel_rgns_register (2, &src_rgn, &dest_rgn);
|
|
|
|
pr != NULL;
|
|
|
|
pr = gimp_pixel_rgns_process (pr))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-09-17 20:53:52 +08:00
|
|
|
const guchar *src, *s;
|
|
|
|
guchar *dest, *d;
|
2003-09-17 13:21:08 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
src = src_rgn.data;
|
|
|
|
dest = dest_rgn.data;
|
|
|
|
|
2003-09-17 20:53:52 +08:00
|
|
|
for (y = 0; y < src_rgn.h; y++)
|
1999-09-04 07:14:44 +08:00
|
|
|
{
|
2003-09-17 20:53:52 +08:00
|
|
|
s = src;
|
|
|
|
d = dest;
|
|
|
|
|
|
|
|
for (x = 0; x < src_rgn.w; x++)
|
1999-09-04 07:14:44 +08:00
|
|
|
{
|
2003-09-17 20:53:52 +08:00
|
|
|
if (has_alpha && s[alpha] == 0)
|
|
|
|
{
|
|
|
|
memset (dest, 0, alpha);
|
|
|
|
}
|
2003-09-17 13:21:08 +08:00
|
|
|
else
|
1999-09-04 07:14:44 +08:00
|
|
|
{
|
2003-09-17 20:53:52 +08:00
|
|
|
for (b = 0; b < alpha; b++)
|
|
|
|
d[b] = s[b];
|
1999-09-04 07:14:44 +08:00
|
|
|
}
|
2003-09-17 20:53:52 +08:00
|
|
|
|
2003-09-17 13:21:08 +08:00
|
|
|
if (has_alpha)
|
2003-09-17 20:53:52 +08:00
|
|
|
d[alpha] = src[alpha];
|
1999-09-04 07:14:44 +08:00
|
|
|
|
2003-09-17 20:53:52 +08:00
|
|
|
s += src_rgn.bpp;
|
|
|
|
d += dest_rgn.bpp;
|
2003-09-17 13:21:08 +08:00
|
|
|
}
|
2003-09-17 20:53:52 +08:00
|
|
|
|
|
|
|
src += src_rgn.rowstride;
|
|
|
|
dest += dest_rgn.rowstride;
|
1999-09-04 07:14:44 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
/* add effects to new image based on intensity of old pixels */
|
2003-09-17 20:53:52 +08:00
|
|
|
|
2000-02-03 01:59:44 +08:00
|
|
|
gimp_pixel_rgn_init (&src_rgn, drawable,
|
2003-09-17 20:53:52 +08:00
|
|
|
x1, y1, (x2 - x1), (y2 - y1), FALSE, FALSE);
|
2000-02-03 01:59:44 +08:00
|
|
|
gimp_pixel_rgn_init (&dest_rgn, drawable,
|
2003-09-17 20:53:52 +08:00
|
|
|
x1, y1, (x2 - x1), (y2 - y1), TRUE, TRUE);
|
2000-02-03 01:59:44 +08:00
|
|
|
|
|
|
|
for (pr = gimp_pixel_rgns_register (2, &src_rgn, &dest_rgn);
|
|
|
|
pr != NULL;
|
|
|
|
pr = gimp_pixel_rgns_process (pr))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-09-17 20:53:52 +08:00
|
|
|
const guchar *src, *s;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
src = src_rgn.data;
|
2003-09-17 20:53:52 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
for (y = 0; y < src_rgn.h; y++)
|
2003-09-17 20:53:52 +08:00
|
|
|
{
|
|
|
|
s = src;
|
|
|
|
|
2003-09-17 13:21:08 +08:00
|
|
|
for (x = 0; x < src_rgn.w; x++)
|
|
|
|
{
|
|
|
|
if (svals.border)
|
2003-09-17 20:53:52 +08:00
|
|
|
{
|
|
|
|
if (x + src_rgn.x == 0 ||
|
|
|
|
y + src_rgn.y == 0 ||
|
|
|
|
x + src_rgn.x == drawable->width - 1 ||
|
|
|
|
y + src_rgn.y == drawable->height - 1)
|
|
|
|
{
|
|
|
|
lum = 255;
|
|
|
|
}
|
2003-09-17 13:21:08 +08:00
|
|
|
else
|
2003-09-17 20:53:52 +08:00
|
|
|
{
|
|
|
|
lum = 0;
|
|
|
|
}
|
2003-09-17 13:21:08 +08:00
|
|
|
}
|
|
|
|
else
|
2003-09-17 20:53:52 +08:00
|
|
|
{
|
|
|
|
lum = compute_luminosity (s, gray, has_alpha);
|
|
|
|
}
|
|
|
|
|
2003-09-17 13:21:08 +08:00
|
|
|
if (lum >= threshold)
|
2003-09-17 20:53:52 +08:00
|
|
|
{
|
|
|
|
nfrac = fabs ((gdouble) (lum + 1 - threshold) /
|
|
|
|
(gdouble) (256 - threshold));
|
|
|
|
length = ((gdouble) svals.spike_len *
|
|
|
|
(gdouble) pow (nfrac, 0.8));
|
|
|
|
inten = svals.flare_inten * nfrac;
|
|
|
|
|
|
|
|
/* fspike im x,y intens rlength angle */
|
|
|
|
if (svals.spike_pts > 0)
|
|
|
|
{
|
2003-09-17 13:21:08 +08:00
|
|
|
gdouble random_1 = g_rand_double(gr);
|
|
|
|
/* major spikes */
|
|
|
|
if (svals.spike_angle == -1)
|
|
|
|
spike_angle = g_rand_double_range (gr, 0, 360.0);
|
|
|
|
else
|
|
|
|
spike_angle = svals.spike_angle;
|
|
|
|
|
|
|
|
if (random_1 <= svals.density)
|
|
|
|
{
|
2003-09-17 20:53:52 +08:00
|
|
|
fspike (&src_rgn, &dest_rgn, x1, y1, x2, y2,
|
2003-09-17 13:21:08 +08:00
|
|
|
x + src_rgn.x, y + src_rgn.y,
|
|
|
|
tile_width, tile_height,
|
|
|
|
inten, length, spike_angle, gr);
|
2003-09-17 20:53:52 +08:00
|
|
|
|
2003-09-17 13:21:08 +08:00
|
|
|
/* minor spikes */
|
2003-09-17 20:53:52 +08:00
|
|
|
fspike (&src_rgn, &dest_rgn, x1, y1, x2, y2,
|
2003-09-17 13:21:08 +08:00
|
|
|
x + src_rgn.x, y + src_rgn.y,
|
|
|
|
tile_width, tile_height,
|
|
|
|
inten * 0.7, length * 0.7,
|
|
|
|
((gdouble)spike_angle+180.0/svals.spike_pts),
|
|
|
|
gr);
|
|
|
|
}
|
|
|
|
}
|
2003-09-17 20:53:52 +08:00
|
|
|
|
2003-09-17 13:21:08 +08:00
|
|
|
cur_progress ++;
|
2003-09-17 20:53:52 +08:00
|
|
|
|
2003-09-17 13:21:08 +08:00
|
|
|
if ((cur_progress % 5) == 0)
|
|
|
|
gimp_progress_update ((double) cur_progress /
|
2003-09-17 20:53:52 +08:00
|
|
|
(double) max_progress);
|
|
|
|
}
|
|
|
|
|
|
|
|
s += src_rgn.bpp;
|
|
|
|
}
|
|
|
|
|
|
|
|
src += src_rgn.rowstride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gimp_progress_update (1.0);
|
|
|
|
|
|
|
|
/* update the blurred region */
|
|
|
|
gimp_drawable_flush (drawable);
|
2001-06-15 04:07:38 +08:00
|
|
|
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
|
|
|
|
gimp_drawable_update (drawable->drawable_id, x1, y1, (x2 - x1), (y2 - y1));
|
2003-09-17 20:53:52 +08:00
|
|
|
|
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c
2002-11-20 Dave Neary <bolsh@gimp.org>
* configure.in
* app/core/gimpbrushpipe.c
* app/gui/about-dialog.c
* app/paint-funcs/paint-funcs-generic.h
* app/paint-funcs/paint-funcs.c
* libgimpmath/gimpmath.h
* libgimpwidgets/gimpwidgets.c
* plug-ins/common/CML_explorer.c
* plug-ins/common/blur.c
* plug-ins/common/cubism.c
* plug-ins/common/gee.c
* plug-ins/common/gee_zoom.c
* plug-ins/common/gqbist.c
* plug-ins/common/jigsaw.c
* plug-ins/common/lic.c
* plug-ins/common/noisify.c
* plug-ins/common/nova.c
* plug-ins/common/papertile.c
* plug-ins/common/plasma.c
* plug-ins/common/randomize.c
* plug-ins/common/sample_colorize.c
* plug-ins/common/scatter_hsv.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/sparkle.c
* plug-ins/common/spheredesigner.c
* plug-ins/common/spread.c
* plug-ins/common/warp.c
* plug-ins/common/wind.c
* plug-ins/flame/cmap.c
* plug-ins/flame/flame.c
* plug-ins/flame/libifs.c
* plug-ins/gflare/gflare.c
* plug-ins/gimpressionist/gimpressionist.c
* plug-ins/gimpressionist/gimpressionist.h
* plug-ins/gimpressionist/plasma.c
* plug-ins/gimpressionist/repaint.c
* plug-ins/ifscompose/ifscompose_utils.c
* plug-ins/maze/algorithms.c
* plug-ins/maze/maze.c
* plug-ins/maze/maze.h
* plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX,
G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(),
srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand*
equivalent. Programs which require seed setting for reproducible
results, and anything in the core, gets a dedicated GRand * for
the lifetime required. Programs which only ever used random
numbers for tossing a coin, rolling a dice, etc use g_random
functions. For the rest, judgement was used. Where it was easy, a
GRand * object was used and g_rand_* functions were
preferred. This fixes bug #67386 in HEAD.
2002-11-20 17:27:48 +08:00
|
|
|
g_rand_free (gr);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
static inline GimpTile *
|
|
|
|
rpnt (GimpDrawable *drawable,
|
|
|
|
GimpTile *tile,
|
2003-09-17 20:53:52 +08:00
|
|
|
gint x1,
|
|
|
|
gint y1,
|
|
|
|
gint x2,
|
|
|
|
gint y2,
|
|
|
|
gdouble xr,
|
|
|
|
gdouble yr,
|
|
|
|
gint tile_width,
|
|
|
|
gint tile_height,
|
|
|
|
gint *row,
|
|
|
|
gint *col,
|
|
|
|
gint bytes,
|
|
|
|
gdouble inten,
|
|
|
|
guchar color[MAX_CHANNELS])
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-09-17 20:53:52 +08:00
|
|
|
gint x, y, b;
|
|
|
|
gdouble dx, dy, rs, val;
|
|
|
|
guchar *pixel;
|
|
|
|
gdouble new;
|
|
|
|
gint newcol, newrow;
|
|
|
|
gint newcoloff, newrowoff;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-09-17 13:21:08 +08:00
|
|
|
x = (int) (xr); /* integer coord. to upper left of real point */
|
1997-11-25 06:05:25 +08:00
|
|
|
y = (int) (yr);
|
|
|
|
|
|
|
|
if (x >= x1 && y >= y1 && x < x2 && y < y2)
|
|
|
|
{
|
1999-09-04 07:14:44 +08:00
|
|
|
newcol = x / tile_width;
|
|
|
|
newcoloff = x % tile_width;
|
|
|
|
newrow = y / tile_height;
|
|
|
|
newrowoff = y % tile_height;
|
2003-09-17 20:53:52 +08:00
|
|
|
|
1999-09-04 07:14:44 +08:00
|
|
|
if ((newcol != *col) || (newrow != *row))
|
2003-09-17 13:21:08 +08:00
|
|
|
{
|
|
|
|
*col = newcol;
|
|
|
|
*row = newrow;
|
2003-09-17 20:53:52 +08:00
|
|
|
|
2003-09-17 13:21:08 +08:00
|
|
|
if (tile)
|
|
|
|
gimp_tile_unref (tile, TRUE);
|
2003-09-17 20:53:52 +08:00
|
|
|
|
2003-09-17 13:21:08 +08:00
|
|
|
tile = gimp_drawable_get_tile (drawable, TRUE, *row, *col);
|
|
|
|
gimp_tile_ref (tile);
|
|
|
|
}
|
1998-03-30 06:32:54 +08:00
|
|
|
|
1999-09-04 07:14:44 +08:00
|
|
|
pixel = tile->data + tile->bpp * (tile->ewidth * newrowoff + newcoloff);
|
1997-11-25 06:05:25 +08:00
|
|
|
dx = xr - x; dy = yr - y;
|
|
|
|
rs = dx * dx + dy * dy;
|
1999-09-04 07:14:44 +08:00
|
|
|
val = inten * exp (-rs / PSV);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-04 07:14:44 +08:00
|
|
|
for (b = 0; b < bytes; b++)
|
2003-09-17 20:53:52 +08:00
|
|
|
{
|
|
|
|
if (svals.inverse)
|
2003-09-17 13:21:08 +08:00
|
|
|
new = 255 - pixel[b];
|
2003-09-17 20:53:52 +08:00
|
|
|
else
|
|
|
|
new = pixel[b];
|
2003-09-17 13:21:08 +08:00
|
|
|
|
2003-09-17 20:53:52 +08:00
|
|
|
if (svals.preserve_luminosity)
|
|
|
|
{
|
|
|
|
if (new < color[b])
|
|
|
|
{
|
|
|
|
new *= (1.0 - val * (1.0 - svals.opacity));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
new -= val * color[b] * (1.0 - svals.opacity);
|
|
|
|
if (new < 0.0)
|
|
|
|
new = 0.0;
|
|
|
|
}
|
|
|
|
}
|
2003-09-17 13:21:08 +08:00
|
|
|
|
2003-09-17 20:53:52 +08:00
|
|
|
new *= 1.0 - val * svals.opacity;
|
|
|
|
new += val * color[b];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-09-17 20:53:52 +08:00
|
|
|
if (new > 255)
|
|
|
|
new = 255;
|
|
|
|
|
|
|
|
if (svals.inverse)
|
|
|
|
pixel[b] = 255 - new;
|
|
|
|
else
|
|
|
|
pixel[b] = new;
|
2003-09-17 13:21:08 +08:00
|
|
|
}
|
|
|
|
}
|
2003-09-17 20:53:52 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return tile;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-08-22 09:26:57 +08:00
|
|
|
fspike (GimpPixelRgn *src_rgn,
|
2003-09-17 20:53:52 +08:00
|
|
|
GimpPixelRgn *dest_rgn,
|
|
|
|
gint x1,
|
|
|
|
gint y1,
|
|
|
|
gint x2,
|
|
|
|
gint y2,
|
|
|
|
gint xr,
|
|
|
|
gint yr,
|
|
|
|
gint tile_width,
|
|
|
|
gint tile_height,
|
|
|
|
gdouble inten,
|
|
|
|
gdouble length,
|
|
|
|
gdouble angle,
|
|
|
|
GRand *gr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-01-03 06:30:20 +08:00
|
|
|
const gdouble efac = 2.0;
|
|
|
|
gdouble xrt, yrt, dx, dy;
|
|
|
|
gdouble rpos;
|
|
|
|
gdouble in;
|
|
|
|
gdouble theta;
|
|
|
|
gdouble sfac;
|
2000-05-02 04:22:55 +08:00
|
|
|
gint r, g, b;
|
2000-08-22 09:26:57 +08:00
|
|
|
GimpTile *tile = NULL;
|
2000-05-02 04:22:55 +08:00
|
|
|
gint row, col;
|
|
|
|
gint i;
|
|
|
|
gint bytes;
|
|
|
|
gint ok;
|
2001-01-15 08:06:43 +08:00
|
|
|
GimpRGB gimp_color;
|
2000-05-02 04:22:55 +08:00
|
|
|
guchar pixel[MAX_CHANNELS];
|
|
|
|
guchar color[MAX_CHANNELS];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-03 06:30:20 +08:00
|
|
|
theta = angle;
|
|
|
|
bytes = dest_rgn->bpp;
|
|
|
|
row = -1;
|
|
|
|
col = -1;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-15 08:06:43 +08:00
|
|
|
switch (svals.colortype)
|
2000-01-03 06:30:20 +08:00
|
|
|
{
|
2001-01-15 08:06:43 +08:00
|
|
|
case NATURAL:
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-15 08:06:43 +08:00
|
|
|
case FOREGROUND:
|
2001-01-25 09:20:05 +08:00
|
|
|
gimp_palette_get_foreground (&gimp_color);
|
2001-01-15 08:06:43 +08:00
|
|
|
gimp_rgb_get_uchar (&gimp_color, &pixel[0], &pixel[1], &pixel[2]);
|
|
|
|
break;
|
2003-09-17 20:53:52 +08:00
|
|
|
|
2001-01-15 08:06:43 +08:00
|
|
|
case BACKGROUND:
|
2001-01-25 09:20:05 +08:00
|
|
|
gimp_palette_get_background (&gimp_color);
|
2001-01-15 08:06:43 +08:00
|
|
|
gimp_rgb_get_uchar (&gimp_color, &pixel[0], &pixel[1], &pixel[2]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* draw the major spikes */
|
|
|
|
for (i = 0; i < svals.spike_pts; i++)
|
|
|
|
{
|
|
|
|
if (svals.colortype == NATURAL)
|
2003-09-17 13:21:08 +08:00
|
|
|
gimp_pixel_rgn_get_pixel (src_rgn, pixel, xr, yr);
|
2003-09-17 20:53:52 +08:00
|
|
|
|
2001-01-15 08:06:43 +08:00
|
|
|
color[0] = pixel[0];
|
|
|
|
color[1] = pixel[1];
|
|
|
|
color[2] = pixel[2];
|
|
|
|
|
2003-09-17 20:53:52 +08:00
|
|
|
if (svals.inverse)
|
2003-09-17 13:21:08 +08:00
|
|
|
{
|
|
|
|
color[0] = 255 - color[0];
|
|
|
|
color[1] = 255 - color[1];
|
|
|
|
color[2] = 255 - color[2];
|
2000-01-03 06:30:20 +08:00
|
|
|
}
|
|
|
|
if (svals.random_hue > 0.0 || svals.random_saturation > 0.0)
|
|
|
|
{
|
2003-09-17 13:21:08 +08:00
|
|
|
r = 255 - color[0];
|
|
|
|
g = 255 - color[1];
|
2003-09-17 20:53:52 +08:00
|
|
|
b = 255 - color[2];
|
|
|
|
|
|
|
|
gimp_rgb_to_hsv_int (&r, &g, &b);
|
|
|
|
|
|
|
|
r += svals.random_hue * g_rand_double_range (gr, -0.5, 0.5) * 255;
|
|
|
|
|
2003-09-17 13:21:08 +08:00
|
|
|
if (r >= 255)
|
|
|
|
r -= 255;
|
2003-09-17 20:53:52 +08:00
|
|
|
else if (r < 0)
|
2003-09-17 13:21:08 +08:00
|
|
|
r += 255;
|
2003-09-17 20:53:52 +08:00
|
|
|
|
|
|
|
b += (svals.random_saturation *
|
|
|
|
g_rand_double_range (gr, -0.5, 0.5)) * 255;
|
|
|
|
|
|
|
|
if (b > 255)
|
|
|
|
b = 255;
|
|
|
|
|
2003-09-17 13:21:08 +08:00
|
|
|
gimp_hsv_to_rgb_int (&r, &g, &b);
|
2003-09-17 20:53:52 +08:00
|
|
|
|
2003-09-17 13:21:08 +08:00
|
|
|
color[0] = 255 - r;
|
|
|
|
color[1] = 255 - g;
|
|
|
|
color[2] = 255 - b;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-03 06:30:20 +08:00
|
|
|
dx = 0.2 * cos (theta * G_PI / 180.0);
|
|
|
|
dy = 0.2 * sin (theta * G_PI / 180.0);
|
2000-01-19 22:57:19 +08:00
|
|
|
xrt = (gdouble) xr; /* (gdouble) is needed because some */
|
|
|
|
yrt = (gdouble) yr; /* compilers optimize too much otherwise */
|
2000-01-03 06:30:20 +08:00
|
|
|
rpos = 0.2;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-03 06:30:20 +08:00
|
|
|
do
|
2003-09-17 13:21:08 +08:00
|
|
|
{
|
|
|
|
sfac = inten * exp (-pow (rpos / length, efac));
|
|
|
|
ok = FALSE;
|
2000-01-03 06:30:20 +08:00
|
|
|
|
2003-09-17 13:21:08 +08:00
|
|
|
in = 0.2 * sfac;
|
|
|
|
if (in > 0.01)
|
2000-01-03 06:30:20 +08:00
|
|
|
ok = TRUE;
|
|
|
|
|
2003-09-17 20:53:52 +08:00
|
|
|
tile = rpnt (dest_rgn->drawable, tile, x1, y1, x2, y2,
|
|
|
|
xrt, yrt, tile_width, tile_height,
|
|
|
|
&row, &col, bytes, in, color);
|
|
|
|
tile = rpnt (dest_rgn->drawable, tile, x1, y1, x2, y2,
|
|
|
|
xrt + 1.0, yrt, tile_width, tile_height,
|
|
|
|
&row, &col, bytes, in, color);
|
|
|
|
tile = rpnt (dest_rgn->drawable, tile, x1, y1, x2, y2,
|
|
|
|
xrt + 1.0, yrt + 1.0, tile_width, tile_height,
|
|
|
|
&row, &col, bytes, in, color);
|
|
|
|
tile = rpnt (dest_rgn->drawable, tile, x1, y1, x2, y2,
|
|
|
|
xrt, yrt + 1.0, tile_width, tile_height,
|
|
|
|
&row, &col, bytes, in, color);
|
2003-09-17 13:21:08 +08:00
|
|
|
|
|
|
|
xrt += dx;
|
|
|
|
yrt += dy;
|
|
|
|
rpos += 0.2;
|
2003-09-17 20:53:52 +08:00
|
|
|
|
2003-09-17 13:21:08 +08:00
|
|
|
} while (ok);
|
2000-01-03 06:30:20 +08:00
|
|
|
|
|
|
|
theta += 360.0 / svals.spike_pts;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-01-03 06:30:20 +08:00
|
|
|
if (tile)
|
|
|
|
gimp_tile_unref (tile, TRUE);
|
|
|
|
}
|