1998-10-22 19:39:32 +08:00
|
|
|
/*
|
2000-05-24 00:04:02 +08:00
|
|
|
* wind 1.1.0 - a plug-in for the GIMP
|
1998-10-22 19:39:32 +08:00
|
|
|
*
|
|
|
|
* Copyright (C) Nigel Wetten
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* Contact info: nigel@cs.nwu.edu
|
|
|
|
* Version: 1.0.0
|
2000-05-24 00:04:02 +08:00
|
|
|
*
|
|
|
|
* Version: 1.1.0
|
|
|
|
* May 2000 tim copperfield [timecop@japan.co.jp]
|
|
|
|
*
|
|
|
|
* Added dynamic preview.
|
|
|
|
*
|
1998-10-22 19:39:32 +08:00
|
|
|
*/
|
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1998-10-22 19:39:32 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2000-10-01 04:13:06 +08:00
|
|
|
#include <string.h>
|
1998-10-22 19:39:32 +08:00
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
2000-01-09 04:00:10 +08:00
|
|
|
|
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2000-01-16 01:22:19 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
1998-10-22 19:39:32 +08:00
|
|
|
|
|
|
|
|
|
|
|
#define PLUG_IN_NAME "wind"
|
|
|
|
|
2000-01-15 23:32:28 +08:00
|
|
|
#define COMPARE_WIDTH 3
|
1998-10-22 19:39:32 +08:00
|
|
|
|
2000-01-09 04:00:10 +08:00
|
|
|
#define SCALE_WIDTH 200
|
|
|
|
#define MIN_THRESHOLD 0
|
|
|
|
#define MAX_THRESHOLD 50
|
|
|
|
#define MIN_STRENGTH 1
|
|
|
|
#define MAX_STRENGTH 50
|
1998-10-22 19:39:32 +08:00
|
|
|
|
2000-01-09 04:00:10 +08:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
LEFT,
|
|
|
|
RIGHT
|
|
|
|
} direction_t;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
RENDER_WIND,
|
|
|
|
RENDER_BLAST
|
|
|
|
} algorithm_t;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
BOTH,
|
|
|
|
LEADING,
|
|
|
|
TRAILING
|
|
|
|
} edge_t;
|
|
|
|
|
1998-10-22 19:39:32 +08:00
|
|
|
|
2000-01-09 04:00:10 +08:00
|
|
|
static void query (void);
|
2003-07-02 21:00:16 +08:00
|
|
|
static void run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals);
|
1998-10-22 19:39:32 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
static gint dialog_box (GimpDrawable *drawable);
|
|
|
|
static void radio_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
|
|
|
|
static gint render_effect (GimpDrawable *drawable,
|
|
|
|
gboolean preview_mode);
|
|
|
|
static void render_wind (GimpDrawable *drawable,
|
|
|
|
gint threshold,
|
|
|
|
gint strength,
|
|
|
|
direction_t direction,
|
|
|
|
edge_t edge,
|
|
|
|
gboolean preview_mode);
|
|
|
|
static void render_blast (GimpDrawable *drawable,
|
|
|
|
gint threshold,
|
|
|
|
gint strength,
|
|
|
|
direction_t direction,
|
|
|
|
edge_t edge,
|
|
|
|
gboolean preview_mode);
|
|
|
|
static gint render_blast_row (guchar *buffer,
|
|
|
|
gint bytes,
|
|
|
|
gint lpi,
|
|
|
|
gint threshold,
|
|
|
|
gint strength,
|
|
|
|
edge_t edge);
|
|
|
|
static void render_wind_row (guchar *sb,
|
|
|
|
gint bytes,
|
|
|
|
gint lpi,
|
|
|
|
gint threshold,
|
|
|
|
gint strength,
|
|
|
|
edge_t edge);
|
|
|
|
|
|
|
|
|
|
|
|
static void get_derivative (guchar *pixel_R1,
|
|
|
|
guchar *pixel_R2,
|
|
|
|
edge_t edge,
|
|
|
|
gboolean has_alpha,
|
|
|
|
gint *derivative_R,
|
|
|
|
gint *derivative_G,
|
|
|
|
gint *derivative_B,
|
|
|
|
gint *derivative_A);
|
|
|
|
static gint threshold_exceeded (guchar *pixel_R1,
|
|
|
|
guchar *pixel_R2,
|
|
|
|
edge_t edge,
|
|
|
|
gint threshold,
|
|
|
|
gboolean has_alpha);
|
|
|
|
static void reverse_buffer (guchar *buffer,
|
|
|
|
gint length,
|
|
|
|
gint bytes);
|
2000-05-24 00:04:02 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
GimpPlugInInfo PLUG_IN_INFO =
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
2000-05-02 04:22:55 +08:00
|
|
|
NULL, /* init_proc */
|
|
|
|
NULL, /* quit_proc */
|
|
|
|
query, /* query_proc */
|
|
|
|
run /* run_proc */
|
1998-10-22 19:39:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
Globals
|
|
|
|
*******************/
|
|
|
|
|
|
|
|
struct config_tag
|
|
|
|
{
|
2000-01-15 23:32:28 +08:00
|
|
|
gint threshold; /* derivative comparison for edge detection */
|
1998-10-22 19:39:32 +08:00
|
|
|
direction_t direction; /* of wind, LEFT or RIGHT */
|
2000-01-15 23:32:28 +08:00
|
|
|
gint strength; /* how many pixels to bleed */
|
1998-10-22 19:39:32 +08:00
|
|
|
algorithm_t alg; /* which algorithm */
|
2000-05-24 00:04:02 +08:00
|
|
|
edge_t edge; /* controls abs, ne+ static guchar *preview_bits;
|
|
|
|
+ static GtkWidget *preview;
|
|
|
|
gation of derivative */
|
1998-10-22 19:39:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct config_tag config_t;
|
|
|
|
config_t config =
|
|
|
|
{
|
|
|
|
10, /* threshold for derivative edge detection */
|
|
|
|
LEFT, /* bleed to the right */
|
|
|
|
10, /* how many pixels to bleed */
|
|
|
|
RENDER_WIND, /* default algorithm */
|
|
|
|
LEADING /* abs(derivative); */
|
|
|
|
};
|
|
|
|
|
2002-12-02 04:56:01 +08:00
|
|
|
static GimpFixMePreview *preview;
|
1998-10-22 19:39:32 +08:00
|
|
|
|
2000-05-02 04:22:55 +08:00
|
|
|
MAIN ()
|
1998-10-22 19:39:32 +08:00
|
|
|
|
|
|
|
static void
|
2000-01-09 04:00:10 +08:00
|
|
|
query (void)
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
static GimpParamDef args[] =
|
1998-10-22 19:39:32 +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_INT32, "threshold", "Controls where blending will be done >= 0" },
|
|
|
|
{ GIMP_PDB_INT32, "direction", "Left or Right: 0 or 1" },
|
|
|
|
{ GIMP_PDB_INT32, "strength", "Controls the extent of the blending > 1" },
|
|
|
|
{ GIMP_PDB_INT32, "alg", "WIND, BLAST" },
|
|
|
|
{ GIMP_PDB_INT32, "edge", "LEADING, TRAILING, or BOTH" }
|
1998-10-22 19:39:32 +08:00
|
|
|
};
|
2000-01-16 01:22:19 +08:00
|
|
|
|
2000-01-15 23:32:28 +08:00
|
|
|
gimp_install_procedure ("plug_in_wind",
|
2000-01-31 10:32:30 +08:00
|
|
|
"Renders a wind effect.",
|
|
|
|
"Renders a wind effect.",
|
2000-01-15 23:32:28 +08:00
|
|
|
"Nigel Wetten",
|
|
|
|
"Nigel Wetten",
|
2000-05-24 00:04:02 +08:00
|
|
|
"May 2000",
|
2003-07-17 23:47:18 +08:00
|
|
|
N_("<Image>/Filters/Distorts/Wi_nd..."),
|
2000-01-15 23:32:28 +08:00
|
|
|
"RGB*",
|
2000-08-22 09:26:57 +08:00
|
|
|
GIMP_PLUGIN,
|
2001-12-06 10:28:58 +08:00
|
|
|
G_N_ELEMENTS (args), 0,
|
2000-02-04 23:12:17 +08:00
|
|
|
args, NULL);
|
2000-01-09 04:00:10 +08:00
|
|
|
}
|
1998-10-22 19:39:32 +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)
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
2002-01-16 02:35:29 +08:00
|
|
|
static GimpParam values[1];
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
GimpRunMode run_mode;
|
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
1998-10-22 19:39:32 +08:00
|
|
|
|
|
|
|
run_mode = param[0].data.d_int32;
|
2002-01-16 02:35:29 +08:00
|
|
|
drawable = gimp_drawable_get (param[2].data.d_drawable);
|
|
|
|
gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width () + 1));
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
INIT_I18N ();
|
|
|
|
|
1998-10-22 19:39:32 +08:00
|
|
|
switch (run_mode)
|
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_NONINTERACTIVE:
|
2000-02-04 23:12:17 +08:00
|
|
|
if (nparams != 8)
|
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
2000-02-04 23:12:17 +08:00
|
|
|
}
|
|
|
|
else
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
|
|
|
config.threshold = param[3].data.d_int32;
|
|
|
|
config.direction = param[4].data.d_int32;
|
|
|
|
config.strength = param[5].data.d_int32;
|
|
|
|
config.alg = param[6].data.d_int32;
|
|
|
|
config.edge = param[7].data.d_int32;
|
2000-02-04 23:12:17 +08:00
|
|
|
|
2000-05-24 00:04:02 +08:00
|
|
|
if (render_effect(drawable, 0) == -1)
|
2000-08-22 09:26:57 +08:00
|
|
|
status = GIMP_PDB_EXECUTION_ERROR;
|
1998-10-22 19:39:32 +08:00
|
|
|
}
|
|
|
|
break;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_INTERACTIVE:
|
1998-10-22 19:39:32 +08:00
|
|
|
gimp_get_data("plug_in_wind", &config);
|
2003-11-06 23:27:05 +08:00
|
|
|
if (! dialog_box (drawable))
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
status = GIMP_PDB_CANCEL;
|
1998-10-22 19:39:32 +08:00
|
|
|
break;
|
|
|
|
}
|
2000-05-24 00:04:02 +08:00
|
|
|
if (render_effect(drawable, 0) == -1)
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
1998-10-22 19:39:32 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
gimp_set_data("plug_in_wind", &config, sizeof(config_t));
|
|
|
|
gimp_displays_flush();
|
|
|
|
break;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_WITH_LAST_VALS:
|
1998-10-22 19:39:32 +08:00
|
|
|
gimp_get_data("plug_in_wind", &config);
|
2000-05-24 00:04:02 +08:00
|
|
|
if (render_effect (drawable, FALSE) == -1)
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
status = GIMP_PDB_EXECUTION_ERROR;
|
1998-10-22 19:39:32 +08:00
|
|
|
gimp_message("An execution error occured.");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-05-24 00:04:02 +08:00
|
|
|
gimp_displays_flush ();
|
1998-10-22 19:39:32 +08:00
|
|
|
}
|
2000-01-09 04:00:10 +08:00
|
|
|
}
|
2003-11-06 23:27:05 +08:00
|
|
|
|
1998-10-22 19:39:32 +08:00
|
|
|
gimp_drawable_detach(drawable);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
1998-10-22 19:39:32 +08:00
|
|
|
*nreturn_vals = 1;
|
|
|
|
*return_vals = values;
|
2000-08-22 09:26:57 +08:00
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
1998-10-22 19:39:32 +08:00
|
|
|
values[0].data.d_status = status;
|
2000-01-09 04:00:10 +08:00
|
|
|
}
|
1998-10-22 19:39:32 +08:00
|
|
|
|
|
|
|
static gint
|
2003-11-06 23:27:05 +08:00
|
|
|
render_effect (GimpDrawable *drawable,
|
2003-07-02 21:00:16 +08:00
|
|
|
gboolean preview_mode)
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
|
|
|
if (config.alg == RENDER_WIND)
|
|
|
|
{
|
2000-05-24 00:04:02 +08:00
|
|
|
render_wind (drawable, config.threshold, config.strength,
|
|
|
|
config.direction, config.edge, preview_mode);
|
1998-10-22 19:39:32 +08:00
|
|
|
}
|
|
|
|
else if (config.alg == RENDER_BLAST)
|
|
|
|
{
|
2000-05-24 00:04:02 +08:00
|
|
|
render_blast (drawable, config.threshold, config.strength,
|
|
|
|
config.direction, config.edge, preview_mode);
|
1998-10-22 19:39:32 +08:00
|
|
|
}
|
|
|
|
return 0;
|
2000-01-09 04:00:10 +08:00
|
|
|
}
|
1998-10-22 19:39:32 +08:00
|
|
|
|
|
|
|
static void
|
2003-07-02 21:00:16 +08:00
|
|
|
render_blast (GimpDrawable *drawable,
|
|
|
|
gint threshold,
|
|
|
|
gint strength,
|
|
|
|
direction_t direction,
|
|
|
|
edge_t edge,
|
|
|
|
gboolean preview_mode)
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
|
|
|
gint x1, x2, y1, y2;
|
2000-01-18 06:12:45 +08:00
|
|
|
gint width;
|
|
|
|
gint height;
|
1998-10-22 19:39:32 +08:00
|
|
|
gint bytes = drawable->bpp;
|
|
|
|
guchar *buffer;
|
2000-08-22 09:26:57 +08:00
|
|
|
GimpPixelRgn src_region, dest_region;
|
1998-10-22 19:39:32 +08:00
|
|
|
gint row;
|
2000-01-18 06:12:45 +08:00
|
|
|
gint row_stride;
|
1998-10-22 19:39:32 +08:00
|
|
|
gint marker = 0;
|
2000-01-18 06:12:45 +08:00
|
|
|
gint lpi;
|
2000-05-25 07:01:48 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
if (preview_mode)
|
2000-05-24 00:04:02 +08:00
|
|
|
{
|
2002-12-02 04:56:01 +08:00
|
|
|
width = preview->width;
|
|
|
|
height = preview->height;
|
|
|
|
bytes = preview->bpp;
|
2000-05-24 00:04:02 +08:00
|
|
|
|
|
|
|
x1 = y1 = 0;
|
|
|
|
x2 = width;
|
|
|
|
y2 = height;
|
2000-05-24 02:52:14 +08:00
|
|
|
|
2002-12-02 04:56:01 +08:00
|
|
|
row_stride = preview->rowstride;
|
2003-11-06 23:27:05 +08:00
|
|
|
}
|
|
|
|
else
|
2000-05-24 00:04:02 +08:00
|
|
|
{
|
2003-06-13 22:37:00 +08:00
|
|
|
gimp_progress_init (_("Rendering Blast..."));
|
2001-06-15 04:07:38 +08:00
|
|
|
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
2000-05-24 02:52:14 +08:00
|
|
|
|
2000-05-24 00:04:02 +08:00
|
|
|
width = x2 - x1;
|
|
|
|
height = y2 - y1;
|
2000-05-24 02:52:14 +08:00
|
|
|
|
2000-05-24 00:04:02 +08:00
|
|
|
gimp_pixel_rgn_init (&src_region, drawable, x1, y1, width, height, FALSE, FALSE);
|
|
|
|
gimp_pixel_rgn_init (&dest_region, drawable, x1, y1, width, height, TRUE, TRUE);
|
2000-05-24 02:52:14 +08:00
|
|
|
|
|
|
|
row_stride = width * bytes;
|
2000-05-24 00:04:02 +08:00
|
|
|
}
|
1998-10-22 19:39:32 +08:00
|
|
|
|
2000-01-18 06:12:45 +08:00
|
|
|
lpi = row_stride - bytes;
|
|
|
|
|
2000-05-24 02:52:14 +08:00
|
|
|
buffer = (guchar *) g_malloc (row_stride);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
1998-10-22 19:39:32 +08:00
|
|
|
for (row = y1; row < y2; row++)
|
|
|
|
{
|
2000-05-24 00:04:02 +08:00
|
|
|
if (preview_mode)
|
2002-12-02 04:56:01 +08:00
|
|
|
memcpy (buffer, preview->cache + (row * row_stride), row_stride);
|
2000-05-24 00:04:02 +08:00
|
|
|
else
|
|
|
|
gimp_pixel_rgn_get_row (&src_region, buffer, x1, row, width);
|
2000-01-18 06:12:45 +08:00
|
|
|
|
1998-10-22 19:39:32 +08:00
|
|
|
if (direction == RIGHT)
|
|
|
|
{
|
2000-01-18 06:12:45 +08:00
|
|
|
reverse_buffer (buffer, row_stride, bytes);
|
1998-10-22 19:39:32 +08:00
|
|
|
}
|
2000-01-18 06:12:45 +08:00
|
|
|
|
|
|
|
marker = render_blast_row (buffer, bytes, lpi, threshold, strength, edge);
|
|
|
|
|
1998-10-22 19:39:32 +08:00
|
|
|
if (direction == RIGHT)
|
|
|
|
{
|
2000-01-18 06:12:45 +08:00
|
|
|
reverse_buffer (buffer, row_stride, bytes);
|
1998-10-22 19:39:32 +08:00
|
|
|
}
|
2000-01-18 06:12:45 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
if (preview_mode)
|
2000-05-24 00:04:02 +08:00
|
|
|
{
|
2002-12-02 04:56:01 +08:00
|
|
|
gimp_fixme_preview_do_row(preview, row, width, buffer);
|
2003-11-06 23:27:05 +08:00
|
|
|
}
|
|
|
|
else
|
2000-05-24 00:04:02 +08:00
|
|
|
{
|
|
|
|
gimp_pixel_rgn_set_row (&dest_region, buffer, x1, row, width);
|
|
|
|
gimp_progress_update ((double) (row - y1)/ (double) (height));
|
|
|
|
}
|
2000-01-18 06:12:45 +08:00
|
|
|
|
1998-10-22 19:39:32 +08:00
|
|
|
if (marker)
|
|
|
|
{
|
|
|
|
gint j, limit;
|
2003-11-06 23:27:05 +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
|
|
|
limit = 1 + g_random_int_range (0, 2);
|
1998-10-22 19:39:32 +08:00
|
|
|
for (j = 0; (j < limit) && (row < y2); j++)
|
|
|
|
{
|
|
|
|
row++;
|
|
|
|
if (row < y2)
|
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
if (preview_mode)
|
2000-05-24 00:04:02 +08:00
|
|
|
{
|
2002-12-02 04:56:01 +08:00
|
|
|
memcpy (buffer, preview->cache + (row * row_stride), row_stride);
|
|
|
|
gimp_fixme_preview_do_row(preview, row, width, buffer);
|
2003-11-06 23:27:05 +08:00
|
|
|
}
|
|
|
|
else
|
2000-05-24 00:04:02 +08:00
|
|
|
{
|
|
|
|
gimp_pixel_rgn_get_row (&src_region, buffer, x1, row, width);
|
|
|
|
gimp_pixel_rgn_set_row (&dest_region, buffer, x1, row, width);
|
|
|
|
}
|
1998-10-22 19:39:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
marker = 0;
|
|
|
|
}
|
2000-01-09 04:00:10 +08:00
|
|
|
}
|
2000-01-18 06:12:45 +08:00
|
|
|
|
applied gimp-lecorfec-99041[02]-0, changes follow
* applied gimp-lecorfec-99041[02]-0, changes follow
* plug-ins/FractalExplorer/Dialogs.h (make_color_map):
replaced free with g_free to fix segfault.
* plug-ins/Lighting/lighting_preview.c (compute_preview):
allocate xpostab and ypostab only when needed (it could also be
allocated on stack with a compilation-fixed size like MapObject).
It avoids to lose some Kb on each preview :)
Also reindented (unfortunate C-c C-q) some other lines.
* plug-ins/Lighting/lighting_main.c (run):
release allocated postabs.
* plug-ins/Lighting/lighting_ui.c:
callbacks now have only one argument because gck widget use
gtk_signal_connect_object. Caused segfault for scale widget.
* plug-ins/autocrop/autocrop.c (doit):
return if image has only background (thus fixing a segfault).
* plug-ins/emboss/emboss.c (pluginCore, emboss_do_preview):
replaced malloc/free with g_malloc/g_free (unneeded, but
shouldn't everyone use glib calls ? :)
* plug-ins/flame/flame.c :
replaced a segfaulting free, and several harmless malloc/free pairs.
* plug-ins/flame/megawidget.c (mw_preview_build):
replaced harmless malloc/free pair.
Note : mwp->bits is malloc'ed but seems to be never freed.
* plug-ins/fractaltrace/fractaltrace.c (pixels_free):
replaced a bunch of segfaulting free.
(pixels_get, dialog_show): replaced gtk_signal_connect_object
with gtk_signal_connect to accomodate callbacks (caused STRANGE
dialog behaviour, coz you destroyed buttons one by one).
* plug-ins/illusion/illusion.c (dialog):
same gtk_signal_connect_object replacement for same reasons.
* plug-ins/libgck/gck/gckcolor.c :
changed all gck_rgb_to_color* functions to use a static GdkColor
instead of a malloc'ed area. Provided reentrant functions with
the old behaviour (gck_rgb_to_color*_r). Made some private functions
static, too.
gck_rgb_to_gdkcolor now use the new functions while
gck_rgb_to_gdkcolor_r is the reentrant version.
Also affected by this change: gck_gc_set_foreground and
gck_gc_set_background (no more free(color)).
* plug-ins/libgck/gck/gckcolor.h :
added the gck_rgb_to_gdkcolor_r proto.
* plug-ins/lic/lic.c (ok_button_clicked, cancel_button_clicked) :
segfault on gtk_widget_destroy, now calls gtk_main_quit.
(dialog_destroy) : segfault on window closure when called by
"destroy" event. Now called by "delete_event".
* plug-ins/megawidget/megawidget.c (mw_preview_build):
replaced harmless malloc/free pair.
Note : mwp->bits is malloc'ed but seems to be never freed.
* plug-ins/png/png.c (load_image):
replaced 2 segfaulting free.
* plug-ins/print/print-ps.c (ps_print):
replaced a segfaulting free (called many times :).
* plug-ins/sgi/sgi.c (load_image, save_image):
replaced a bunch of segfaulting free, and did some harmless
inits to avoid a few gcc warnings.
* plug-ins/wind/wind.c (render_wind):
replaced a segfaulting free.
(render_blast): replaced harmless malloc/free pair.
* plug-ins/bmp/bmpread.c (ReadImage):
yet another free()/g_free() problem fixed.
* plug-ins/exchange/exchange.c (real_exchange):
ditto.
* plug-ins/fp/fp.h: added Frames_Check_Button_In_A_Box proto.
* plug-ins/fp/fp_gtk.c: closing subdialogs via window manager
wasn't handled, thus leading to errors and crashes.
Now delete_event signals the dialog control button
to close a dialog with the good way.
* plug-ins/ifscompose/ifscompose.c (value_pair_create):
tried to set events mask on scale widget (a NO_WINDOW widget).
* plug-ins/png/png.c (save_image):
Replaced 2 free() with g_free() for g_malloc'ed memory.
Mysteriously I corrected the loading bug but not the saving one :)
-Yosh
1999-04-16 05:49:09 +08:00
|
|
|
g_free(buffer);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
1998-10-22 19:39:32 +08:00
|
|
|
/* update the region */
|
2003-11-06 23:27:05 +08:00
|
|
|
if (preview_mode)
|
2000-05-24 00:04:02 +08:00
|
|
|
{
|
2002-12-02 04:56:01 +08:00
|
|
|
gtk_widget_queue_draw (preview->widget);
|
2000-05-24 00:04:02 +08:00
|
|
|
}
|
2003-11-06 23:27:05 +08:00
|
|
|
else
|
2000-05-24 00:04:02 +08:00
|
|
|
{
|
|
|
|
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);
|
2000-05-24 00:04:02 +08:00
|
|
|
}
|
2000-01-09 04:00:10 +08:00
|
|
|
}
|
1998-10-22 19:39:32 +08:00
|
|
|
|
|
|
|
static void
|
2003-07-02 21:00:16 +08:00
|
|
|
render_wind (GimpDrawable *drawable,
|
|
|
|
gint threshold,
|
|
|
|
gint strength,
|
|
|
|
direction_t direction,
|
|
|
|
edge_t edge,
|
|
|
|
gboolean preview_mode)
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
GimpPixelRgn src_region, dest_region;
|
2000-01-18 06:12:45 +08:00
|
|
|
gint width;
|
|
|
|
gint height;
|
2000-05-24 00:04:02 +08:00
|
|
|
gint bytes;
|
2000-01-18 06:12:45 +08:00
|
|
|
gint row_stride;
|
|
|
|
gint comp_stride;
|
1998-10-22 19:39:32 +08:00
|
|
|
gint row;
|
|
|
|
guchar *sb;
|
2000-01-18 06:12:45 +08:00
|
|
|
gint lpi;
|
1998-10-22 19:39:32 +08:00
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
if (preview_mode)
|
2000-05-24 00:04:02 +08:00
|
|
|
{
|
2002-12-02 04:56:01 +08:00
|
|
|
width = preview->width;
|
|
|
|
height = preview->height;
|
|
|
|
bytes = preview->bpp;
|
2000-05-24 00:04:02 +08:00
|
|
|
|
|
|
|
x1 = y1 = 0;
|
|
|
|
x2 = width;
|
|
|
|
y2 = height;
|
2000-05-24 02:52:14 +08:00
|
|
|
|
2002-12-02 04:56:01 +08:00
|
|
|
row_stride = preview->rowstride;
|
2003-11-06 23:27:05 +08:00
|
|
|
}
|
|
|
|
else
|
2000-05-24 00:04:02 +08:00
|
|
|
{
|
2003-06-13 22:37:00 +08:00
|
|
|
gimp_progress_init (_("Rendering Wind..."));
|
2001-06-15 04:07:38 +08:00
|
|
|
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
2000-05-24 02:52:14 +08:00
|
|
|
|
2000-05-24 00:04:02 +08:00
|
|
|
bytes = drawable->bpp;
|
|
|
|
width = x2 - x1;
|
|
|
|
height = y2 - y1;
|
2000-05-24 02:52:14 +08:00
|
|
|
|
2000-05-24 00:04:02 +08:00
|
|
|
gimp_pixel_rgn_init (&src_region, drawable, x1, y1, width, height, FALSE, FALSE);
|
|
|
|
gimp_pixel_rgn_init (&dest_region, drawable, x1, y1, width, height, TRUE, TRUE);
|
2000-05-24 02:52:14 +08:00
|
|
|
|
|
|
|
row_stride = width * bytes;
|
2000-05-24 00:04:02 +08:00
|
|
|
}
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2000-01-18 06:12:45 +08:00
|
|
|
comp_stride = bytes * COMPARE_WIDTH;
|
|
|
|
lpi = row_stride - comp_stride;
|
|
|
|
|
|
|
|
sb = g_malloc (row_stride);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
1998-10-22 19:39:32 +08:00
|
|
|
for (row = y1; row < y2; row++)
|
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
if (preview_mode)
|
2002-12-02 04:56:01 +08:00
|
|
|
memcpy (sb, preview->cache + (row * row_stride), row_stride);
|
2003-11-06 23:27:05 +08:00
|
|
|
else
|
2000-05-24 00:04:02 +08:00
|
|
|
gimp_pixel_rgn_get_row (&src_region, sb, x1, row, width);
|
2000-01-18 06:12:45 +08:00
|
|
|
|
1998-10-22 19:39:32 +08:00
|
|
|
if (direction == RIGHT)
|
2000-05-24 00:04:02 +08:00
|
|
|
reverse_buffer (sb, row_stride, bytes);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2000-01-18 06:12:45 +08:00
|
|
|
render_wind_row (sb, bytes, lpi, threshold, strength, edge);
|
|
|
|
|
1998-10-22 19:39:32 +08:00
|
|
|
if (direction == RIGHT)
|
2000-05-24 00:04:02 +08:00
|
|
|
reverse_buffer(sb, row_stride, bytes);
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
if (preview_mode)
|
2000-05-24 00:04:02 +08:00
|
|
|
{
|
2002-12-02 04:56:01 +08:00
|
|
|
gimp_fixme_preview_do_row(preview, row, width, sb);
|
2003-11-06 23:27:05 +08:00
|
|
|
}
|
|
|
|
else
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
2000-05-24 00:04:02 +08:00
|
|
|
gimp_pixel_rgn_set_row (&dest_region, sb, x1, row, width);
|
|
|
|
gimp_progress_update ((double) (row - y1)/ (double) (height));
|
1998-10-22 19:39:32 +08:00
|
|
|
}
|
|
|
|
}
|
2000-01-18 06:12:45 +08:00
|
|
|
|
applied gimp-lecorfec-99041[02]-0, changes follow
* applied gimp-lecorfec-99041[02]-0, changes follow
* plug-ins/FractalExplorer/Dialogs.h (make_color_map):
replaced free with g_free to fix segfault.
* plug-ins/Lighting/lighting_preview.c (compute_preview):
allocate xpostab and ypostab only when needed (it could also be
allocated on stack with a compilation-fixed size like MapObject).
It avoids to lose some Kb on each preview :)
Also reindented (unfortunate C-c C-q) some other lines.
* plug-ins/Lighting/lighting_main.c (run):
release allocated postabs.
* plug-ins/Lighting/lighting_ui.c:
callbacks now have only one argument because gck widget use
gtk_signal_connect_object. Caused segfault for scale widget.
* plug-ins/autocrop/autocrop.c (doit):
return if image has only background (thus fixing a segfault).
* plug-ins/emboss/emboss.c (pluginCore, emboss_do_preview):
replaced malloc/free with g_malloc/g_free (unneeded, but
shouldn't everyone use glib calls ? :)
* plug-ins/flame/flame.c :
replaced a segfaulting free, and several harmless malloc/free pairs.
* plug-ins/flame/megawidget.c (mw_preview_build):
replaced harmless malloc/free pair.
Note : mwp->bits is malloc'ed but seems to be never freed.
* plug-ins/fractaltrace/fractaltrace.c (pixels_free):
replaced a bunch of segfaulting free.
(pixels_get, dialog_show): replaced gtk_signal_connect_object
with gtk_signal_connect to accomodate callbacks (caused STRANGE
dialog behaviour, coz you destroyed buttons one by one).
* plug-ins/illusion/illusion.c (dialog):
same gtk_signal_connect_object replacement for same reasons.
* plug-ins/libgck/gck/gckcolor.c :
changed all gck_rgb_to_color* functions to use a static GdkColor
instead of a malloc'ed area. Provided reentrant functions with
the old behaviour (gck_rgb_to_color*_r). Made some private functions
static, too.
gck_rgb_to_gdkcolor now use the new functions while
gck_rgb_to_gdkcolor_r is the reentrant version.
Also affected by this change: gck_gc_set_foreground and
gck_gc_set_background (no more free(color)).
* plug-ins/libgck/gck/gckcolor.h :
added the gck_rgb_to_gdkcolor_r proto.
* plug-ins/lic/lic.c (ok_button_clicked, cancel_button_clicked) :
segfault on gtk_widget_destroy, now calls gtk_main_quit.
(dialog_destroy) : segfault on window closure when called by
"destroy" event. Now called by "delete_event".
* plug-ins/megawidget/megawidget.c (mw_preview_build):
replaced harmless malloc/free pair.
Note : mwp->bits is malloc'ed but seems to be never freed.
* plug-ins/png/png.c (load_image):
replaced 2 segfaulting free.
* plug-ins/print/print-ps.c (ps_print):
replaced a segfaulting free (called many times :).
* plug-ins/sgi/sgi.c (load_image, save_image):
replaced a bunch of segfaulting free, and did some harmless
inits to avoid a few gcc warnings.
* plug-ins/wind/wind.c (render_wind):
replaced a segfaulting free.
(render_blast): replaced harmless malloc/free pair.
* plug-ins/bmp/bmpread.c (ReadImage):
yet another free()/g_free() problem fixed.
* plug-ins/exchange/exchange.c (real_exchange):
ditto.
* plug-ins/fp/fp.h: added Frames_Check_Button_In_A_Box proto.
* plug-ins/fp/fp_gtk.c: closing subdialogs via window manager
wasn't handled, thus leading to errors and crashes.
Now delete_event signals the dialog control button
to close a dialog with the good way.
* plug-ins/ifscompose/ifscompose.c (value_pair_create):
tried to set events mask on scale widget (a NO_WINDOW widget).
* plug-ins/png/png.c (save_image):
Replaced 2 free() with g_free() for g_malloc'ed memory.
Mysteriously I corrected the loading bug but not the saving one :)
-Yosh
1999-04-16 05:49:09 +08:00
|
|
|
g_free(sb);
|
2000-01-18 06:12:45 +08:00
|
|
|
|
|
|
|
/* update the region */
|
2003-11-06 23:27:05 +08:00
|
|
|
if (preview_mode)
|
2000-05-24 00:04:02 +08:00
|
|
|
{
|
2002-12-02 04:56:01 +08:00
|
|
|
gtk_widget_queue_draw (preview->widget);
|
2003-11-06 23:27:05 +08:00
|
|
|
}
|
|
|
|
else
|
2000-05-24 00:04:02 +08:00
|
|
|
{
|
|
|
|
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);
|
2000-05-24 00:04:02 +08:00
|
|
|
}
|
2000-01-09 04:00:10 +08:00
|
|
|
}
|
1998-10-22 19:39:32 +08:00
|
|
|
|
|
|
|
static gint
|
2000-01-09 04:00:10 +08:00
|
|
|
render_blast_row (guchar *buffer,
|
|
|
|
gint bytes,
|
|
|
|
gint lpi,
|
|
|
|
gint threshold,
|
|
|
|
gint strength,
|
|
|
|
edge_t edge)
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
2000-05-25 07:01:48 +08:00
|
|
|
gint Ri, Gi, Bi, Ai= 0;
|
1998-10-22 19:39:32 +08:00
|
|
|
gint sbi, lbi;
|
|
|
|
gint bleed_length;
|
|
|
|
gint i, j;
|
|
|
|
gint weight, random_factor;
|
|
|
|
gint skip = 0;
|
|
|
|
|
|
|
|
for (j = 0; j < lpi; j += bytes)
|
|
|
|
{
|
|
|
|
Ri = j; Gi = j + 1; Bi = j + 2;
|
2000-05-25 07:01:48 +08:00
|
|
|
|
|
|
|
if(bytes > 3)
|
|
|
|
Ai = j + 3;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2000-05-25 07:01:48 +08:00
|
|
|
if (threshold_exceeded(buffer+Ri, buffer+Ri+bytes, edge, threshold, (bytes > 3)))
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
|
|
|
/* we have found an edge, do bleeding */
|
|
|
|
sbi = Ri;
|
2003-11-06 23:27:05 +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
|
|
|
weight = g_random_int_range (0, 10);
|
|
|
|
if (weight > 5) /* 40% */
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
|
|
|
random_factor = 2;
|
|
|
|
}
|
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
|
|
|
else if (weight > 3) /* 20% */
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
|
|
|
random_factor = 3;
|
|
|
|
}
|
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
|
|
|
else /* 40% */
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
|
|
|
random_factor = 4;
|
|
|
|
}
|
|
|
|
bleed_length = 0;
|
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
|
|
|
switch (g_random_int_range (0, random_factor))
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
|
|
|
case 3:
|
|
|
|
bleed_length += strength;
|
|
|
|
/* fall through to add up multiples of strength */
|
|
|
|
case 2:
|
|
|
|
bleed_length += strength;
|
|
|
|
/* fall through */
|
|
|
|
case 1:
|
|
|
|
bleed_length += strength;
|
|
|
|
/* fall through */
|
|
|
|
case 0:
|
|
|
|
bleed_length += strength;
|
|
|
|
/* fall through */
|
|
|
|
}
|
|
|
|
|
|
|
|
lbi = sbi + bytes * bleed_length;
|
|
|
|
if (lbi > lpi)
|
|
|
|
{
|
|
|
|
lbi = lpi;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = sbi; i < lbi; i += bytes)
|
|
|
|
{
|
|
|
|
buffer[i] = buffer[Ri];
|
|
|
|
buffer[i+1] = buffer[Gi];
|
|
|
|
buffer[i+2] = buffer[Bi];
|
2000-05-25 07:01:48 +08:00
|
|
|
if(bytes > 3)
|
|
|
|
buffer[i+3] = buffer[Ai];
|
1998-10-22 19:39:32 +08:00
|
|
|
}
|
|
|
|
j = lbi - bytes;
|
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
|
|
|
if (g_random_int_range (0, 10) > 7) /* 20% */
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
|
|
|
skip = 1;
|
|
|
|
}
|
2000-01-09 04:00:10 +08:00
|
|
|
}
|
|
|
|
}
|
1998-10-22 19:39:32 +08:00
|
|
|
return skip;
|
2000-01-09 04:00:10 +08:00
|
|
|
}
|
1998-10-22 19:39:32 +08:00
|
|
|
|
|
|
|
static void
|
2000-01-09 04:00:10 +08:00
|
|
|
render_wind_row (guchar *sb,
|
|
|
|
gint bytes,
|
|
|
|
gint lpi,
|
|
|
|
gint threshold,
|
|
|
|
gint strength,
|
|
|
|
edge_t edge)
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
|
|
|
gint i, j;
|
|
|
|
gint bleed_length;
|
2000-05-25 07:01:48 +08:00
|
|
|
gint blend_amt_R, blend_amt_G, blend_amt_B, blend_amt_A = 0 ;
|
|
|
|
gint blend_colour_R, blend_colour_G, blend_colour_B, blend_colour_A = 0 ;
|
|
|
|
gint target_colour_R, target_colour_G, target_colour_B, target_colour_A = 0;
|
1998-10-22 19:39:32 +08:00
|
|
|
gdouble bleed_length_max;
|
|
|
|
gint bleed_variation;
|
|
|
|
gint n;
|
|
|
|
gint sbi; /* starting bleed index */
|
|
|
|
gint lbi; /* last bleed index */
|
|
|
|
gdouble denominator;
|
|
|
|
gint comp_stride = bytes * COMPARE_WIDTH;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
1998-10-22 19:39:32 +08:00
|
|
|
for (j = 0; j < lpi; j += bytes)
|
|
|
|
{
|
|
|
|
gint Ri = j;
|
|
|
|
gint Gi = j + 1;
|
|
|
|
gint Bi = j + 2;
|
2000-05-25 07:01:48 +08:00
|
|
|
gint Ai = 0;
|
|
|
|
|
|
|
|
if(bytes > 3)
|
|
|
|
Ai = j + 3;
|
1998-10-22 19:39:32 +08:00
|
|
|
|
2000-05-25 07:01:48 +08:00
|
|
|
if (threshold_exceeded(sb+Ri, sb+Ri+comp_stride, edge, threshold,(bytes > 3)))
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
|
|
|
/* we have found an edge, do bleeding */
|
|
|
|
sbi = Ri + comp_stride;
|
|
|
|
blend_colour_R = sb[Ri];
|
|
|
|
blend_colour_G = sb[Gi];
|
|
|
|
blend_colour_B = sb[Bi];
|
|
|
|
target_colour_R = sb[sbi];
|
|
|
|
target_colour_G = sb[sbi+1];
|
|
|
|
target_colour_B = sb[sbi+2];
|
|
|
|
bleed_length_max = strength;
|
|
|
|
|
2000-05-25 07:01:48 +08:00
|
|
|
if(bytes > 3)
|
|
|
|
{
|
|
|
|
blend_colour_A = sb[Ai];
|
|
|
|
target_colour_A = sb[sbi+3];
|
|
|
|
}
|
|
|
|
|
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
|
|
|
if (g_random_int_range (0, 3)) /* introduce weighted randomness */
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
|
|
|
bleed_length_max = strength;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bleed_length_max = 4 * strength;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
bleed_variation = 1 + (gint) (bleed_length_max * g_random_double ());
|
1998-10-22 19:39:32 +08:00
|
|
|
|
|
|
|
lbi = sbi + bleed_variation * bytes;
|
|
|
|
if (lbi > lpi)
|
|
|
|
{
|
|
|
|
lbi = lpi; /* stop overunning the buffer */
|
|
|
|
}
|
|
|
|
|
|
|
|
bleed_length = bleed_variation;
|
|
|
|
|
|
|
|
blend_amt_R = target_colour_R - blend_colour_R;
|
|
|
|
blend_amt_G = target_colour_G - blend_colour_G;
|
|
|
|
blend_amt_B = target_colour_B - blend_colour_B;
|
2000-05-25 07:01:48 +08:00
|
|
|
if(bytes > 3)
|
|
|
|
{
|
|
|
|
blend_amt_A = target_colour_A - blend_colour_A;
|
|
|
|
}
|
1998-10-22 19:39:32 +08:00
|
|
|
denominator = bleed_length * bleed_length + bleed_length;
|
|
|
|
denominator = 2.0 / denominator;
|
|
|
|
n = bleed_length;
|
|
|
|
for (i = sbi; i < lbi; i += bytes)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* check against original colour */
|
2000-05-25 07:01:48 +08:00
|
|
|
if (!threshold_exceeded(sb+Ri, sb+i, edge, threshold,(bytes>3))
|
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_random_boolean())
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
blend_colour_R += blend_amt_R * n * denominator;
|
|
|
|
blend_colour_G += blend_amt_G * n * denominator;
|
|
|
|
blend_colour_B += blend_amt_B * n * denominator;
|
|
|
|
|
2000-05-25 07:01:48 +08:00
|
|
|
if(bytes > 3)
|
|
|
|
{
|
|
|
|
blend_colour_A += blend_amt_A * n * denominator;
|
|
|
|
if (blend_colour_A > 255) blend_colour_A = 255;
|
|
|
|
else if (blend_colour_A < 0) blend_colour_A = 0;
|
|
|
|
}
|
|
|
|
|
1998-10-22 19:39:32 +08:00
|
|
|
if (blend_colour_R > 255) blend_colour_R = 255;
|
|
|
|
else if (blend_colour_R < 0) blend_colour_R = 0;
|
|
|
|
if (blend_colour_G > 255) blend_colour_G = 255;
|
|
|
|
else if (blend_colour_G < 0) blend_colour_G = 0;
|
|
|
|
if (blend_colour_B > 255) blend_colour_B = 255;
|
|
|
|
else if (blend_colour_B < 0) blend_colour_B = 0;
|
|
|
|
|
|
|
|
sb[i] = (blend_colour_R * 2 + sb[i]) / 3;
|
|
|
|
sb[i+1] = (blend_colour_G * 2 + sb[i+1]) / 3;
|
|
|
|
sb[i+2] = (blend_colour_B * 2 + sb[i+2]) / 3;
|
|
|
|
|
2000-05-25 07:01:48 +08:00
|
|
|
if(bytes > 3)
|
|
|
|
sb[i+3] = (blend_colour_A * 2 + sb[i+3]) / 3;
|
|
|
|
|
1998-10-22 19:39:32 +08:00
|
|
|
if (threshold_exceeded(sb+i, sb+i+comp_stride, BOTH,
|
2000-05-25 07:01:48 +08:00
|
|
|
threshold,(bytes>3)))
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
|
|
|
target_colour_R = sb[i+comp_stride];
|
|
|
|
target_colour_G = sb[i+comp_stride+1];
|
|
|
|
target_colour_B = sb[i+comp_stride+2];
|
2000-05-25 07:01:48 +08:00
|
|
|
if(bytes > 3)
|
|
|
|
target_colour_A = sb[i+comp_stride+3];
|
1998-10-22 19:39:32 +08:00
|
|
|
blend_amt_R = target_colour_R - blend_colour_R;
|
|
|
|
blend_amt_G = target_colour_G - blend_colour_G;
|
|
|
|
blend_amt_B = target_colour_B - blend_colour_B;
|
2000-05-25 07:01:48 +08:00
|
|
|
if(bytes > 3)
|
|
|
|
blend_amt_A = target_colour_A - blend_colour_A;
|
1998-10-22 19:39:32 +08:00
|
|
|
denominator = n * n + n;
|
|
|
|
denominator = 2.0 / denominator;
|
|
|
|
}
|
|
|
|
n--;
|
|
|
|
}
|
2000-01-09 04:00:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-10-22 19:39:32 +08:00
|
|
|
|
|
|
|
static gint
|
2000-05-25 07:01:48 +08:00
|
|
|
threshold_exceeded (guchar *pixel_R1,
|
|
|
|
guchar *pixel_R2,
|
|
|
|
edge_t edge,
|
|
|
|
gint threshold,
|
|
|
|
gboolean has_alpha)
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
2000-05-25 07:01:48 +08:00
|
|
|
gint derivative_R, derivative_G, derivative_B, derivative_A;
|
1998-10-22 19:39:32 +08:00
|
|
|
gint return_value;
|
|
|
|
|
2000-05-25 07:01:48 +08:00
|
|
|
get_derivative(pixel_R1, pixel_R2, edge, has_alpha,
|
|
|
|
&derivative_R, &derivative_G, &derivative_B, &derivative_A);
|
1998-10-22 19:39:32 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
if(((derivative_R +
|
|
|
|
derivative_G +
|
|
|
|
derivative_B +
|
2000-05-25 07:01:48 +08:00
|
|
|
derivative_A) / 4) > threshold)
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
|
|
|
return_value = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return_value = 0;
|
|
|
|
}
|
|
|
|
return return_value;
|
2000-01-09 04:00:10 +08:00
|
|
|
}
|
1998-10-22 19:39:32 +08:00
|
|
|
|
|
|
|
static void
|
2000-05-25 07:01:48 +08:00
|
|
|
get_derivative (guchar *pixel_R1,
|
|
|
|
guchar *pixel_R2,
|
|
|
|
edge_t edge,
|
|
|
|
gboolean has_alpha,
|
|
|
|
gint *derivative_R,
|
|
|
|
gint *derivative_G,
|
|
|
|
gint *derivative_B,
|
|
|
|
gint *derivative_A)
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
|
|
|
guchar *pixel_G1 = pixel_R1 + 1;
|
|
|
|
guchar *pixel_B1 = pixel_R1 + 2;
|
|
|
|
guchar *pixel_G2 = pixel_R2 + 1;
|
|
|
|
guchar *pixel_B2 = pixel_R2 + 2;
|
2000-05-25 07:01:48 +08:00
|
|
|
guchar *pixel_A1;
|
|
|
|
guchar *pixel_A2;
|
|
|
|
|
|
|
|
if(has_alpha)
|
|
|
|
{
|
|
|
|
pixel_A1 = pixel_R1 + 3;
|
|
|
|
pixel_A2 = pixel_R2 + 3;
|
|
|
|
*derivative_A = *pixel_A2 - *pixel_A1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*derivative_A = 0;
|
|
|
|
}
|
1998-10-22 19:39:32 +08:00
|
|
|
|
|
|
|
*derivative_R = *pixel_R2 - *pixel_R1;
|
|
|
|
*derivative_G = *pixel_G2 - *pixel_G1;
|
|
|
|
*derivative_B = *pixel_B2 - *pixel_B1;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
1998-10-22 19:39:32 +08:00
|
|
|
if (edge == BOTH)
|
|
|
|
{
|
|
|
|
*derivative_R = abs(*derivative_R);
|
|
|
|
*derivative_G = abs(*derivative_G);
|
|
|
|
*derivative_B = abs(*derivative_B);
|
2000-05-25 07:01:48 +08:00
|
|
|
*derivative_A = abs(*derivative_A);
|
1998-10-22 19:39:32 +08:00
|
|
|
}
|
|
|
|
else if (edge == LEADING)
|
|
|
|
{
|
|
|
|
*derivative_R = -(*derivative_R);
|
|
|
|
*derivative_G = -(*derivative_G);
|
|
|
|
*derivative_B = -(*derivative_B);
|
2000-05-25 07:01:48 +08:00
|
|
|
*derivative_A = -(*derivative_A);
|
1998-10-22 19:39:32 +08:00
|
|
|
}
|
|
|
|
else if (edge == TRAILING)
|
|
|
|
{
|
|
|
|
/* no change needed */
|
|
|
|
}
|
2000-01-09 04:00:10 +08:00
|
|
|
}
|
1998-10-22 19:39:32 +08:00
|
|
|
|
|
|
|
static void
|
2000-01-09 04:00:10 +08:00
|
|
|
reverse_buffer (guchar *buffer,
|
|
|
|
gint length,
|
|
|
|
gint bytes)
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
|
|
|
gint i, si;
|
|
|
|
gint temp;
|
|
|
|
gint midpoint;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
1998-10-22 19:39:32 +08:00
|
|
|
midpoint = length / 2;
|
|
|
|
for (i = 0; i < midpoint; i += bytes)
|
|
|
|
{
|
|
|
|
si = length - bytes - i;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
1998-10-22 19:39:32 +08:00
|
|
|
temp = buffer[i];
|
|
|
|
buffer[i] = buffer[si];
|
|
|
|
buffer[si] = (guchar) temp;
|
|
|
|
|
|
|
|
temp = buffer[i+1];
|
|
|
|
buffer[i+1] = buffer[si+1];
|
|
|
|
buffer[si+1] = (guchar) temp;
|
|
|
|
|
|
|
|
temp = buffer[i+2];
|
|
|
|
buffer[i+2] = buffer[si+2];
|
|
|
|
buffer[si+2] = (guchar) temp;
|
2000-05-25 07:20:42 +08:00
|
|
|
|
|
|
|
if(bytes > 3)
|
|
|
|
{
|
|
|
|
temp = buffer[i+3];
|
|
|
|
buffer[i+3] = buffer[si+3];
|
|
|
|
buffer[si+3] = (guchar) temp;
|
|
|
|
}
|
1998-10-22 19:39:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
2000-01-09 04:00:10 +08:00
|
|
|
}
|
1998-10-22 19:39:32 +08:00
|
|
|
|
|
|
|
/***************************************************
|
2003-11-06 23:27:05 +08:00
|
|
|
GUI
|
1998-10-22 19:39:32 +08:00
|
|
|
***************************************************/
|
|
|
|
|
|
|
|
static void
|
2003-11-06 23:27:05 +08:00
|
|
|
radio_callback (GtkWidget *widget,
|
2000-05-24 00:04:02 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
gimp_radio_button_update (widget, data);
|
2000-08-21 04:34:26 +08:00
|
|
|
|
|
|
|
if (GTK_TOGGLE_BUTTON (widget)->active)
|
|
|
|
{
|
2002-12-02 04:56:01 +08:00
|
|
|
GimpDrawable *drawable;
|
2002-01-16 02:35:29 +08:00
|
|
|
drawable = g_object_get_data (G_OBJECT (widget), "drawable");
|
|
|
|
|
2000-08-21 04:34:26 +08:00
|
|
|
if (drawable != NULL)
|
|
|
|
render_effect (drawable, TRUE);
|
|
|
|
}
|
2000-05-24 00:04:02 +08:00
|
|
|
}
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
static gint
|
2000-08-22 09:26:57 +08:00
|
|
|
dialog_box (GimpDrawable *drawable)
|
1998-10-22 19:39:32 +08:00
|
|
|
{
|
2000-01-09 04:00:10 +08:00
|
|
|
GtkWidget *main_vbox;
|
2000-05-24 00:04:02 +08:00
|
|
|
GtkWidget *vbox;
|
1998-10-22 19:39:32 +08:00
|
|
|
GtkWidget *table;
|
2000-01-15 23:32:28 +08:00
|
|
|
GtkObject *adj;
|
1998-10-22 19:39:32 +08:00
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *dlg;
|
2000-05-24 00:04:02 +08:00
|
|
|
GtkWidget *style1;
|
|
|
|
GtkWidget *style2;
|
|
|
|
GtkWidget *dir1;
|
|
|
|
GtkWidget *dir2;
|
|
|
|
GtkWidget *edge1;
|
|
|
|
GtkWidget *edge2;
|
|
|
|
GtkWidget *edge3;
|
2003-11-06 23:27:05 +08:00
|
|
|
gboolean run;
|
2000-05-02 04:22:55 +08:00
|
|
|
|
2000-05-24 22:35:25 +08:00
|
|
|
gimp_ui_init ("wind", TRUE);
|
2000-01-09 04:00:10 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
dlg = gimp_dialog_new (_("Wind"), "wind",
|
|
|
|
NULL, 0,
|
2000-05-23 01:10:28 +08:00
|
|
|
gimp_standard_help_func, "filters/wind.html",
|
2000-01-09 04:00:10 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
2000-01-09 04:00:10 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
NULL);
|
1998-10-22 19:39:32 +08:00
|
|
|
|
2000-05-24 00:04:02 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 2);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), vbox, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (vbox);
|
2000-01-09 04:00:10 +08:00
|
|
|
|
2002-12-20 06:23:37 +08:00
|
|
|
preview = gimp_fixme_preview_new (NULL, TRUE);
|
2002-12-02 04:56:01 +08:00
|
|
|
gimp_fixme_preview_fill (preview, drawable);
|
2002-12-20 06:23:37 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), preview->frame, FALSE, FALSE, 0);
|
2002-12-02 04:56:01 +08:00
|
|
|
render_effect (drawable, TRUE);
|
|
|
|
gtk_widget_show (preview->widget);
|
1998-10-22 19:39:32 +08:00
|
|
|
|
2003-09-14 02:07:44 +08:00
|
|
|
main_vbox = gimp_parameter_settings_new (vbox, 0, 0);
|
2000-01-26 01:46:56 +08:00
|
|
|
|
1998-10-22 19:39:32 +08:00
|
|
|
/*****************************************************
|
|
|
|
outer frame and table
|
|
|
|
***************************************************/
|
|
|
|
|
2000-01-09 04:00:10 +08:00
|
|
|
table = gtk_table_new (1, 3, FALSE);
|
2000-05-24 00:04:02 +08:00
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
2000-01-09 04:00:10 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 0);
|
1998-10-22 19:39:32 +08:00
|
|
|
|
|
|
|
/*********************************************************
|
|
|
|
radio buttons for choosing wind rendering algorithm
|
|
|
|
******************************************************/
|
|
|
|
|
2000-01-16 01:22:19 +08:00
|
|
|
frame = gimp_radio_group_new2 (TRUE, _("Style"),
|
2001-07-29 17:43:09 +08:00
|
|
|
G_CALLBACK (radio_callback),
|
2002-01-16 02:35:29 +08:00
|
|
|
&config.alg,
|
|
|
|
GINT_TO_POINTER (config.alg),
|
|
|
|
|
2002-06-14 04:32:21 +08:00
|
|
|
_("_Wind"),
|
2002-01-16 02:35:29 +08:00
|
|
|
GINT_TO_POINTER (RENDER_WIND), &style1,
|
|
|
|
|
2002-06-14 04:32:21 +08:00
|
|
|
_("_Blast"),
|
2002-01-16 02:35:29 +08:00
|
|
|
GINT_TO_POINTER (RENDER_BLAST), &style2,
|
2000-01-15 23:32:28 +08:00
|
|
|
|
|
|
|
NULL);
|
2002-01-16 02:35:29 +08:00
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (style1), "drawable", drawable);
|
|
|
|
g_object_set_data (G_OBJECT (style2), "drawable", drawable);
|
2000-01-09 04:00:10 +08:00
|
|
|
|
2000-01-15 23:32:28 +08:00
|
|
|
gtk_table_attach (GTK_TABLE (table), frame, 0, 1, 0, 1,
|
|
|
|
GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0);
|
2000-01-09 04:00:10 +08:00
|
|
|
gtk_widget_show (frame);
|
1998-10-22 19:39:32 +08:00
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
radio buttons for choosing LEFT or RIGHT
|
|
|
|
**************************************************/
|
2000-01-15 23:32:28 +08:00
|
|
|
|
2000-01-16 01:22:19 +08:00
|
|
|
frame = gimp_radio_group_new2 (TRUE, _("Direction"),
|
2001-07-29 17:43:09 +08:00
|
|
|
G_CALLBACK (radio_callback),
|
2002-01-16 02:35:29 +08:00
|
|
|
&config.direction,
|
|
|
|
GINT_TO_POINTER (config.direction),
|
|
|
|
|
2002-06-14 04:32:21 +08:00
|
|
|
_("_Left"),
|
2002-01-16 02:35:29 +08:00
|
|
|
GINT_TO_POINTER (LEFT), &dir1,
|
|
|
|
|
2002-06-14 04:32:21 +08:00
|
|
|
_("_Right"),
|
2002-01-16 02:35:29 +08:00
|
|
|
GINT_TO_POINTER (RIGHT), &dir2,
|
|
|
|
|
2000-01-15 23:32:28 +08:00
|
|
|
NULL);
|
2002-01-16 02:35:29 +08:00
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (dir1), "drawable", drawable);
|
|
|
|
g_object_set_data (G_OBJECT (dir2), "drawable", drawable);
|
2000-01-15 23:32:28 +08:00
|
|
|
|
2000-01-09 04:00:10 +08:00
|
|
|
gtk_table_attach (GTK_TABLE (table), frame, 1, 2, 0, 1,
|
|
|
|
GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0);
|
|
|
|
gtk_widget_show (frame);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
1998-10-22 19:39:32 +08:00
|
|
|
/*****************************************************
|
|
|
|
radio buttons for choosing BOTH, LEADING, TRAILING
|
|
|
|
***************************************************/
|
|
|
|
|
2000-01-16 01:22:19 +08:00
|
|
|
frame = gimp_radio_group_new2 (TRUE, _("Edge Affected"),
|
2001-07-29 17:43:09 +08:00
|
|
|
G_CALLBACK (radio_callback),
|
2002-01-16 02:35:29 +08:00
|
|
|
&config.edge,
|
|
|
|
GINT_TO_POINTER (config.edge),
|
|
|
|
|
2002-06-14 04:32:21 +08:00
|
|
|
_("L_eading"),
|
2002-01-16 02:35:29 +08:00
|
|
|
GINT_TO_POINTER (LEADING), &edge1,
|
|
|
|
|
2002-06-14 04:32:21 +08:00
|
|
|
_("Tr_ailing"),
|
2002-01-16 02:35:29 +08:00
|
|
|
GINT_TO_POINTER (TRAILING), &edge2,
|
2000-01-15 23:32:28 +08:00
|
|
|
|
2002-06-14 04:32:21 +08:00
|
|
|
_("Bot_h"),
|
2002-01-16 02:35:29 +08:00
|
|
|
GINT_TO_POINTER (BOTH), &edge3,
|
2000-01-15 23:32:28 +08:00
|
|
|
|
|
|
|
NULL);
|
2002-01-16 02:35:29 +08:00
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (edge1), "drawable", drawable);
|
|
|
|
g_object_set_data (G_OBJECT (edge2), "drawable", drawable);
|
|
|
|
g_object_set_data (G_OBJECT (edge3), "drawable", drawable);
|
2000-01-15 23:32:28 +08:00
|
|
|
|
2000-01-09 04:00:10 +08:00
|
|
|
gtk_table_attach (GTK_TABLE (table), frame, 2, 3, 0, 1,
|
|
|
|
GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0);
|
|
|
|
gtk_widget_show (frame);
|
1998-10-22 19:39:32 +08:00
|
|
|
|
2000-01-09 04:00:10 +08:00
|
|
|
gtk_widget_show (table);
|
2000-01-26 01:46:56 +08:00
|
|
|
|
|
|
|
/****************************************************
|
|
|
|
table for sliders
|
|
|
|
****************************************************/
|
|
|
|
table = gtk_table_new (2, 3, FALSE);
|
|
|
|
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);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
/*****************************************************
|
|
|
|
slider and entry for threshold
|
|
|
|
***************************************************/
|
|
|
|
|
|
|
|
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
|
2002-06-14 04:32:21 +08:00
|
|
|
_("_Threshold:"), SCALE_WIDTH, 0,
|
2000-01-26 01:46:56 +08:00
|
|
|
config.threshold,
|
|
|
|
MIN_THRESHOLD, MAX_THRESHOLD, 1.0, 10, 0,
|
2000-02-04 23:12:17 +08:00
|
|
|
TRUE, 0, 0,
|
2000-01-26 01:46:56 +08:00
|
|
|
_("Higher values restrict the effect to fewer areas of the image"), NULL);
|
2002-01-16 02:35:29 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (adj, "value_changed",
|
2002-01-16 02:35:29 +08:00
|
|
|
G_CALLBACK (gimp_int_adjustment_update),
|
|
|
|
&config.threshold);
|
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect_swapped (adj, "value_changed",
|
2002-01-16 02:35:29 +08:00
|
|
|
G_CALLBACK (render_effect),
|
|
|
|
drawable);
|
2000-01-26 01:46:56 +08:00
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
slider and entry for strength of wind
|
|
|
|
****************************************************/
|
|
|
|
|
|
|
|
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
|
2002-06-14 04:32:21 +08:00
|
|
|
_("_Strength:"), SCALE_WIDTH, 0,
|
2000-01-26 01:46:56 +08:00
|
|
|
config.strength,
|
|
|
|
MIN_STRENGTH, MAX_STRENGTH, 1.0, 10.0, 0,
|
2000-02-04 23:12:17 +08:00
|
|
|
TRUE, 0, 0,
|
2000-01-26 01:46:56 +08:00
|
|
|
_("Higher values increase the magnitude of the effect"), NULL);
|
2000-05-24 00:04:02 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (adj, "value_changed",
|
2002-01-16 02:35:29 +08:00
|
|
|
G_CALLBACK (gimp_int_adjustment_update),
|
|
|
|
&config.strength);
|
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect_swapped (adj, "value_changed",
|
2002-01-16 02:35:29 +08:00
|
|
|
G_CALLBACK (render_effect),
|
|
|
|
drawable);
|
2000-01-26 01:46:56 +08:00
|
|
|
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
2000-01-09 04:00:10 +08:00
|
|
|
gtk_widget_show (dlg);
|
1998-10-22 19:39:32 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
run = (gtk_dialog_run (GTK_DIALOG (dlg)) == GTK_RESPONSE_OK);
|
|
|
|
|
|
|
|
gtk_widget_destroy (dlg);
|
|
|
|
|
|
|
|
return run;
|
1998-10-22 19:39:32 +08:00
|
|
|
}
|