1997-11-25 06:05:25 +08:00
|
|
|
/*
|
|
|
|
* This is a plugin for the GIMP.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
* Copyright (C) 1996 Torsten Martinsen
|
|
|
|
*
|
|
|
|
* 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
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This filter adds random noise to an image.
|
|
|
|
* The amount of noise can be set individually for each RGB channel.
|
|
|
|
* This filter does not operate on indexed images.
|
2000-05-23 21:00:40 +08:00
|
|
|
*
|
|
|
|
* May 2000 tim copperfield [timecop@japan.co.jp]
|
|
|
|
* Added dynamic preview.
|
|
|
|
*
|
2000-05-27 05:23:03 +08:00
|
|
|
* alt@gimp.org. Fixed previews so they handle alpha channels correctly.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
|
|
|
|
2000-01-07 18:39:33 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2000-10-01 04:13:06 +08:00
|
|
|
#include <string.h>
|
2002-01-30 22:54:27 +08:00
|
|
|
|
2000-01-07 18:39:33 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2000-01-11 23:48:00 +08:00
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
2000-01-07 18:39:33 +08:00
|
|
|
|
2000-01-01 00:39:04 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-12-12 02:16:47 +08:00
|
|
|
#include "gimpoldpreview.h"
|
2000-05-02 01:01:18 +08:00
|
|
|
|
2000-05-23 21:00:40 +08:00
|
|
|
#define SCALE_WIDTH 125
|
2000-01-15 01:06:35 +08:00
|
|
|
#define TILE_CACHE_SIZE 16
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
gint independent;
|
|
|
|
gdouble noise[4]; /* per channel */
|
|
|
|
} NoisifyVals;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2000-02-04 23:12:17 +08:00
|
|
|
gint channels;
|
|
|
|
GtkObject *channel_adj[4];
|
1997-11-25 06:05:25 +08:00
|
|
|
} NoisifyInterface;
|
|
|
|
|
|
|
|
/* Declare local functions.
|
|
|
|
*/
|
2000-05-23 21:00:40 +08:00
|
|
|
static void query (void);
|
2003-07-02 08:15:09 +08:00
|
|
|
static void run (const gchar *name,
|
2003-12-11 06:50:26 +08:00
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals);
|
2003-07-02 08:15:09 +08:00
|
|
|
|
|
|
|
static void noisify (GimpDrawable *drawable,
|
|
|
|
gboolean preview_mode);
|
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
|
|
|
static gdouble gauss (GRand *gr);
|
2000-05-23 21:00:40 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
static gint noisify_dialog (GimpDrawable *drawable,
|
2003-12-11 06:50:26 +08:00
|
|
|
gint channels);
|
2000-05-23 21:00:40 +08:00
|
|
|
static void noisify_double_adjustment_update (GtkAdjustment *adjustment,
|
2003-12-11 06:50:26 +08:00
|
|
|
gpointer data);
|
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-01-15 01:06:35 +08:00
|
|
|
NULL, /* init_proc */
|
|
|
|
NULL, /* quit_proc */
|
|
|
|
query, /* query_proc */
|
|
|
|
run, /* run_proc */
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static NoisifyVals nvals =
|
|
|
|
{
|
|
|
|
TRUE,
|
2004-06-22 04:42:55 +08:00
|
|
|
{ 0.20, 0.20, 0.20, 0.0 }
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static NoisifyInterface noise_int =
|
|
|
|
{
|
2000-02-04 23:12:17 +08:00
|
|
|
0,
|
2003-11-06 23:27:05 +08:00
|
|
|
{ NULL, NULL, NULL, NULL }
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
2003-12-11 06:50:26 +08:00
|
|
|
static GimpRunMode run_mode;
|
|
|
|
static GimpOldPreview *preview;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
MAIN ()
|
|
|
|
|
|
|
|
static void
|
2000-01-11 23:48:00 +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
|
|
|
{
|
2004-05-07 21:15:52 +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_INT32, "independent", "Noise in channels independent" },
|
|
|
|
{ GIMP_PDB_FLOAT, "noise_1", "Noise in the first channel (red, gray)" },
|
|
|
|
{ GIMP_PDB_FLOAT, "noise_2", "Noise in the second channel (green, gray_alpha)" },
|
|
|
|
{ GIMP_PDB_FLOAT, "noise_3", "Noise in the third channel (blue)" },
|
|
|
|
{ GIMP_PDB_FLOAT, "noise_4", "Noise in the fourth channel (alpha)" }
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
gimp_install_procedure ("plug_in_noisify",
|
2003-12-11 06:50:26 +08:00
|
|
|
"Adds random noise to a drawable's channels",
|
|
|
|
"More here later",
|
|
|
|
"Torsten Martinsen",
|
|
|
|
"Torsten Martinsen",
|
|
|
|
"May 2000",
|
2004-06-22 04:42:55 +08:00
|
|
|
N_("_Scatter RGB..."),
|
2003-12-11 06:50:26 +08:00
|
|
|
"RGB*, GRAY*",
|
|
|
|
GIMP_PLUGIN,
|
|
|
|
G_N_ELEMENTS (args), 0,
|
|
|
|
args, NULL);
|
2004-05-07 21:15:52 +08:00
|
|
|
|
|
|
|
gimp_plugin_menu_register ("plug_in_noisify",
|
|
|
|
N_("<Image>/Filters/Noise"));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-07-02 08:15:09 +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
|
|
|
{
|
2001-12-31 08:21:10 +08:00
|
|
|
static GimpParam values[1];
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
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;
|
2001-12-31 08:21:10 +08:00
|
|
|
*return_vals = values;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-12-31 08:21:10 +08:00
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
1997-11-25 06:05:25 +08:00
|
|
|
values[0].data.d_status = status;
|
|
|
|
|
|
|
|
/* Get the specified drawable */
|
|
|
|
drawable = gimp_drawable_get (param[2].data.d_drawable);
|
|
|
|
|
2004-06-22 04:42:55 +08:00
|
|
|
if (gimp_drawable_is_gray (drawable->drawable_id))
|
|
|
|
nvals.noise[1] = 0.;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
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_noisify", &nvals);
|
|
|
|
|
|
|
|
/* First acquire information with a dialog */
|
2000-05-23 21:00:40 +08:00
|
|
|
if (! noisify_dialog (drawable, drawable->bpp))
|
2003-12-11 06:50:26 +08:00
|
|
|
{
|
|
|
|
gimp_drawable_detach (drawable);
|
|
|
|
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! */
|
|
|
|
if (nparams != 8)
|
2003-12-11 06:50:26 +08:00
|
|
|
{
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
}
|
2000-02-04 23:12:17 +08:00
|
|
|
else
|
2003-12-11 06:50:26 +08:00
|
|
|
{
|
|
|
|
nvals.independent = param[3].data.d_int32 ? TRUE : FALSE;
|
|
|
|
nvals.noise[0] = param[4].data.d_float;
|
|
|
|
nvals.noise[1] = param[5].data.d_float;
|
|
|
|
nvals.noise[2] = param[6].data.d_float;
|
|
|
|
nvals.noise[3] = param[7].data.d_float;
|
|
|
|
}
|
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_noisify", &nvals);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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-01-11 23:48:00 +08:00
|
|
|
gimp_progress_init (_("Adding Noise..."));
|
1997-11-25 06:05:25 +08:00
|
|
|
gimp_tile_cache_ntiles (TILE_CACHE_SIZE);
|
|
|
|
|
|
|
|
/* compute the luminosity which exceeds the luminosity threshold */
|
2000-05-23 21:00:40 +08:00
|
|
|
noisify (drawable, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
if (run_mode != GIMP_RUN_NONINTERACTIVE)
|
2003-12-11 06:50:26 +08:00
|
|
|
gimp_displays_flush ();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Store data */
|
2000-08-22 09:26:57 +08:00
|
|
|
if (run_mode == GIMP_RUN_INTERACTIVE) {
|
2003-12-11 06:50:26 +08:00
|
|
|
gimp_set_data ("plug_in_noisify", &nvals, sizeof (NoisifyVals));
|
2000-05-23 21:00:40 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-05-23 21:00:40 +08:00
|
|
|
/* gimp_message ("blur: cannot operate on indexed color images"); ??? BLUR ??? */
|
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);
|
|
|
|
}
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
static void
|
2003-07-02 08:15:09 +08:00
|
|
|
noisify_func (const guchar *src,
|
2003-12-11 06:50:26 +08:00
|
|
|
guchar *dest,
|
|
|
|
gint bpp,
|
|
|
|
gpointer data)
|
2000-05-27 05:23:03 +08:00
|
|
|
{
|
2003-02-02 06:26:34 +08:00
|
|
|
GRand *gr = (GRand*) data;
|
2002-12-16 04:31:07 +08:00
|
|
|
gint noise = 0, b;
|
|
|
|
|
|
|
|
if (!nvals.independent)
|
|
|
|
noise = (gint) (nvals.noise[0] * gauss (gr) * 127);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2002-12-16 04:31:07 +08:00
|
|
|
for (b = 0; b < bpp; b++)
|
2000-05-27 05:23:03 +08:00
|
|
|
{
|
2002-12-16 04:31:07 +08:00
|
|
|
if (nvals.noise[b] > 0.0)
|
2003-12-11 06:50:26 +08:00
|
|
|
{
|
|
|
|
gint p;
|
2002-12-16 20:19:22 +08:00
|
|
|
|
2004-06-22 04:42:55 +08:00
|
|
|
if (nvals.independent || (b == 1 && bpp == 2) || (b == 3 && bpp == 4))
|
2003-12-11 06:50:26 +08:00
|
|
|
noise = (gint) (nvals.noise[b] * gauss (gr) * 127);
|
2002-12-16 04:31:07 +08:00
|
|
|
|
2003-12-11 06:50:26 +08:00
|
|
|
p = src[b] + noise;
|
|
|
|
dest[b] = CLAMP0255 (p);
|
|
|
|
}
|
2000-05-27 05:23:03 +08:00
|
|
|
else
|
2002-12-16 20:19:22 +08:00
|
|
|
{
|
|
|
|
dest[b] = src[b];
|
|
|
|
}
|
2000-05-27 05:23:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
2003-11-06 23:27:05 +08:00
|
|
|
noisify (GimpDrawable *drawable,
|
2003-12-11 06:50:26 +08:00
|
|
|
gboolean preview_mode)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-05-19 01:06:06 +08:00
|
|
|
GRand *gr = g_rand_new ();
|
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
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
if (preview_mode)
|
2003-12-11 06:50:26 +08:00
|
|
|
gimp_old_preview_update (preview, noisify_func, gr);
|
2003-11-06 23:27:05 +08:00
|
|
|
else
|
2003-02-02 06:26:34 +08:00
|
|
|
gimp_rgn_iterate2 (drawable, run_mode, noisify_func, gr);
|
2000-05-23 21:00:40 +08:00
|
|
|
|
2002-12-16 04:31:07 +08:00
|
|
|
g_rand_free (gr);
|
|
|
|
}
|
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
|
|
|
|
2002-12-16 04:31:07 +08:00
|
|
|
static void
|
2003-11-06 23:27:05 +08:00
|
|
|
noisify_add_channel (GtkWidget *table, gint channel, gchar *name,
|
2003-12-11 06:50:26 +08:00
|
|
|
GimpDrawable *drawable)
|
2002-12-16 04:31:07 +08:00
|
|
|
{
|
|
|
|
GtkObject *adj;
|
|
|
|
|
|
|
|
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, channel + 1,
|
2003-12-11 06:50:26 +08:00
|
|
|
name, SCALE_WIDTH, 0,
|
|
|
|
nvals.noise[channel], 0.0, 1.0, 0.01, 0.1, 2,
|
|
|
|
TRUE, 0, 0,
|
|
|
|
NULL, NULL);
|
2002-12-16 04:31:07 +08:00
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (adj), "drawable", drawable);
|
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (adj, "value_changed",
|
2003-12-11 06:50:26 +08:00
|
|
|
G_CALLBACK (noisify_double_adjustment_update),
|
|
|
|
&nvals.noise[channel]);
|
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
|
|
|
|
2002-12-16 04:31:07 +08:00
|
|
|
noise_int.channel_adj[channel] = adj;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2004-06-22 04:42:55 +08:00
|
|
|
static void
|
|
|
|
noisify_add_alpha_channel (GtkWidget *table, gint channel, gchar *name,
|
|
|
|
GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
GtkObject *adj;
|
|
|
|
|
|
|
|
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, channel + 1,
|
|
|
|
name, SCALE_WIDTH, 0,
|
|
|
|
nvals.noise[channel], 0.0, 1.0, 0.01, 0.1, 2,
|
|
|
|
TRUE, 0, 0,
|
|
|
|
NULL, NULL);
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (adj), "drawable", drawable);
|
|
|
|
|
|
|
|
g_signal_connect (adj, "value_changed",
|
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
|
|
|
&nvals.noise[channel]);
|
|
|
|
|
|
|
|
noise_int.channel_adj[channel] = adj;
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static gint
|
2003-11-06 23:27:05 +08:00
|
|
|
noisify_dialog (GimpDrawable *drawable,
|
2003-12-11 06:50:26 +08:00
|
|
|
gint channels)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
GtkWidget *dlg;
|
2004-05-19 01:06:06 +08:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
1997-11-25 06:05:25 +08:00
|
|
|
GtkWidget *toggle;
|
|
|
|
GtkWidget *table;
|
2003-11-06 23:27:05 +08:00
|
|
|
gboolean run;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-02 01:01:18 +08:00
|
|
|
gimp_ui_init ("noisify", FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-06-22 04:42:55 +08:00
|
|
|
dlg = gimp_dialog_new (_("Scatter RGB"), "noisify",
|
2003-11-06 23:27:05 +08:00
|
|
|
NULL, 0,
|
2004-01-21 01:10:16 +08:00
|
|
|
gimp_standard_help_func, "plug-in-noisify",
|
2000-01-07 18:39:33 +08:00
|
|
|
|
2003-12-11 06:50:26 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
2000-01-07 18:39:33 +08:00
|
|
|
|
2003-12-11 06:50:26 +08:00
|
|
|
NULL);
|
2000-01-07 18:39:33 +08:00
|
|
|
|
2004-05-19 01:06:06 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 12);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), vbox, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (vbox);
|
2000-05-23 21:00:40 +08:00
|
|
|
|
|
|
|
/* preview */
|
2004-05-19 01:06:06 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
preview = gimp_old_preview_new (NULL);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), preview->frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (preview->frame);
|
2003-12-11 06:50:26 +08:00
|
|
|
gimp_old_preview_fill (preview, drawable);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2004-05-19 01:06:06 +08:00
|
|
|
noisify (drawable, TRUE); /* preview noisify */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-06-22 04:42:55 +08:00
|
|
|
if (gimp_drawable_is_rgb (drawable->drawable_id))
|
|
|
|
{
|
|
|
|
toggle = gtk_check_button_new_with_mnemonic (_("_Independent RGB"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), nvals.independent);
|
|
|
|
gtk_widget_show (toggle);
|
|
|
|
|
|
|
|
g_signal_connect (toggle, "toggled",
|
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
&nvals.independent);
|
|
|
|
}
|
2001-12-31 08:21:10 +08:00
|
|
|
|
2004-05-19 01:06:06 +08:00
|
|
|
table = gtk_table_new (channels, 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 (vbox), table, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
2000-02-04 23:12:17 +08:00
|
|
|
noise_int.channels = channels;
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
if (channels == 1)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-12-16 04:31:07 +08:00
|
|
|
noisify_add_channel (table, 0, _("_Gray:"), drawable);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else if (channels == 2)
|
|
|
|
{
|
2002-12-16 04:31:07 +08:00
|
|
|
noisify_add_channel (table, 0, _("_Gray:"), drawable);
|
2004-06-22 04:42:55 +08:00
|
|
|
noisify_add_alpha_channel (table, 1, _("_Alpha:"), drawable);
|
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (table), 1, 15);
|
2003-11-06 23:27:05 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
else if (channels == 3)
|
|
|
|
{
|
2002-12-16 04:31:07 +08:00
|
|
|
noisify_add_channel (table, 0, _("_Red:"), drawable);
|
|
|
|
noisify_add_channel (table, 1, _("_Green:"), drawable);
|
|
|
|
noisify_add_channel (table, 2, _("_Blue:"), drawable);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
else if (channels == 4)
|
|
|
|
{
|
2002-12-16 04:31:07 +08:00
|
|
|
noisify_add_channel (table, 0, _("_Red:"), drawable);
|
|
|
|
noisify_add_channel (table, 1, _("_Green:"), drawable);
|
|
|
|
noisify_add_channel (table, 2, _("_Blue:"), drawable);
|
2004-06-22 04:42:55 +08:00
|
|
|
noisify_add_alpha_channel (table, 3, _("_Alpha:"), drawable);
|
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (table), 3, 15);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-12-16 04:31:07 +08:00
|
|
|
gchar *buffer;
|
|
|
|
gint i;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
for (i = 0; i < channels; i++)
|
2003-12-11 06:50:26 +08:00
|
|
|
{
|
|
|
|
buffer = g_strdup_printf (_("Channel #%d:"), i);
|
2000-01-15 01:06:35 +08:00
|
|
|
|
2003-12-11 06:50:26 +08:00
|
|
|
noisify_add_channel (table, i, buffer, drawable);
|
2000-01-15 01:06:35 +08:00
|
|
|
|
2003-12-11 06:50:26 +08:00
|
|
|
g_free (buffer);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return a Gaussian (aka normal) random variable.
|
|
|
|
*
|
|
|
|
* Adapted from ppmforge.c, which is part of PBMPLUS.
|
|
|
|
* The algorithm comes from:
|
|
|
|
* 'The Science Of Fractal Images'. Peitgen, H.-O., and Saupe, D. eds.
|
|
|
|
* Springer Verlag, New York, 1988.
|
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
|
|
|
*
|
2003-11-06 23:27:05 +08:00
|
|
|
* It would probably be better to use another algorithm, such as that
|
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
|
|
|
* in Knuth
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
|
|
|
static gdouble
|
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
|
|
|
gauss (GRand *gr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
gdouble sum = 0.0;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
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
|
|
|
sum += g_rand_int_range (gr, 0, 0x7FFF);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return sum * 5.28596089837e-5 - 3.46410161514;
|
|
|
|
}
|
|
|
|
|
2000-02-04 23:12:17 +08:00
|
|
|
static void
|
|
|
|
noisify_double_adjustment_update (GtkAdjustment *adjustment,
|
2003-12-11 06:50:26 +08:00
|
|
|
gpointer data)
|
2000-02-04 23:12:17 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
GimpDrawable *drawable;
|
2004-06-22 04:42:55 +08:00
|
|
|
gint n;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2000-02-04 23:12:17 +08:00
|
|
|
gimp_double_adjustment_update (adjustment, data);
|
2001-12-31 08:21:10 +08:00
|
|
|
|
|
|
|
drawable = g_object_get_data (G_OBJECT (adjustment), "drawable");
|
|
|
|
|
2000-05-23 21:00:40 +08:00
|
|
|
noisify (drawable, TRUE);
|
2000-02-04 23:12:17 +08:00
|
|
|
|
|
|
|
if (! nvals.independent)
|
|
|
|
{
|
|
|
|
gint i;
|
2004-06-22 04:42:55 +08:00
|
|
|
switch (noise_int.channels)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
n = 1;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
n = 1;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
n = 3;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
n = 3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
2003-12-11 06:50:26 +08:00
|
|
|
if (adjustment != GTK_ADJUSTMENT (noise_int.channel_adj[i]))
|
|
|
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (noise_int.channel_adj[i]),
|
|
|
|
adjustment->value);
|
2000-02-04 23:12:17 +08:00
|
|
|
}
|
|
|
|
}
|