2000-05-23 21:00:40 +08:00
|
|
|
/*
|
|
|
|
* illusion.c -- This is a plug-in for the GIMP 1.0
|
2003-11-06 23:27:05 +08:00
|
|
|
*
|
2000-05-23 21:00:40 +08:00
|
|
|
* Copyright (C) 1997 Hirotsuna Mizuno
|
|
|
|
* s1041150@u-aizu.ac.jp
|
|
|
|
*
|
|
|
|
* Preview and new mode added May 2000 by tim copperfield
|
|
|
|
* timecop@japan.co.jp
|
|
|
|
* http://www.ne.jp/asahi/linux/timecop
|
2001-10-19 07:09:40 +08:00
|
|
|
*
|
2000-05-23 21:00:40 +08:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 2 of the License, or (at your option)
|
|
|
|
* any later version.
|
2001-10-19 07:09:40 +08:00
|
|
|
*
|
2000-05-23 21:00:40 +08:00
|
|
|
* 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.
|
2001-10-19 07:09:40 +08:00
|
|
|
*
|
2000-05-23 21:00:40 +08:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
1997-12-09 13:57:33 +08:00
|
|
|
|
1999-12-29 04:04:19 +08:00
|
|
|
#include "config.h"
|
2000-01-07 18:39:33 +08:00
|
|
|
|
1998-06-09 19:41:13 +08:00
|
|
|
#include <stdio.h>
|
1997-12-09 13:57:33 +08:00
|
|
|
#include <stdlib.h>
|
2000-10-01 04:13:06 +08:00
|
|
|
#include <string.h>
|
2000-01-07 18:39:33 +08:00
|
|
|
|
1997-12-09 13:57:33 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-01-07 18:39:33 +08:00
|
|
|
|
2000-01-18 01:02:26 +08:00
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
2000-01-07 18:39:33 +08:00
|
|
|
|
1999-12-29 04:04:19 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
1997-12-09 13:57:33 +08:00
|
|
|
|
2000-05-02 01:01:18 +08:00
|
|
|
|
1997-12-09 13:57:33 +08:00
|
|
|
#define PLUG_IN_NAME "plug_in_illusion"
|
2000-05-23 21:00:40 +08:00
|
|
|
#define PLUG_IN_VERSION "v0.8 (May 14 2000)"
|
|
|
|
|
1997-12-09 13:57:33 +08:00
|
|
|
|
2000-05-02 01:01:18 +08:00
|
|
|
static void query (void);
|
2003-07-02 20:03:08 +08:00
|
|
|
static void run (const gchar *name,
|
|
|
|
gint nparam,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals);
|
2000-01-18 01:02:26 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
static void filter (GimpDrawable *drawable);
|
2000-05-23 21:00:40 +08:00
|
|
|
static void filter_preview (void);
|
2000-08-22 09:26:57 +08:00
|
|
|
static gboolean dialog (GimpDrawable *drawable);
|
1997-12-09 13:57:33 +08:00
|
|
|
|
2000-01-18 01:02:26 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
1997-12-09 13:57:33 +08:00
|
|
|
gint32 division;
|
2000-05-23 21:00:40 +08:00
|
|
|
gint type1;
|
|
|
|
gint type2;
|
|
|
|
} IllValues;
|
1997-12-09 13:57:33 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
GimpPlugInInfo PLUG_IN_INFO =
|
2000-01-18 01:02:26 +08:00
|
|
|
{
|
|
|
|
NULL, /* init_proc */
|
|
|
|
NULL, /* quit_proc */
|
|
|
|
query, /* query_proc */
|
2000-05-23 21:00:40 +08:00
|
|
|
run /* run_proc */
|
1997-12-09 13:57:33 +08:00
|
|
|
};
|
|
|
|
|
2000-05-23 21:00:40 +08:00
|
|
|
static IllValues parameters =
|
2000-01-18 01:02:26 +08:00
|
|
|
{
|
2000-05-23 21:00:40 +08:00
|
|
|
8, /* division */
|
|
|
|
1, /* type 1 */
|
|
|
|
0 /* type 2 */
|
1997-12-09 13:57:33 +08:00
|
|
|
};
|
|
|
|
|
2000-05-23 21:00:40 +08:00
|
|
|
|
2002-12-02 04:56:01 +08:00
|
|
|
static GimpFixMePreview *preview;
|
2003-11-06 23:27:05 +08:00
|
|
|
static GimpRunMode run_mode;
|
|
|
|
|
1997-12-09 13:57:33 +08:00
|
|
|
|
2000-01-18 01:02:26 +08:00
|
|
|
MAIN ()
|
1997-12-09 13:57:33 +08:00
|
|
|
|
2000-01-18 01:02:26 +08:00
|
|
|
static void
|
|
|
|
query (void)
|
1997-12-09 13:57:33 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
static GimpParamDef args[] =
|
2000-01-07 18:39:33 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
{ GIMP_PDB_INT32, "run_mode", "interactive / non-interactive" },
|
|
|
|
{ GIMP_PDB_IMAGE, "image", "input image" },
|
|
|
|
{ GIMP_PDB_DRAWABLE, "drawable", "input drawable" },
|
2001-10-19 07:09:40 +08:00
|
|
|
{ GIMP_PDB_INT32, "division", "the number of divisions" },
|
2001-10-19 18:40:47 +08:00
|
|
|
{ GIMP_PDB_INT32, "type", "illusion type (0=type1, 1=type2)" }
|
1997-12-09 13:57:33 +08:00
|
|
|
};
|
1999-12-29 04:04:19 +08:00
|
|
|
|
2000-01-07 18:39:33 +08:00
|
|
|
gimp_install_procedure (PLUG_IN_NAME,
|
2000-03-08 21:53:54 +08:00
|
|
|
"produce illusion",
|
|
|
|
"produce illusion",
|
2000-01-07 18:39:33 +08:00
|
|
|
"Hirotsuna Mizuno <s1041150@u-aizu.ac.jp>",
|
|
|
|
"Hirotsuna Mizuno",
|
|
|
|
PLUG_IN_VERSION,
|
2003-07-17 23:47:18 +08:00
|
|
|
N_("<Image>/Filters/Map/_Illusion..."),
|
2000-01-07 18:39:33 +08:00
|
|
|
"RGB*, GRAY*",
|
2000-08-22 09:26:57 +08:00
|
|
|
GIMP_PLUGIN,
|
2001-12-06 10:28:58 +08:00
|
|
|
G_N_ELEMENTS (args), 0,
|
2000-05-02 01:01:18 +08:00
|
|
|
args, NULL);
|
1997-12-09 13:57:33 +08:00
|
|
|
}
|
|
|
|
|
2000-01-07 18:39:33 +08:00
|
|
|
static void
|
2003-07-02 20:03:08 +08:00
|
|
|
run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *params,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals)
|
1997-12-09 13:57:33 +08:00
|
|
|
{
|
2001-12-29 21:26:29 +08:00
|
|
|
GimpDrawable *drawable;
|
|
|
|
static GimpParam returnv[1];
|
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
1997-12-09 13:57:33 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
INIT_I18N ();
|
|
|
|
|
1997-12-09 13:57:33 +08:00
|
|
|
run_mode = params[0].data.d_int32;
|
2000-01-07 18:39:33 +08:00
|
|
|
drawable = gimp_drawable_get (params[2].data.d_drawable);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2000-01-18 01:02:26 +08:00
|
|
|
*nreturn_vals = 1;
|
|
|
|
*return_vals = returnv;
|
1997-12-09 13:57:33 +08:00
|
|
|
|
|
|
|
/* get the drawable info */
|
|
|
|
|
|
|
|
/* switch the run mode */
|
2000-01-07 18:39:33 +08:00
|
|
|
switch (run_mode)
|
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_INTERACTIVE:
|
2000-01-07 18:39:33 +08:00
|
|
|
gimp_get_data (PLUG_IN_NAME, ¶meters);
|
2000-05-23 21:00:40 +08:00
|
|
|
if (! dialog(drawable))
|
2000-01-18 01:02:26 +08:00
|
|
|
return;
|
2000-05-23 21:00:40 +08:00
|
|
|
gimp_set_data (PLUG_IN_NAME, ¶meters, sizeof (IllValues));
|
2002-12-02 04:56:01 +08:00
|
|
|
gimp_fixme_preview_free (preview);
|
2000-01-07 18:39:33 +08:00
|
|
|
break;
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_NONINTERACTIVE:
|
2001-10-19 18:40:47 +08:00
|
|
|
if (nparams != 5)
|
2000-01-07 18:39:33 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
2000-01-07 18:39:33 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
parameters.division = params[3].data.d_int32;
|
2001-10-19 18:40:47 +08:00
|
|
|
if (params[4].data.d_int32 == 0)
|
|
|
|
{
|
|
|
|
parameters.type1 = 1;
|
|
|
|
parameters.type2 = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
parameters.type1 = 0;
|
|
|
|
parameters.type2 = 1;
|
|
|
|
}
|
2000-01-07 18:39:33 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_WITH_LAST_VALS:
|
2000-01-07 18:39:33 +08:00
|
|
|
gimp_get_data (PLUG_IN_NAME, ¶meters);
|
|
|
|
break;
|
1997-12-09 13:57:33 +08:00
|
|
|
}
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
2000-01-07 18:39:33 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
if (gimp_drawable_is_rgb (drawable->drawable_id) ||
|
2001-06-15 04:07:38 +08:00
|
|
|
gimp_drawable_is_gray (drawable->drawable_id))
|
2000-01-07 18:39:33 +08:00
|
|
|
{
|
|
|
|
gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width() + 1));
|
2000-05-23 21:00:40 +08:00
|
|
|
gimp_progress_init (_("Illusion..."));
|
2000-01-07 18:39:33 +08:00
|
|
|
filter (drawable);
|
2000-08-22 09:26:57 +08:00
|
|
|
if (run_mode != GIMP_RUN_NONINTERACTIVE)
|
2000-01-07 18:39:33 +08:00
|
|
|
gimp_displays_flush ();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
status = GIMP_PDB_EXECUTION_ERROR;
|
2000-01-07 18:39:33 +08:00
|
|
|
}
|
1997-12-09 13:57:33 +08:00
|
|
|
}
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
returnv[0].type = GIMP_PDB_STATUS;
|
1997-12-09 13:57:33 +08:00
|
|
|
returnv[0].data.d_status = status;
|
|
|
|
|
2000-01-07 18:39:33 +08:00
|
|
|
gimp_drawable_detach (drawable);
|
1997-12-09 13:57:33 +08:00
|
|
|
}
|
|
|
|
|
2003-09-25 04:17:43 +08:00
|
|
|
typedef struct {
|
|
|
|
GimpPixelFetcher *pft;
|
|
|
|
gdouble center_x;
|
|
|
|
gdouble center_y;
|
|
|
|
gdouble scale;
|
|
|
|
gdouble offset;
|
|
|
|
gboolean has_alpha;
|
|
|
|
} IllusionParam_t;
|
|
|
|
|
2000-01-07 18:39:33 +08:00
|
|
|
static void
|
2003-09-25 04:17:43 +08:00
|
|
|
illusion_func (gint x,
|
|
|
|
gint y,
|
|
|
|
const guchar *src,
|
|
|
|
guchar *dest,
|
|
|
|
gint bpp,
|
|
|
|
gpointer data)
|
1997-12-09 13:57:33 +08:00
|
|
|
{
|
2003-09-25 04:17:43 +08:00
|
|
|
IllusionParam_t *param = (IllusionParam_t*) data;
|
|
|
|
gint xx, yy, b;
|
|
|
|
gdouble radius, cx, cy, angle;
|
|
|
|
guchar pixel[4];
|
2000-05-23 21:00:40 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
cy = ((gdouble) y - param->center_y) / param->scale;
|
2003-09-25 04:17:43 +08:00
|
|
|
cx = ((gdouble) x - param->center_x) / param->scale;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2003-09-25 04:17:43 +08:00
|
|
|
angle = floor (atan2 (cy, cx) * parameters.division / G_PI_2)
|
|
|
|
* G_PI_2 / parameters.division + (G_PI / parameters.division);
|
|
|
|
radius = sqrt ((gdouble) (cx * cx + cy * cy));
|
2000-05-23 21:00:40 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
if (parameters.type1)
|
2000-01-07 18:39:33 +08:00
|
|
|
{
|
2003-09-25 04:17:43 +08:00
|
|
|
xx = x - param->offset * cos (angle);
|
|
|
|
yy = y - param->offset * sin (angle);
|
2003-11-06 23:27:05 +08:00
|
|
|
}
|
2003-09-25 04:17:43 +08:00
|
|
|
else /* Type 2 */
|
|
|
|
{
|
|
|
|
xx = x - param->offset * sin (angle);
|
|
|
|
yy = y - param->offset * cos (angle);
|
2000-01-07 18:39:33 +08:00
|
|
|
}
|
1997-12-09 13:57:33 +08:00
|
|
|
|
2003-09-25 04:17:43 +08:00
|
|
|
gimp_pixel_fetcher_get_pixel2 (param->pft, xx, yy, PIXEL_SMEAR, pixel);
|
2000-01-07 18:39:33 +08:00
|
|
|
|
2003-09-25 04:17:43 +08:00
|
|
|
if (param->has_alpha)
|
2000-01-07 18:39:33 +08:00
|
|
|
{
|
2003-09-25 04:17:43 +08:00
|
|
|
guint alpha1 = src[bpp - 1];
|
|
|
|
guint alpha2 = pixel[bpp - 1];
|
2003-09-25 06:01:53 +08:00
|
|
|
guint alpha = (1 - radius) * alpha1 + radius * alpha2;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2003-09-25 04:17:43 +08:00
|
|
|
if ((dest[bpp - 1] = (alpha >> 1)))
|
2000-01-07 18:39:33 +08:00
|
|
|
{
|
2003-09-25 04:17:43 +08:00
|
|
|
for (b = 0; b < bpp - 1; b++)
|
2003-11-06 23:27:05 +08:00
|
|
|
dest[b] = ((1 - radius) * src[b] * alpha1 +
|
2003-09-25 04:17:43 +08:00
|
|
|
radius * pixel[b] * alpha2) / alpha;
|
2000-01-07 18:39:33 +08:00
|
|
|
}
|
1997-12-09 13:57:33 +08:00
|
|
|
}
|
2003-09-25 04:17:43 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
for (b = 0; b < bpp; b++)
|
|
|
|
dest[b] = (1 - radius) * src[b] + radius * pixel[b];
|
|
|
|
}
|
|
|
|
}
|
2000-01-07 18:39:33 +08:00
|
|
|
|
2003-09-25 04:17:43 +08:00
|
|
|
static void
|
|
|
|
filter (GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
IllusionParam_t param;
|
|
|
|
GimpRgnIterator *iter;
|
|
|
|
gint width, height;
|
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
|
|
|
|
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
|
|
|
width = x2 - x1;
|
|
|
|
height = y2 - y1;
|
|
|
|
|
|
|
|
param.pft = gimp_pixel_fetcher_new (drawable);
|
|
|
|
param.has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
|
|
|
param.center_x = (x1 + x2) / 2.0;
|
|
|
|
param.center_y = (y1 + y2) / 2.0;
|
|
|
|
param.scale = sqrt (width * width + height * height) / 2;
|
|
|
|
param.offset = (gint) (param.scale / 2);
|
|
|
|
|
|
|
|
iter = gimp_rgn_iterator_new (drawable, run_mode);
|
|
|
|
gimp_rgn_iterator_src_dest (iter, illusion_func, ¶m);
|
|
|
|
gimp_rgn_iterator_free (iter);
|
|
|
|
|
|
|
|
gimp_pixel_fetcher_destroy (param.pft);
|
2000-05-23 21:00:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
filter_preview (void)
|
|
|
|
{
|
|
|
|
guchar **pixels;
|
|
|
|
guchar **destpixels;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2000-05-23 21:00:40 +08:00
|
|
|
gint image_width;
|
|
|
|
gint image_height;
|
|
|
|
gint image_bpp;
|
|
|
|
gdouble center_x;
|
|
|
|
gdouble center_y;
|
|
|
|
|
|
|
|
gint x, y, b;
|
|
|
|
gint xx = 0;
|
|
|
|
gint yy = 0;
|
|
|
|
gdouble scale, radius, cx, cy, angle, offset;
|
|
|
|
|
2002-12-02 04:56:01 +08:00
|
|
|
image_width = preview->width;
|
|
|
|
image_height = preview->height;
|
|
|
|
image_bpp = preview->bpp;
|
2000-05-23 21:00:40 +08:00
|
|
|
center_x = (gdouble)image_width / 2;
|
|
|
|
center_y = (gdouble)image_height / 2;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2000-05-23 21:00:40 +08:00
|
|
|
pixels = g_new (guchar *, image_height);
|
|
|
|
destpixels = g_new (guchar *, image_height);
|
|
|
|
|
|
|
|
for (y = 0; y < image_height; y++)
|
|
|
|
{
|
2002-12-02 04:56:01 +08:00
|
|
|
pixels[y] = g_new (guchar, preview->rowstride);
|
|
|
|
destpixels[y] = g_new (guchar, preview->rowstride);
|
2003-11-06 23:27:05 +08:00
|
|
|
memcpy (pixels[y],
|
|
|
|
preview->cache + preview->rowstride * y,
|
2002-12-02 04:56:01 +08:00
|
|
|
preview->rowstride);
|
2000-05-23 21:00:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
scale = sqrt (image_width * image_width + image_height * image_height) / 2;
|
|
|
|
offset = (gint) (scale / 2);
|
|
|
|
|
|
|
|
for (y = 0; y < image_height; y++)
|
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
cy = ((gdouble)y - center_y) / scale;
|
2000-05-23 21:00:40 +08:00
|
|
|
for (x = 0; x < image_width; x++)
|
|
|
|
{
|
|
|
|
cx = ((gdouble)x - center_x) / scale;
|
|
|
|
angle = floor (atan2 (cy, cx) * parameters.division / G_PI_2)
|
|
|
|
* G_PI_2 / parameters.division + (G_PI / parameters.division);
|
|
|
|
radius = sqrt ((gdouble) (cx * cx + cy * cy));
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
if (parameters.type1)
|
2000-05-23 21:00:40 +08:00
|
|
|
{
|
|
|
|
xx = x - offset * cos (angle);
|
|
|
|
yy = y - offset * sin (angle);
|
|
|
|
}
|
2003-09-25 04:17:43 +08:00
|
|
|
else /* Type 2 */
|
2000-05-23 21:00:40 +08:00
|
|
|
{
|
|
|
|
xx = x - offset * sin (angle);
|
|
|
|
yy = y - offset * cos (angle);
|
|
|
|
}
|
|
|
|
|
2002-12-02 04:56:01 +08:00
|
|
|
xx = CLAMP (xx, 0, image_width - 1);
|
|
|
|
yy = CLAMP (yy, 0, image_height - 1);
|
2000-05-23 21:00:40 +08:00
|
|
|
|
2003-09-25 06:01:53 +08:00
|
|
|
if (image_bpp == 2 || image_bpp == 4)
|
|
|
|
{
|
|
|
|
gdouble alpha1 = pixels[y][x * image_bpp + image_bpp - 1];
|
|
|
|
gdouble alpha2 = pixels[yy][xx * image_bpp + image_bpp - 1];
|
|
|
|
gdouble alpha = (1 - radius) * alpha1 + radius * alpha2;
|
|
|
|
|
|
|
|
for (b = 0; alpha > 0 && b < image_bpp - 1; b++)
|
|
|
|
{
|
|
|
|
destpixels[y][x * image_bpp+b] =
|
|
|
|
((1-radius) * alpha1 * pixels[y][x * image_bpp + b]
|
|
|
|
+ radius * alpha2 * pixels[yy][xx * image_bpp + b])/alpha;
|
|
|
|
}
|
|
|
|
destpixels[y][x * image_bpp + image_bpp-1] = alpha;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (b = 0; b < image_bpp; b++)
|
|
|
|
destpixels[y][x*image_bpp+b] =
|
2003-11-06 23:27:05 +08:00
|
|
|
(1-radius) * pixels[y][x * image_bpp + b]
|
2003-09-25 06:01:53 +08:00
|
|
|
+ radius * pixels[yy][xx * image_bpp + b];
|
|
|
|
}
|
2000-05-23 21:00:40 +08:00
|
|
|
}
|
2002-12-02 04:56:01 +08:00
|
|
|
gimp_fixme_preview_do_row (preview, y, image_width, destpixels[y]);
|
2000-05-23 21:00:40 +08:00
|
|
|
}
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
for (y = 0; y < image_height; y++)
|
2000-05-23 21:00:40 +08:00
|
|
|
g_free (pixels[y]);
|
2000-01-07 18:39:33 +08:00
|
|
|
g_free (pixels);
|
2000-05-23 21:00:40 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
for (y = 0; y < image_height; y++)
|
2000-05-23 21:00:40 +08:00
|
|
|
g_free (destpixels[y]);
|
2000-01-07 18:39:33 +08:00
|
|
|
g_free (destpixels);
|
2000-05-23 21:00:40 +08:00
|
|
|
|
2002-12-02 04:56:01 +08:00
|
|
|
gtk_widget_queue_draw (preview->widget);
|
1997-12-09 13:57:33 +08:00
|
|
|
}
|
|
|
|
|
2000-05-02 01:01:18 +08:00
|
|
|
static gboolean
|
2000-08-22 09:26:57 +08:00
|
|
|
dialog (GimpDrawable *mangle)
|
1997-12-09 13:57:33 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
GtkWidget *dlg;
|
2000-05-23 21:00:40 +08:00
|
|
|
GtkWidget *main_vbox;
|
2003-12-11 05:13:29 +08:00
|
|
|
GtkWidget *frame;
|
2000-01-18 01:02:26 +08:00
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *spinbutton;
|
|
|
|
GtkObject *adj;
|
2000-05-23 21:00:40 +08:00
|
|
|
GtkWidget *radio;
|
|
|
|
GSList *group = NULL;
|
2003-11-06 23:27:05 +08:00
|
|
|
gboolean run;
|
2000-05-23 21:00:40 +08:00
|
|
|
|
|
|
|
gimp_ui_init ("illusion", TRUE);
|
|
|
|
|
|
|
|
dlg = gimp_dialog_new (_("Illusion"), "illusion",
|
2003-11-06 23:27:05 +08:00
|
|
|
NULL, 0,
|
2000-05-23 21:00:40 +08:00
|
|
|
gimp_standard_help_func, "filters/illusion.html",
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
|
|
|
|
|
|
|
NULL);
|
1997-12-09 13:57:33 +08:00
|
|
|
|
2002-09-07 04:44:47 +08:00
|
|
|
main_vbox = gtk_vbox_new (FALSE, 4);
|
2002-09-08 00:31:32 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 6);
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), main_vbox,
|
|
|
|
TRUE, TRUE, 0);
|
2000-05-23 21:00:40 +08:00
|
|
|
gtk_widget_show (main_vbox);
|
|
|
|
|
2002-12-20 06:23:37 +08:00
|
|
|
preview = gimp_fixme_preview_new (mangle, TRUE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), preview->frame, FALSE, FALSE, 0);
|
2000-05-23 21:00:40 +08:00
|
|
|
filter_preview();
|
2002-12-02 04:56:01 +08:00
|
|
|
gtk_widget_show (preview->widget);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2003-12-11 05:13:29 +08:00
|
|
|
frame = gtk_frame_new (_("Parameter Settings"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
table = gtk_table_new (3, 2, FALSE);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (table), 4);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), table);
|
|
|
|
gtk_widget_show (table);
|
2000-01-18 01:02:26 +08:00
|
|
|
|
|
|
|
spinbutton = gimp_spin_button_new (&adj, parameters.division,
|
2000-05-23 21:00:40 +08:00
|
|
|
-32, 64, 1, 10, 0, 1, 0);
|
2000-01-31 11:13:02 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
2002-05-31 19:39:27 +08:00
|
|
|
_("_Division:"), 1.0, 0.5,
|
2000-01-31 11:13:02 +08:00
|
|
|
spinbutton, 1, TRUE);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (adj, "value_changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_int_adjustment_update),
|
|
|
|
¶meters.division);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (adj, "value_changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (filter_preview),
|
|
|
|
NULL);
|
2000-05-23 21:00:40 +08:00
|
|
|
|
2002-05-31 19:39:27 +08:00
|
|
|
radio = gtk_radio_button_new_with_mnemonic (group, _("Mode _1"));
|
2001-12-29 21:26:29 +08:00
|
|
|
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio));
|
|
|
|
gtk_table_attach (GTK_TABLE (table), radio, 0, 2, 1, 2,
|
|
|
|
GTK_FILL, GTK_FILL, 0, 0);
|
2000-05-23 21:00:40 +08:00
|
|
|
gtk_widget_show (radio);
|
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (radio, "toggled",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
¶meters.type1);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (radio, "toggled",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (filter_preview),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), parameters.type1);
|
|
|
|
|
2002-05-31 19:39:27 +08:00
|
|
|
radio = gtk_radio_button_new_with_mnemonic (group, _("Mode _2"));
|
2001-12-29 21:26:29 +08:00
|
|
|
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio));
|
|
|
|
gtk_table_attach (GTK_TABLE (table), radio, 0, 2, 2, 3,
|
|
|
|
GTK_FILL, GTK_FILL, 0, 0);
|
2000-05-23 21:00:40 +08:00
|
|
|
gtk_widget_show (radio);
|
1997-12-09 13:57:33 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (radio, "toggled",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
¶meters.type2);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (radio, "toggled",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (filter_preview),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), parameters.type2);
|
|
|
|
|
2000-05-23 21:00:40 +08:00
|
|
|
gtk_widget_show (dlg);
|
2000-01-07 18:39:33 +08:00
|
|
|
|
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-12-09 13:57:33 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
return run;
|
1997-12-09 13:57:33 +08:00
|
|
|
}
|