updated a few plugins (randomize, gqbist, warp, fuse,gfig)
with there latest version removed gflare-tar.gz from plugins dir removed a Makefile and libtool script from gfig dir
This commit is contained in:
parent
e2092a1ffa
commit
3d86014f32
11 changed files with 5326 additions and 1067 deletions
|
|
@ -1,3 +1,9 @@
|
|||
Mon Dec 8 16:30:29 EST 1997 Adrian Likins <adrian@gimp.org>
|
||||
|
||||
* udpdate gqbist, warp, randomize, fuse, gfig plugins
|
||||
|
||||
* removed gflare-tar.gz from the plugins dir
|
||||
|
||||
Mon Dec 8 11:43:17 EST 1997 Adrian Likins <adrian@gimp.org>
|
||||
|
||||
* updated iwarp to latest version
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
* 1.7 added patch from Art Haas to make it compile with HP-UX, a small clean-up
|
||||
* 1.8 Dscho added transform file load/save, bug-fixes
|
||||
* 1.9 rewrote renderloop.
|
||||
* 1.9a fixed a bug.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
@ -258,7 +259,6 @@ void run(char *name, int nparams, GParam *param, int *nreturn_vals, GParam **ret
|
|||
gint sel_x1, sel_y1, sel_x2, sel_y2;
|
||||
gint img_height, img_width, img_bpp, img_has_alpha;
|
||||
|
||||
GParam values[1];
|
||||
GDrawable *drawable;
|
||||
GRunModeType run_mode;
|
||||
GStatusType status;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
/****************************************************************************
|
||||
* This is a plugin for the GIMP v 0.99.8 or later.
|
||||
* This is a plugin for the GIMP v 0.99.8 or later. Documentation is
|
||||
* available at http://www.rru.com/~meo/gimp/ .
|
||||
*
|
||||
* Copyright (C) 1997 Miles O'Neal
|
||||
* Copyright (C) 1997 Miles O'Neal <meo@rru.com> http://www.rru.com/~meo/
|
||||
* Blur code Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
* GUI based on GTK code from:
|
||||
* plasma (Copyright (C) 1996 Stephen Norris),
|
||||
* oilify (Copyright (C) 1996 Torsten Martinsen),
|
||||
* ripple (Copyright (C) 1997 Brian Degenhardt) and
|
||||
* whirl (Copyright (C) 1997 Federico Mena Quintero).
|
||||
* alienmap (Copyright (C) 1996, 1997 Daniel Cotting)
|
||||
* plasma (Copyright (C) 1996 Stephen Norris),
|
||||
* oilify (Copyright (C) 1996 Torsten Martinsen),
|
||||
* ripple (Copyright (C) 1997 Brian Degenhardt) and
|
||||
* whirl (Copyright (C) 1997 Federico Mena Quintero).
|
||||
*
|
||||
* 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
|
||||
|
|
@ -28,8 +30,19 @@
|
|||
/****************************************************************************
|
||||
* Randomize:
|
||||
*
|
||||
* randomize version 0.4c (17 May 1997, MEO)
|
||||
* randomize version 1.0 (19 Oct 1997, MEO)
|
||||
* history
|
||||
* 1.1 - 30 Nov 1997 MEO
|
||||
* added tooltips
|
||||
* 1.0 - 19 Nov 1997 MEO
|
||||
* final cleanup for 1.0 GIMP release
|
||||
* - added email and URL info for author
|
||||
* - added doc URL info
|
||||
* - final FCS comment cleanup
|
||||
* - standardized constant strings
|
||||
* - restored proper behavior when repeating
|
||||
* - final UI labels
|
||||
* - better help text (for when GIMP help arrives)
|
||||
* 0.5 - 20 May 1997 MEO
|
||||
* added seed initialization choices (current time or user value)
|
||||
* added randomization type to progress label
|
||||
|
|
@ -99,7 +112,8 @@
|
|||
*
|
||||
* TODO List
|
||||
*
|
||||
* - Add a real melt function.
|
||||
* - add a real melt function
|
||||
* - split into multiple files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
|
@ -107,23 +121,25 @@
|
|||
#include "libgimp/gimp.h"
|
||||
#include "gtk/gtk.h"
|
||||
|
||||
/*********************************
|
||||
*
|
||||
* PLUGIN-SPECIFIC CONSTANTS
|
||||
*
|
||||
********************************/
|
||||
|
||||
/*
|
||||
* Set this to 0 for faster processing, to 1 if for some
|
||||
* Set this to 1 for faster processing, to 0 if for some
|
||||
* reason you want all functions to be subroutines
|
||||
*/
|
||||
#define SUBS_NOT_DEFINES 0
|
||||
#define OPTIMIZE_SUBS 0
|
||||
|
||||
/*
|
||||
* progress meter update frequency
|
||||
*/
|
||||
#define PROG_UPDATE_TIME ((row % 10) == 0)
|
||||
|
||||
#define RNDM_VERSION "Randomize 0.5"
|
||||
|
||||
/*********************************
|
||||
*
|
||||
* LOCAL DATA
|
||||
*
|
||||
********************************/
|
||||
#define PLUG_IN_NAME "plug_in_randomize"
|
||||
#define RNDM_VERSION "Randomize 1.1"
|
||||
|
||||
#define RNDM_BLUR 1
|
||||
#define RNDM_PICK 2
|
||||
|
|
@ -136,6 +152,12 @@
|
|||
#define ENTRY_WIDTH 75
|
||||
#define SCALE_WIDTH 100
|
||||
|
||||
/*********************************
|
||||
*
|
||||
* PLUGIN-SPECIFIC STRUCTURES AND DATA
|
||||
*
|
||||
********************************/
|
||||
|
||||
typedef struct {
|
||||
gint rndm_type; /* type of randomization to apply */
|
||||
gdouble rndm_pct; /* likelihood of randomization (as %age) */
|
||||
|
|
@ -185,14 +207,15 @@ GPlugInInfo PLUG_IN_INFO = {
|
|||
};
|
||||
|
||||
static void randomize(GDrawable *drawable);
|
||||
#if (SUBS_NOT_DEFINES == 1)
|
||||
static void randomize_prepare_row(
|
||||
GPixelRgn *pixel_rgn,
|
||||
guchar *data,
|
||||
int x,
|
||||
int y,
|
||||
int w
|
||||
);
|
||||
|
||||
#if (OPTIMIZE_SUBS == 0)
|
||||
static void randomize_prepare_row(
|
||||
GPixelRgn *pixel_rgn,
|
||||
guchar *data,
|
||||
int x,
|
||||
int y,
|
||||
int w
|
||||
);
|
||||
#endif
|
||||
|
||||
static gint randomize_dialog();
|
||||
|
|
@ -224,6 +247,14 @@ static void randomize_text_update(
|
|||
gpointer data
|
||||
);
|
||||
|
||||
static void set_tooltip(
|
||||
GtkWidget *widget,
|
||||
const char *tip
|
||||
);
|
||||
|
||||
static void setup_tooltips();
|
||||
|
||||
/************************************ Guts ***********************************/
|
||||
|
||||
MAIN()
|
||||
|
||||
|
|
@ -250,12 +281,18 @@ query()
|
|||
static int nargs = sizeof(args) / sizeof (args[0]);
|
||||
static int nreturn_vals = 0;
|
||||
|
||||
gimp_install_procedure("plug_in_randomize",
|
||||
"Add a random factor to the image, by blurring, picking a nearby pixel, slurring (similar to melting), or just hurling on it.",
|
||||
"This function randomly ``blurs'' the specified drawable, using either a 3x3 blur, picking a nearby pixel, slurring (cheezy melting), or hurling (spewing colors). The type and percentage are user selectable. Blurring is not supported for indexed images.",
|
||||
"Miles O'Neal",
|
||||
"Miles O'Neal, Spencer Kimball, Peter Mattis, Torsten Martinsen, Brian Degenhardt, Federico Mena Quintero",
|
||||
"1995-1997",
|
||||
const char *blurb = "Add a random factor to the image, by blurring, picking a nearby pixel, slurring (similar to melting), or just hurling on it.";
|
||||
const char *help = "This function randomly ``blurs'' the specified drawable, using either a 3x3 blur, picking a nearby pixel, slurring (cheezy melting), or hurling (spewing colors). The type and percentage are user selectable. Blurring is not supported for indexed images.";
|
||||
const char *author = "Miles O'Neal <meo@rru.com> http://www.rru.com/~meo/";
|
||||
const char *copyrights = "Miles O'Neal, Spencer Kimball, Peter Mattis, Torsten Martinsen, Brian Degenhardt, Federico Mena Quintero, Stephen Norris, Daniel Cotting";
|
||||
const char *copyright_date = "1995-1997";
|
||||
|
||||
gimp_install_procedure(PLUG_IN_NAME,
|
||||
(char *) blurb,
|
||||
(char *) help,
|
||||
(char *) author,
|
||||
(char *) copyrights,
|
||||
(char *) copyright_date,
|
||||
"<Image>/Filters/Distorts/Randomize",
|
||||
"RGB*, GRAY*, INDEXED*",
|
||||
PROC_PLUG_IN,
|
||||
|
|
@ -292,12 +329,12 @@ run(char *name, int nparams, GParam *param, int *nreturn_vals,
|
|||
GParam **return_vals)
|
||||
{
|
||||
|
||||
static GParam values[1];
|
||||
GDrawable *drawable;
|
||||
GRunModeType run_mode;
|
||||
GStatusType status = STATUS_SUCCESS; /* assume the best! */
|
||||
char *rndm_type_str = '\0';
|
||||
char prog_label[32];
|
||||
static GParam values[1];
|
||||
/*
|
||||
* Get the specified drawable, do standard initialization.
|
||||
*/
|
||||
|
|
@ -321,7 +358,7 @@ run(char *name, int nparams, GParam *param, int *nreturn_vals,
|
|||
*/
|
||||
case RUN_INTERACTIVE:
|
||||
FIX_INDEX_BLUR();
|
||||
gimp_get_data("plug_in_randomize", &pivals);
|
||||
gimp_get_data(PLUG_IN_NAME, &pivals);
|
||||
if (!randomize_dialog()) /* return on Cancel */
|
||||
return;
|
||||
break;
|
||||
|
|
@ -355,7 +392,7 @@ run(char *name, int nparams, GParam *param, int *nreturn_vals,
|
|||
* If we're running with the last set of values, get those values.
|
||||
*/
|
||||
case RUN_WITH_LAST_VALS:
|
||||
gimp_get_data("plug_in_randomize", &pivals);
|
||||
gimp_get_data(PLUG_IN_NAME, &pivals);
|
||||
break;
|
||||
/*
|
||||
* Hopefully we never get here!
|
||||
|
|
@ -376,7 +413,7 @@ run(char *name, int nparams, GParam *param, int *nreturn_vals,
|
|||
gimp_progress_init(prog_label);
|
||||
gimp_tile_cache_ntiles(2 * (drawable->width / gimp_tile_width() + 1));
|
||||
/*
|
||||
* Initialie the rand() function seed
|
||||
* Initialize the rand() function seed
|
||||
*/
|
||||
if (pivals.seed_type == SEED_TIME)
|
||||
srand(time(NULL));
|
||||
|
|
@ -394,7 +431,7 @@ run(char *name, int nparams, GParam *param, int *nreturn_vals,
|
|||
* If we use the dialog popup, set the data for future use.
|
||||
*/
|
||||
if (run_mode == RUN_INTERACTIVE) {
|
||||
gimp_set_data("plug_in_randomize", &pivals, sizeof(RandomizeVals));
|
||||
gimp_set_data(PLUG_IN_NAME, &pivals, sizeof(RandomizeVals));
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
|
|
@ -420,7 +457,7 @@ run(char *name, int nparams, GParam *param, int *nreturn_vals,
|
|||
*
|
||||
********************************/
|
||||
|
||||
#if (SUBS_NOT_DEFINES == 1)
|
||||
#if (OPTIMIZE_SUBS == 0)
|
||||
static void
|
||||
randomize_prepare_row(GPixelRgn *pixel_rgn, guchar *data, int x, int y, int w)
|
||||
{
|
||||
|
|
@ -474,7 +511,7 @@ randomize_prepare_row(GPixelRgn *pixel_rgn, guchar *data, int x, int y, int w)
|
|||
static void
|
||||
randomize(GDrawable *drawable)
|
||||
{
|
||||
GPixelRgn srcPR, destPR;
|
||||
GPixelRgn srcPR, destPR, destPR2, *sp, *dp, *tp;
|
||||
gint width, height;
|
||||
gint bytes;
|
||||
guchar *dest, *d;
|
||||
|
|
@ -509,27 +546,32 @@ randomize(GDrawable *drawable)
|
|||
next_row = (guchar *) malloc((x2 - x1 + 2) * bytes);
|
||||
dest = (guchar *) malloc((x2 - x1) * bytes);
|
||||
|
||||
for (cnt = 1; cnt <= pivals.rndm_rcount; cnt++) {
|
||||
/*
|
||||
* initialize the pixel regions
|
||||
*/
|
||||
gimp_pixel_rgn_init(&srcPR, drawable, 0, 0, width, height, FALSE, FALSE);
|
||||
gimp_pixel_rgn_init(&destPR, drawable, 0, 0, width, height, TRUE, TRUE);
|
||||
gimp_pixel_rgn_init(&srcPR, drawable, 0, 0, width, height, FALSE, FALSE);
|
||||
gimp_pixel_rgn_init(&destPR, drawable, 0, 0, width, height, TRUE, TRUE);
|
||||
gimp_pixel_rgn_init(&destPR2, drawable, 0, 0, width, height, TRUE, TRUE);
|
||||
sp = &srcPR;
|
||||
dp = &destPR;
|
||||
tp = NULL;
|
||||
|
||||
pr = prev_row + bytes;
|
||||
cr = cur_row + bytes;
|
||||
nr = next_row + bytes;
|
||||
pr = prev_row + bytes;
|
||||
cr = cur_row + bytes;
|
||||
nr = next_row + bytes;
|
||||
|
||||
for (cnt = 1; cnt <= pivals.rndm_rcount; cnt++) {
|
||||
/*
|
||||
* prepare the first row and previous row
|
||||
*/
|
||||
randomize_prepare_row(&srcPR, pr, x1, y1 - 1, (x2 - x1));
|
||||
randomize_prepare_row(&srcPR, cr, x1, y1, (x2 - x1));
|
||||
randomize_prepare_row(sp, pr, x1, y1 - 1, (x2 - x1));
|
||||
randomize_prepare_row(dp, cr, x1, y1, (x2 - x1));
|
||||
/*
|
||||
* loop through the rows, applying the selected convolution
|
||||
*/
|
||||
for (row = y1; row < y2; row++) {
|
||||
/* prepare the next row */
|
||||
randomize_prepare_row(&srcPR, nr, x1, row + 1, (x2 - x1));
|
||||
randomize_prepare_row(sp, nr, x1, row + 1, (x2 - x1));
|
||||
|
||||
d = dest;
|
||||
for (col = 0; col < (x2 - x1) * bytes; col++) {
|
||||
|
|
@ -621,7 +663,7 @@ randomize(GDrawable *drawable)
|
|||
* Save the modified row, shuffle the row pointers, and every
|
||||
* so often, update the progress meter.
|
||||
*/
|
||||
gimp_pixel_rgn_set_row(&destPR, dest, x1, row, (x2 - x1));
|
||||
gimp_pixel_rgn_set_row(dp, dest, x1, row, (x2 - x1));
|
||||
|
||||
tmp = pr;
|
||||
pr = cr;
|
||||
|
|
@ -631,6 +673,20 @@ randomize(GDrawable *drawable)
|
|||
if (PROG_UPDATE_TIME)
|
||||
gimp_progress_update((double) row / (double) (y2 - y1));
|
||||
}
|
||||
/*
|
||||
* if we have more cycles to perform, swap the src and dest Pixel Regions
|
||||
*/
|
||||
if (cnt < pivals.rndm_rcount) {
|
||||
if (tp != NULL) {
|
||||
tp = dp;
|
||||
dp = sp;
|
||||
sp = tp;
|
||||
} else {
|
||||
tp = &srcPR;
|
||||
sp = &destPR;
|
||||
dp = &destPR2;
|
||||
}
|
||||
}
|
||||
}
|
||||
gimp_progress_update((double) 100);
|
||||
/*
|
||||
|
|
@ -654,7 +710,7 @@ randomize(GDrawable *drawable)
|
|||
*
|
||||
********************************/
|
||||
|
||||
#define randomize_add_action_button(label, callback, dialog) \
|
||||
#define randomize_add_action_button(label, callback, dialog, tip) \
|
||||
{ \
|
||||
GtkWidget *button; \
|
||||
\
|
||||
|
|
@ -665,9 +721,10 @@ randomize(GDrawable *drawable)
|
|||
button, TRUE, TRUE, 0); \
|
||||
gtk_widget_grab_default(button); \
|
||||
gtk_widget_show(button); \
|
||||
set_tooltip(button, tip); \
|
||||
}
|
||||
|
||||
#define randomize_add_radio_button(group, label, box, callback, value) \
|
||||
#define randomize_add_radio_button(group, label, box, callback, value, tip) \
|
||||
{ \
|
||||
GtkWidget *toggle; \
|
||||
\
|
||||
|
|
@ -679,6 +736,7 @@ randomize(GDrawable *drawable)
|
|||
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(toggle), *value); \
|
||||
gtk_widget_show(toggle); \
|
||||
gtk_widget_show(box); \
|
||||
set_tooltip(toggle, tip); \
|
||||
}
|
||||
|
||||
/*********************************
|
||||
|
|
@ -723,13 +781,6 @@ randomize_dialog()
|
|||
gtk_window_position(GTK_WINDOW(dlg), GTK_WIN_POS_MOUSE);
|
||||
gtk_signal_connect(GTK_OBJECT(dlg), "destroy",
|
||||
(GtkSignalFunc) randomize_close_callback, NULL);
|
||||
/*
|
||||
* Action area OK & Cancel buttons
|
||||
*/
|
||||
randomize_add_action_button("OK",
|
||||
(GtkSignalFunc) randomize_ok_callback, dlg);
|
||||
randomize_add_action_button("Cancel",
|
||||
(GtkSignalFunc) randomize_cancel_callback, dlg);
|
||||
/*
|
||||
* Parameter settings
|
||||
*
|
||||
|
|
@ -742,6 +793,17 @@ randomize_dialog()
|
|||
table = gtk_table_new(4, 2, FALSE);
|
||||
gtk_container_border_width(GTK_CONTAINER(table), 10);
|
||||
gtk_container_add(GTK_CONTAINER(frame), table);
|
||||
gtk_widget_show(table);
|
||||
setup_tooltips(table);
|
||||
/*
|
||||
* Action area OK & Cancel buttons
|
||||
*/
|
||||
randomize_add_action_button("OK",
|
||||
(GtkSignalFunc) randomize_ok_callback, dlg,
|
||||
"Accept settings and apply filter to image");
|
||||
randomize_add_action_button("Cancel",
|
||||
(GtkSignalFunc) randomize_cancel_callback, dlg,
|
||||
"Close plug-in without making any changes");
|
||||
/*
|
||||
* Randomization Type - label & radio buttons
|
||||
*/
|
||||
|
|
@ -761,22 +823,25 @@ randomize_dialog()
|
|||
*/
|
||||
if (! is_indexed_drawable) {
|
||||
randomize_add_radio_button(type_group, "Blur", toggle_hbox,
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_blur);
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_blur,
|
||||
"Blur each pixel by averaging its value with those of its neighbors");
|
||||
}
|
||||
/*
|
||||
* Hurl, Pick and Slur buttons
|
||||
*/
|
||||
randomize_add_radio_button(type_group, "Hurl", toggle_hbox,
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_hurl);
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_hurl,
|
||||
"Hurl random colors onto pixels");
|
||||
randomize_add_radio_button(type_group, "Pick", toggle_hbox,
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_pick);
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_pick,
|
||||
"Pick at random from neighboring pixels");
|
||||
randomize_add_radio_button(type_group, "Slur", toggle_hbox,
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_slur);
|
||||
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_slur,
|
||||
"Simplistic melt");
|
||||
/*
|
||||
* Randomization seed initialization controls
|
||||
*/
|
||||
label = gtk_label_new("Seed");
|
||||
label = gtk_label_new("Randomization Seed");
|
||||
gtk_misc_set_alignment(GTK_MISC (label), 0.0, 0.5);
|
||||
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_FILL, 0, 5, 0);
|
||||
gtk_widget_show(label);
|
||||
|
|
@ -791,7 +856,8 @@ randomize_dialog()
|
|||
* Time button
|
||||
*/
|
||||
randomize_add_radio_button(seed_group, "Current Time", seed_vbox,
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_time);
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_time,
|
||||
"Seed random number generator from the current time - this guarantees a reasonable randomization");
|
||||
/*
|
||||
* Box to hold seed user initialization controls
|
||||
*/
|
||||
|
|
@ -801,10 +867,11 @@ randomize_dialog()
|
|||
/*
|
||||
* User button
|
||||
*/
|
||||
randomize_add_radio_button(seed_group, "User", seed_hbox,
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_user);
|
||||
randomize_add_radio_button(seed_group, "Other Value", seed_hbox,
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_user,
|
||||
"Enable user-entered value for random number generator seed - this allows you to repeat a given \"random\" operation");
|
||||
/*
|
||||
* Randomization seed text
|
||||
* Randomization seed number (text)
|
||||
*/
|
||||
entry = gtk_entry_new();
|
||||
gtk_widget_set_usize(entry, ENTRY_WIDTH, 0);
|
||||
|
|
@ -814,8 +881,8 @@ randomize_dialog()
|
|||
gtk_signal_connect(GTK_OBJECT(entry), "changed",
|
||||
(GtkSignalFunc) randomize_text_update, &pivals.rndm_seed);
|
||||
gtk_widget_show(entry);
|
||||
set_tooltip(entry, "Value for seeding the random number generator");
|
||||
gtk_widget_show(seed_hbox);
|
||||
|
||||
/*
|
||||
* Randomization percentage label & scale (1 to 100)
|
||||
*/
|
||||
|
|
@ -837,6 +904,7 @@ randomize_dialog()
|
|||
(GtkSignalFunc) randomize_scale_update, &pivals.rndm_pct);
|
||||
gtk_widget_show(label);
|
||||
gtk_widget_show(scale);
|
||||
set_tooltip(scale, "Percentage of pixels to be filtered");
|
||||
/*
|
||||
* Repeat count label & scale (1 to 100)
|
||||
*/
|
||||
|
|
@ -858,11 +926,11 @@ randomize_dialog()
|
|||
(GtkSignalFunc) randomize_scale_update, &pivals.rndm_rcount);
|
||||
gtk_widget_show(label);
|
||||
gtk_widget_show(scale);
|
||||
set_tooltip(scale, "Number of times to apply filter");
|
||||
/*
|
||||
* Display everything.
|
||||
*/
|
||||
gtk_widget_show(frame);
|
||||
gtk_widget_show(table);
|
||||
gtk_widget_show(dlg);
|
||||
|
||||
gtk_main();
|
||||
|
|
@ -898,28 +966,42 @@ randomize_dialog()
|
|||
*
|
||||
********************************/
|
||||
|
||||
/*
|
||||
* DESTROY callback
|
||||
*/
|
||||
static void
|
||||
randomize_close_callback(GtkWidget *widget, gpointer data) {
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
/*
|
||||
* OK BUTTON callback
|
||||
*/
|
||||
static void
|
||||
randomize_ok_callback(GtkWidget *widget, gpointer data) {
|
||||
rndm_int.run = TRUE;
|
||||
gtk_widget_destroy(GTK_WIDGET(data));
|
||||
}
|
||||
|
||||
/*
|
||||
* CANCEL BUTTON callback
|
||||
*/
|
||||
static void
|
||||
randomize_cancel_callback(GtkWidget *widget, gpointer data) {
|
||||
gtk_widget_destroy(GTK_WIDGET(data));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* SCALE UPDATE callback
|
||||
*/
|
||||
static void
|
||||
randomize_scale_update(GtkAdjustment *adjustment, double *scale_val) {
|
||||
*scale_val = adjustment->value;
|
||||
}
|
||||
|
||||
/*
|
||||
* TOGGLE UPDATE callback
|
||||
*/
|
||||
static void
|
||||
randomize_toggle_update(GtkWidget *widget, gpointer data) {
|
||||
int *toggle_val;
|
||||
|
|
@ -932,6 +1014,9 @@ randomize_toggle_update(GtkWidget *widget, gpointer data) {
|
|||
*toggle_val = FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* TEXT UPDATE callback
|
||||
*/
|
||||
static void
|
||||
randomize_text_update(GtkWidget *widget, gpointer data) {
|
||||
gint *text_val;
|
||||
|
|
@ -940,3 +1025,39 @@ randomize_text_update(GtkWidget *widget, gpointer data) {
|
|||
|
||||
*text_val = atoi(gtk_entry_get_text(GTK_ENTRY(widget)));
|
||||
}
|
||||
|
||||
/*
|
||||
* TOOLTIPS ROUTINES
|
||||
*/
|
||||
static GtkTooltips *tips;
|
||||
|
||||
|
||||
void setup_tooltips(GtkWidget *parent)
|
||||
{
|
||||
static GdkColor tips_fg, tips_bg;
|
||||
|
||||
tips = gtk_tooltips_new();
|
||||
|
||||
/* black as foreground: */
|
||||
|
||||
tips_fg.red = 0;
|
||||
tips_fg.green = 0;
|
||||
tips_fg.blue = 0;
|
||||
gdk_color_alloc(gtk_widget_get_colormap(parent), &tips_fg);
|
||||
|
||||
/* postit yellow (khaki) as background: */
|
||||
|
||||
tips_bg.red = 61669;
|
||||
tips_bg.green = 59113;
|
||||
tips_bg.blue = 35979;
|
||||
gdk_color_alloc(gtk_widget_get_colormap(parent), &tips_bg);
|
||||
|
||||
gtk_tooltips_set_colors(tips, &tips_bg, &tips_fg);
|
||||
}
|
||||
|
||||
|
||||
void set_tooltip(GtkWidget *widget, const char *tip)
|
||||
{
|
||||
if (tip && tip[0])
|
||||
gtk_tooltips_set_tips(tips, widget, (char *) tip);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,17 @@
|
|||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
revision history
|
||||
|
||||
Fri Nov 28 1997 - added template image
|
||||
|
||||
Sun Nov 16 1997 - listbox to select multiple inputs
|
||||
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
|
@ -27,14 +38,14 @@
|
|||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "gtk/gtk.h"
|
||||
#include "libgimp/gimp.h"
|
||||
#include "libgimp/gimpmenu.h"
|
||||
#include "libgimp/gimpwire.h"
|
||||
#include "gck/gck.h"
|
||||
|
||||
|
||||
/* Declare local functions. */
|
||||
static void query(void);
|
||||
static void run(char *name,
|
||||
int nparams,
|
||||
|
|
@ -65,25 +76,36 @@ int run_flag = 0;
|
|||
|
||||
|
||||
GtkWidget *dlg;
|
||||
GckListBox *listbox;
|
||||
|
||||
#define preview_size 200
|
||||
|
||||
#define preview_size 150
|
||||
GtkWidget *preview;
|
||||
|
||||
GDrawable *drawable;
|
||||
|
||||
#define max_inputs 100
|
||||
|
||||
struct {
|
||||
gint32 input_image_id;
|
||||
int ninputs;
|
||||
gint32 input_image_ids[max_inputs];
|
||||
int tile_size;
|
||||
int overlap;
|
||||
int order;
|
||||
int acceleration;
|
||||
int search_time;
|
||||
int use_template;
|
||||
double template_weight; /* in [0,10] */
|
||||
} config = {
|
||||
-1,
|
||||
0,
|
||||
{0},
|
||||
25,
|
||||
8,
|
||||
0,
|
||||
0,
|
||||
10
|
||||
10,
|
||||
0,
|
||||
0.5,
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -107,7 +129,7 @@ static void query()
|
|||
"uhm, image dissociation",
|
||||
"Scott Draves",
|
||||
"Scott Draves",
|
||||
"1997",
|
||||
"Nov 1997",
|
||||
"<Image>/Filters/Transforms/Fuse",
|
||||
"RGB*",
|
||||
PROC_PLUG_IN,
|
||||
|
|
@ -115,11 +137,11 @@ static void query()
|
|||
args, return_vals);
|
||||
}
|
||||
|
||||
static void run(char *name, int n_params, GParam * param, int *nreturn_vals,
|
||||
GParam ** return_vals)
|
||||
static void
|
||||
run(char *name, int n_params, GParam * param, int *nreturn_vals,
|
||||
GParam ** return_vals)
|
||||
{
|
||||
static GParam values[1];
|
||||
GDrawable *drawable;
|
||||
GRunModeType run_mode;
|
||||
GStatusType status = STATUS_SUCCESS;
|
||||
|
||||
|
|
@ -148,14 +170,7 @@ static void run(char *name, int n_params, GParam * param, int *nreturn_vals,
|
|||
if (status == STATUS_SUCCESS) {
|
||||
|
||||
if (gimp_drawable_color(drawable->id)) {
|
||||
gimp_progress_init("Fusing...");
|
||||
gimp_tile_cache_ntiles(2 * (drawable->width / gimp_tile_width() + 1));
|
||||
|
||||
doit(drawable);
|
||||
|
||||
if (run_mode != RUN_NONINTERACTIVE)
|
||||
gimp_displays_flush();
|
||||
gimp_set_data("plug_in_fuse", &config, sizeof(config));
|
||||
;
|
||||
} else {
|
||||
status = STATUS_EXECUTION_ERROR;
|
||||
}
|
||||
|
|
@ -177,19 +192,20 @@ compare(image *in, image *out) {
|
|||
pixel *q = out->pixels + y * out->stride;
|
||||
for (x = 0; x < in->width; x++) {
|
||||
double rr, z;
|
||||
guchar *i = (guchar *) p;
|
||||
guchar *o = (guchar *) q;
|
||||
int d = i[0] - (int) o[0];
|
||||
z = i[3] * o[3];
|
||||
guchar *i = (guchar *) (&p[x]);
|
||||
guchar *o = (guchar *) (&q[x]);
|
||||
int d;
|
||||
if (0 == i[3] || 0 == o[3])
|
||||
continue;
|
||||
d = i[0] - (int) o[0];
|
||||
rr = d * d;
|
||||
d = i[1] - o[1];
|
||||
d = i[1] - (int) o[1];
|
||||
rr += d * d;
|
||||
d = i[2] - o[2];
|
||||
d = i[2] - (int) o[2];
|
||||
rr += d * d;
|
||||
z = i[3] * (double) o[3];
|
||||
r += rr * z;
|
||||
t += z;
|
||||
t += z * z; /* z * 255? */
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -207,8 +223,8 @@ blit(image *dst, image *src) {
|
|||
pixel *p = dst->pixels + y * dst->stride;
|
||||
pixel *q = src->pixels + y * src->stride;
|
||||
for (x = 0; x < src->width; x++) {
|
||||
guchar *o = (guchar *) p;
|
||||
guchar *i = (guchar *) q;
|
||||
guchar *o = (guchar *) (&p[x]);
|
||||
guchar *i = (guchar *) (&q[x]);
|
||||
int s = i[3];
|
||||
if (255 == s)
|
||||
p[x] = q[x];
|
||||
|
|
@ -221,11 +237,13 @@ blit(image *dst, image *src) {
|
|||
}
|
||||
}
|
||||
|
||||
/* find tile somewhere in IN that matches OUT and TEMPLATE */
|
||||
void
|
||||
source_match(image *in, image *out) {
|
||||
source_match(image *in, image *out, image *template) {
|
||||
int i;
|
||||
double best_d = HUGE;
|
||||
image best_tile;
|
||||
double w = exp(-0.3 * (10-config.template_weight));
|
||||
|
||||
if (0 == out->width || 0 == out->height)
|
||||
return;
|
||||
|
|
@ -237,15 +255,25 @@ source_match(image *in, image *out) {
|
|||
tile.pixels =
|
||||
in->pixels + (random() % (in->width - out->width)) +
|
||||
in->stride * (random() % (in->height - out->height));
|
||||
|
||||
tile.stride = in->stride;
|
||||
tile.width = out->width;
|
||||
tile.height = out->height;
|
||||
|
||||
d = compare(&tile, out);
|
||||
if (d < 0.0) {
|
||||
/* should really only happen with null overlap */
|
||||
best_tile = tile;
|
||||
break;
|
||||
}
|
||||
if (template) {
|
||||
double e = compare(&tile, template);
|
||||
if (e < 0.0)
|
||||
printf("e less than zero\n");
|
||||
else
|
||||
d = (d * (1.0 - w) + e * w);
|
||||
}
|
||||
|
||||
if (d < best_d) {
|
||||
best_d = d;
|
||||
best_tile = tile;
|
||||
|
|
@ -256,7 +284,7 @@ source_match(image *in, image *out) {
|
|||
|
||||
|
||||
void
|
||||
do_fuse(image *in, image *out) {
|
||||
do_fuse(int nin, image *ins, image *out, image *template) {
|
||||
int i, parity = 0;
|
||||
double r, rad;
|
||||
double bo;
|
||||
|
|
@ -264,9 +292,12 @@ do_fuse(image *in, image *out) {
|
|||
|
||||
bo = config.tile_size - config.overlap;
|
||||
|
||||
if (config.tile_size >= in->width ||
|
||||
config.tile_size >= in->height)
|
||||
return;
|
||||
for (i = 0; i < nin; i++)
|
||||
if (config.tile_size >= ins[i].width ||
|
||||
config.tile_size >= ins[i].height) {
|
||||
printf("input smaller than tile - bailing\n");
|
||||
return;
|
||||
}
|
||||
|
||||
rad = sqrt(out->width * out->width +
|
||||
out->height * out->height) / 2;
|
||||
|
|
@ -286,7 +317,7 @@ do_fuse(image *in, image *out) {
|
|||
}
|
||||
parity++;
|
||||
for (i = 0; i < n; i++) {
|
||||
image tile;
|
||||
image tile, template_tile;
|
||||
int x, y, w, h;
|
||||
double theta = 2.0 * M_PI * prmute[i] / n;
|
||||
if (parity&1)
|
||||
|
|
@ -302,18 +333,55 @@ do_fuse(image *in, image *out) {
|
|||
if (x > out->width - w) w = out->width - x;
|
||||
if (y > out->height - h) h = out->height - y;
|
||||
|
||||
if (w <= 0 || h <= 0)
|
||||
continue;
|
||||
|
||||
tile.pixels = out->pixels + y * out->stride + x;
|
||||
tile.stride = out->stride;
|
||||
tile.width = w;
|
||||
tile.height = h;
|
||||
|
||||
source_match(in, &tile);
|
||||
if (0) {
|
||||
int y;
|
||||
for (y = 0; y < preview_size; y++)
|
||||
if (template) {
|
||||
template_tile.pixels = template->pixels + y * template->stride + x;
|
||||
template_tile.stride = template->stride;
|
||||
template_tile.width = w;
|
||||
template_tile.height = h;
|
||||
}
|
||||
|
||||
source_match(ins + (random()%nin), &tile,
|
||||
template ? &template_tile : NULL);
|
||||
if ((parity < 4) || ((i&7) == 0)) {
|
||||
int xx, yy;
|
||||
int cx, cy;
|
||||
guchar *buf = (guchar *) malloc(3 * preview_size);
|
||||
int p2 = preview_size/2;
|
||||
if (r < p2) {
|
||||
cx = out->width/2;
|
||||
cy = out->height/2;
|
||||
} else {
|
||||
cx = x;
|
||||
cy = y;
|
||||
}
|
||||
for (yy = cy-p2; yy < cy+p2; yy++) {
|
||||
for (xx = cx-p2; xx < cx+p2; xx++) {
|
||||
guchar *p = &buf[3*(xx-(cx-p2))];
|
||||
guchar *q = (guchar *)(out->pixels+yy*out->stride+xx);
|
||||
if ((xx < out->width) &&
|
||||
(xx >= 0) &&
|
||||
(yy < out->height) &&
|
||||
(yy >= 0)) {
|
||||
p[0] = q[0];
|
||||
p[1] = q[1];
|
||||
p[2] = q[2];
|
||||
} else {
|
||||
p[0] = p[1] = p[2] = 0;
|
||||
}
|
||||
}
|
||||
gtk_preview_draw_row(GTK_PREVIEW (preview),
|
||||
(guchar *)(out->pixels+y*out->stride),
|
||||
0, y, preview_size);
|
||||
buf, 0, (yy-(cy-p2)), preview_size);
|
||||
}
|
||||
free(buf);
|
||||
gtk_widget_draw (preview, NULL);
|
||||
}
|
||||
gimp_progress_update((1-i/(double)n) * r * r / (rad * rad) +
|
||||
i/(double)n * (r + bo) * (r + bo) / (rad * rad));
|
||||
|
|
@ -324,57 +392,151 @@ do_fuse(image *in, image *out) {
|
|||
|
||||
static void
|
||||
doit(GDrawable * target_drawable) {
|
||||
image in, out;
|
||||
image *in, out, template;
|
||||
gint bytes;
|
||||
GPixelRgn pr;
|
||||
GDrawable *input_drawable;
|
||||
int i;
|
||||
|
||||
in.width = gimp_image_width(config.input_image_id);
|
||||
in.height = gimp_image_height(config.input_image_id);
|
||||
in.stride = in.width;
|
||||
|
||||
|
||||
#if 0
|
||||
if (4 == bytes) {
|
||||
printf("using 4 channel image\n");
|
||||
}
|
||||
if (3 != bytes && 4 != bytes) {
|
||||
fprintf(stderr, "only works with three or four channels, not %d.\n", bytes);
|
||||
if (0 == config.ninputs) {
|
||||
printf("fuse needs at least one input\n");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* allocate and initialize input buffer */
|
||||
in = (image *) malloc(sizeof(image) * config.ninputs);
|
||||
|
||||
in.pixels = (pixel *) malloc(in.width * in.height * 4);
|
||||
if (in.pixels == NULL) {
|
||||
fprintf(stderr, "cannot malloc %d bytes for input.\n", in.width * in.height * 4);
|
||||
return;
|
||||
for (i = 0; i < config.ninputs; i++) {
|
||||
image *inp = &in[i];
|
||||
|
||||
inp->width = gimp_image_width(config.input_image_ids[i]);
|
||||
inp->height = gimp_image_height(config.input_image_ids[i]);
|
||||
inp->stride = inp->width;
|
||||
|
||||
/* allocate and initialize input buffer */
|
||||
|
||||
inp->pixels = (pixel *) malloc(inp->width * inp->height * 4);
|
||||
if (inp->pixels == NULL) {
|
||||
fprintf(stderr, "cannot malloc %d bytes for input.\n", inp->width * inp->height * 4);
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
int nlayers;
|
||||
gint32 *layer_ids;
|
||||
layer_ids = gimp_image_get_layers (config.input_image_ids[i], &nlayers);
|
||||
if ((NULL == layer_ids) || (nlayers <= 0)) {
|
||||
fprintf(stderr, "fuse: error getting layer IDs\n");
|
||||
return;
|
||||
}
|
||||
input_drawable = gimp_drawable_get(layer_ids[nlayers-1]);
|
||||
bytes = input_drawable->bpp;
|
||||
|
||||
gimp_pixel_rgn_init(&pr, input_drawable,
|
||||
0, 0, inp->width, inp->height, FALSE, FALSE);
|
||||
if (4 == bytes) {
|
||||
printf("4 channel image, using alpha\n");
|
||||
gimp_pixel_rgn_get_rect(&pr, (guchar *)inp->pixels, 0, 0, inp->width, inp->height);
|
||||
} else if (3 == bytes) {
|
||||
int i;
|
||||
guchar *tb = malloc (inp->width * bytes);
|
||||
for (i = 0; i < inp->height; i++) {
|
||||
int j;
|
||||
gimp_pixel_rgn_get_rect(&pr, tb, 0, i, inp->width, 1);
|
||||
for (j = 0; j < inp->width; j++) {
|
||||
guchar *d = (guchar *) (inp->pixels + (inp->width * i) + j);
|
||||
guchar *s = tb + j * bytes;
|
||||
d[0] = s[0];
|
||||
d[1] = s[1];
|
||||
d[2] = s[2];
|
||||
d[3] = 255;
|
||||
}
|
||||
}
|
||||
free(tb);
|
||||
} else if (1 == bytes) {
|
||||
int i;
|
||||
guchar *tb = malloc (inp->width * bytes);
|
||||
for (i = 0; i < inp->height; i++) {
|
||||
int j;
|
||||
gimp_pixel_rgn_get_rect(&pr, tb, 0, i, inp->width, 1);
|
||||
for (j = 0; j < inp->width; j++) {
|
||||
guchar *d = (guchar *) (inp->pixels + (inp->width * i) + j);
|
||||
guchar *s = tb + j * bytes;
|
||||
d[0] = d[1] = d[2] = s[0];
|
||||
d[3] = 255;
|
||||
}
|
||||
}
|
||||
free(tb);
|
||||
} else {
|
||||
printf("cannot handle image with %d bytes per pixel\n", bytes);
|
||||
}
|
||||
|
||||
|
||||
if (nlayers > 1) {
|
||||
input_drawable = gimp_drawable_get(layer_ids[0]);
|
||||
bytes = input_drawable->bpp;
|
||||
|
||||
gimp_pixel_rgn_init(&pr, input_drawable,
|
||||
0, 0, inp->width, inp->height, FALSE, FALSE);
|
||||
printf("looking for alpha\n");
|
||||
if (1 == bytes) {
|
||||
int i;
|
||||
guchar *tb = malloc (inp->width * bytes);
|
||||
printf("got alpha\n");
|
||||
for (i = 0; i < inp->height; i++) {
|
||||
int j;
|
||||
gimp_pixel_rgn_get_rect(&pr, tb, 0, i, inp->width, 1);
|
||||
for (j = 0; j < inp->width; j++) {
|
||||
guchar *d = (guchar *) (inp->pixels + (inp->width * i) + j);
|
||||
guchar *s = tb + j * bytes;
|
||||
d[3] = s[0];
|
||||
}
|
||||
}
|
||||
free(tb);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int nlayers;
|
||||
gint32 *layer_ids;
|
||||
layer_ids = gimp_image_get_layers (config.input_image_id, &nlayers);
|
||||
if ((NULL == layer_ids) || (nlayers <= 0)) {
|
||||
fprintf(stderr, "fuse: error getting layer IDs\n");
|
||||
out.width = target_drawable->width;
|
||||
out.height = target_drawable->height;
|
||||
out.stride = out.width;
|
||||
|
||||
out.pixels = (pixel *) malloc(out.width * out.height * 4);
|
||||
if (out.pixels == NULL) {
|
||||
fprintf(stderr, "cannot malloc %d bytes for output.\n",
|
||||
out.width * out.height * 4);
|
||||
return;
|
||||
}
|
||||
input_drawable = gimp_drawable_get(layer_ids[0]);
|
||||
bytes = input_drawable->bpp;
|
||||
}
|
||||
|
||||
if (config.use_template) {
|
||||
template.width = target_drawable->width;
|
||||
template.height = target_drawable->height;
|
||||
template.stride = template.width;
|
||||
template.pixels = (pixel *) malloc(template.width * template.height * 4);
|
||||
if (template.pixels == NULL) {
|
||||
fprintf(stderr, "cannot malloc %d bytes for output.\n",
|
||||
template.width * template.height * 4);
|
||||
return;
|
||||
}
|
||||
|
||||
bytes = target_drawable->bpp;
|
||||
|
||||
gimp_pixel_rgn_init(&pr, input_drawable,
|
||||
0, 0, in.width, in.height, FALSE, FALSE);
|
||||
if (4 == bytes)
|
||||
gimp_pixel_rgn_get_rect(&pr, (guchar *)in.pixels, 0, 0, in.width, in.height);
|
||||
else if (3 == bytes) {
|
||||
gimp_pixel_rgn_init(&pr, target_drawable,
|
||||
0, 0, template.width, template.height, FALSE, FALSE);
|
||||
if (4 == bytes) {
|
||||
printf("4 channel image, using alpha\n");
|
||||
gimp_pixel_rgn_get_rect(&pr, (guchar *)template.pixels, 0, 0, template.width, template.height);
|
||||
} else if (3 == bytes) {
|
||||
int i;
|
||||
guchar *tb = malloc (in.width * bytes);
|
||||
for (i = 0; i < in.height; i++) {
|
||||
guchar *tb = malloc (template.width * bytes);
|
||||
for (i = 0; i < template.height; i++) {
|
||||
int j;
|
||||
gimp_pixel_rgn_get_rect(&pr, tb, 0, i, in.width, 1);
|
||||
for (j = 0; j < in.width; j++) {
|
||||
guchar *d = (guchar *) (in.pixels + (in.width * i) + j);
|
||||
gimp_pixel_rgn_get_rect(&pr, tb, 0, i, template.width, 1);
|
||||
for (j = 0; j < template.width; j++) {
|
||||
guchar *d = (guchar *) (template.pixels + (template.width * i) + j);
|
||||
guchar *s = tb + j * bytes;
|
||||
d[0] = s[0];
|
||||
d[1] = s[1];
|
||||
|
|
@ -383,49 +545,20 @@ doit(GDrawable * target_drawable) {
|
|||
}
|
||||
}
|
||||
free(tb);
|
||||
} else if (1 == bytes) {
|
||||
int i;
|
||||
guchar *tb = malloc (in.width * bytes);
|
||||
for (i = 0; i < in.height; i++) {
|
||||
int j;
|
||||
gimp_pixel_rgn_get_rect(&pr, tb, 0, i, in.width, 1);
|
||||
for (j = 0; j < in.width; j++) {
|
||||
guchar *d = (guchar *) (in.pixels + (in.width * i) + j);
|
||||
guchar *s = tb + j * bytes;
|
||||
d[0] = d[1] = d[2] = s[0];
|
||||
d[3] = 255;
|
||||
}
|
||||
}
|
||||
free(tb);
|
||||
}
|
||||
}
|
||||
|
||||
out.width = target_drawable->width;
|
||||
out.height = target_drawable->height;
|
||||
out.stride = out.width;
|
||||
|
||||
out.pixels = (pixel *) malloc(out.width * out.height * 4);
|
||||
if (out.pixels == NULL) {
|
||||
fprintf(stderr, "cannot malloc %d bytes for output.\n",
|
||||
out.width * out.height * 4);
|
||||
return;
|
||||
}
|
||||
|
||||
if (1)
|
||||
do_fuse(&in, &out);
|
||||
else {
|
||||
int i, j;
|
||||
for (i = 0; i < out.height; i++)
|
||||
for (j = 0; j < out.width; j++)
|
||||
out.pixels[i * out.stride + j] = random();
|
||||
}
|
||||
|
||||
do_fuse(config.ninputs, in, &out,
|
||||
config.use_template ? &template : NULL);
|
||||
|
||||
gimp_pixel_rgn_init(&pr, target_drawable,
|
||||
0, 0, out.width, out.height, FALSE, FALSE);
|
||||
|
||||
bytes = target_drawable->bpp;
|
||||
|
||||
|
||||
if (4 == bytes) {
|
||||
gimp_pixel_rgn_set_rect(&pr, (guchar *)out.pixels, 0, 0, out.width, out.height);
|
||||
gimp_pixel_rgn_set_rect(&pr, (guchar *) out.pixels, 0, 0, out.width, out.height);
|
||||
} else {
|
||||
int i;
|
||||
guchar *tb = malloc (out.width * bytes);
|
||||
|
|
@ -448,6 +581,16 @@ doit(GDrawable * target_drawable) {
|
|||
*/
|
||||
gimp_drawable_update(target_drawable->id, 0, 0,
|
||||
target_drawable->width, target_drawable->height);
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < config.ninputs; i++)
|
||||
free(in[i].pixels);
|
||||
free(in);
|
||||
|
||||
free(out.pixels);
|
||||
if (config.use_template)
|
||||
free(template.pixels);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -458,8 +601,34 @@ static void close_callback(GtkWidget * widget, gpointer data)
|
|||
|
||||
static void ok_callback(GtkWidget * widget, gpointer data)
|
||||
{
|
||||
GList *sel;
|
||||
int n;
|
||||
run_flag = 1;
|
||||
gtk_widget_destroy(GTK_WIDGET(data));
|
||||
|
||||
if (gimp_drawable_color(drawable->id)) {
|
||||
|
||||
sel = gck_listbox_get_current_selection(listbox);
|
||||
|
||||
n = 0;
|
||||
while (sel != NULL && n < max_inputs) {
|
||||
|
||||
config.input_image_ids[n] =
|
||||
((GckListBoxItem *) sel->data)->user_data;
|
||||
sel = sel->next;
|
||||
n++;
|
||||
}
|
||||
config.ninputs = n;
|
||||
|
||||
gimp_progress_init("Fusing...");
|
||||
gimp_tile_cache_ntiles(2 * (drawable->width / gimp_tile_width() + 1));
|
||||
|
||||
doit(drawable);
|
||||
|
||||
gtk_widget_destroy(dlg);
|
||||
|
||||
gimp_displays_flush();
|
||||
gimp_set_data("plug_in_fuse", &config, sizeof(config));
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
|
|
@ -472,13 +641,6 @@ not_indexed_constrain (gint32 image_id, gint32 drawable_id, gpointer data) {
|
|||
return INDEXED != gimp_image_base_type (image_id);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
input_callback(gint32 id, gpointer data) {
|
||||
config.input_image_id = id;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
overlap_callback (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
|
|
@ -505,12 +667,42 @@ search_time_callback (GtkWidget *widget, gpointer data)
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
toggle_callback (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
int *toggle_val;
|
||||
|
||||
toggle_val = (int *) data;
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
*toggle_val = TRUE;
|
||||
else
|
||||
*toggle_val = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
scale_callback (GtkAdjustment *adjustment, gpointer data)
|
||||
{
|
||||
* (double *) data = adjustment->value;
|
||||
}
|
||||
|
||||
static char*
|
||||
gimp_base_name (char *str)
|
||||
{
|
||||
char *t;
|
||||
|
||||
t = strrchr (str, '/');
|
||||
if (!t)
|
||||
return str;
|
||||
return t+1;
|
||||
}
|
||||
|
||||
static gint dialog() {
|
||||
GtkWidget *frame;
|
||||
GtkWidget *button;
|
||||
GtkWidget *table;
|
||||
GtkWidget *box;
|
||||
GtkWidget *w;
|
||||
GtkWidget *frame;
|
||||
gchar **argv;
|
||||
gint argc;
|
||||
int row;
|
||||
|
|
@ -557,29 +749,56 @@ static gint dialog() {
|
|||
|
||||
box = GTK_DIALOG(dlg)->vbox;
|
||||
|
||||
|
||||
{
|
||||
GtkWidget *menu;
|
||||
GtkWidget *menuitem;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *option_menu = gtk_option_menu_new ();
|
||||
gint32 *images;
|
||||
int i, k, nimages;
|
||||
|
||||
frame = gtk_frame_new("Source Images");
|
||||
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
|
||||
gtk_container_border_width(GTK_CONTAINER(frame), 10);
|
||||
gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 10);
|
||||
gtk_widget_show(frame);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 5);
|
||||
gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 10);
|
||||
gtk_widget_show(hbox);
|
||||
listbox = gck_listbox_new(frame, TRUE, TRUE, 10, 150, 150,
|
||||
GTK_SELECTION_MULTIPLE, NULL,
|
||||
NULL /* event_handler */);
|
||||
|
||||
w = gtk_label_new("Tile Source:");
|
||||
gtk_misc_set_alignment(GTK_MISC(w), 0.0, 0.5);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), w, TRUE, TRUE, 10);
|
||||
gtk_widget_show(w);
|
||||
|
||||
images = gimp_query_images (&nimages);
|
||||
for (i = 0, k = 0; i < nimages; i++) {
|
||||
if (not_indexed_constrain(images[i], 0, 0)) {
|
||||
int j;
|
||||
GckListBoxItem item;
|
||||
char *filename;
|
||||
filename = gimp_image_get_filename (images[i]);
|
||||
item.label = g_new (char, strlen (filename) + 16);
|
||||
sprintf (item.label, "%s-%d", gimp_base_name (filename), images[i]);
|
||||
g_free (filename);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(hbox), option_menu, TRUE, TRUE, 10);
|
||||
menu = gimp_image_menu_new(not_indexed_constrain, input_callback,
|
||||
0, config.input_image_id);
|
||||
|
||||
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
|
||||
gtk_widget_show (option_menu);
|
||||
item.widget = NULL;
|
||||
item.user_data = (gpointer) images[i];
|
||||
item.listbox = NULL;
|
||||
gck_listbox_insert_item(listbox, &item, k);
|
||||
g_free(item.label);
|
||||
for (j = 0; j < config.ninputs; j++)
|
||||
if (images[i] == config.input_image_ids[j])
|
||||
(void) gck_listbox_select_item_by_position(listbox, k);
|
||||
k++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
frame = gtk_frame_new("Parameters");
|
||||
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
|
||||
gtk_container_border_width(GTK_CONTAINER(frame), 10);
|
||||
gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 10);
|
||||
gtk_widget_show(frame);
|
||||
|
||||
box = gtk_vbox_new (FALSE, 5);
|
||||
gtk_container_add(GTK_CONTAINER(frame), box);
|
||||
gtk_widget_show (box);
|
||||
|
||||
{
|
||||
GtkWidget *label;
|
||||
GtkWidget *entry;
|
||||
|
|
@ -654,6 +873,63 @@ static gint dialog() {
|
|||
gtk_widget_show (hbox);
|
||||
}
|
||||
|
||||
{
|
||||
GtkWidget *toggle;
|
||||
toggle = gtk_check_button_new_with_label ("use target as template");
|
||||
gtk_box_pack_start(GTK_BOX(box), toggle, FALSE, FALSE, 0);
|
||||
gtk_signal_connect (GTK_OBJECT (toggle), "toggled",
|
||||
(GtkSignalFunc) toggle_callback,
|
||||
&config.use_template);
|
||||
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (toggle), (config.use_template));
|
||||
gtk_widget_show (toggle);
|
||||
}
|
||||
|
||||
{
|
||||
GtkWidget *label;
|
||||
GtkWidget *scale;
|
||||
GtkObject *scale_data;
|
||||
GtkWidget *hbox;
|
||||
char buffer[20];
|
||||
hbox = gtk_hbox_new (FALSE, 5);
|
||||
gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
|
||||
|
||||
label = gtk_label_new ("Template weight: ");
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
scale_data = gtk_adjustment_new (config.template_weight, 0.0, 10.0,
|
||||
0.01, 0.01, 0.0);
|
||||
scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data));
|
||||
gtk_widget_set_usize (scale, 150, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0);
|
||||
gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP);
|
||||
gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED);
|
||||
gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed",
|
||||
(GtkSignalFunc) scale_callback,
|
||||
&config.template_weight);
|
||||
gtk_widget_show (scale);
|
||||
|
||||
gtk_widget_show (hbox);
|
||||
}
|
||||
|
||||
box = GTK_DIALOG(dlg)->vbox;
|
||||
|
||||
{
|
||||
frame = gtk_frame_new("Preview");
|
||||
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
|
||||
gtk_container_border_width(GTK_CONTAINER(frame), 10);
|
||||
gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 10);
|
||||
gtk_widget_show(frame);
|
||||
|
||||
|
||||
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (preview), preview_size, preview_size);
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(frame), preview);
|
||||
|
||||
gtk_widget_show (preview);
|
||||
}
|
||||
|
||||
gtk_widget_show(dlg);
|
||||
gtk_main();
|
||||
gdk_flush();
|
||||
|
|
|
|||
|
|
@ -1,361 +0,0 @@
|
|||
# Generated automatically from Makefile.in by configure.
|
||||
# Makefile.in generated automatically by automake 1.2c from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
srcdir = .
|
||||
top_srcdir = ../..
|
||||
prefix = /usr
|
||||
exec_prefix = ${prefix}
|
||||
|
||||
bindir = ${exec_prefix}/bin
|
||||
sbindir = ${exec_prefix}/sbin
|
||||
libexecdir = ${exec_prefix}/libexec
|
||||
datadir = ${prefix}/share
|
||||
sysconfdir = ${prefix}/etc
|
||||
sharedstatedir = ${prefix}/com
|
||||
localstatedir = ${prefix}/var
|
||||
libdir = ${exec_prefix}/lib
|
||||
infodir = ${prefix}/info
|
||||
mandir = ${prefix}/man
|
||||
includedir = ${prefix}/include
|
||||
oldincludedir = /usr/include
|
||||
|
||||
pkgdatadir = $(datadir)/gimp
|
||||
pkglibdir = $(libdir)/gimp
|
||||
pkgincludedir = $(includedir)/gimp
|
||||
|
||||
top_builddir = ../..
|
||||
|
||||
ACLOCAL = aclocal
|
||||
AUTOCONF = autoconf
|
||||
AUTOMAKE = automake
|
||||
AUTOHEADER = autoheader
|
||||
|
||||
INSTALL = /usr/bin/install -c
|
||||
INSTALL_PROGRAM = ${INSTALL}
|
||||
INSTALL_DATA = ${INSTALL} -m 644
|
||||
INSTALL_SCRIPT = ${INSTALL_PROGRAM}
|
||||
transform = s,x,x,
|
||||
|
||||
NORMAL_INSTALL = true
|
||||
PRE_INSTALL = true
|
||||
POST_INSTALL = true
|
||||
NORMAL_UNINSTALL = true
|
||||
PRE_UNINSTALL = true
|
||||
POST_UNINSTALL = true
|
||||
host_alias = i486-pc-linux-gnu
|
||||
host_triplet = i486-pc-linux-gnu
|
||||
CC = gcc
|
||||
CPP = gcc -E
|
||||
EMACS = /usr/bin/emacs
|
||||
GIMPTCL = gimptcl
|
||||
JPEG = jpeg
|
||||
LD = /usr/lib/gcc-lib/i386-linux/egcs-2.90.18/ld
|
||||
LIBJPEG_LIB = -ljpeg
|
||||
LIBMPEG_LIB =
|
||||
LIBPNG_LIB = -lpng -lz
|
||||
LIBTCL_LIB = -ltcl -ltk
|
||||
LIBTIFF_LIB = -ltiff
|
||||
LIBTOOL = $(SHELL) $(top_builddir)/libtool
|
||||
LIBXDELTA_LIB =
|
||||
LIBXPM_LIB = -lXpm
|
||||
LN_S = ln -s
|
||||
MAINT = #M#
|
||||
MAKEINFO = makeinfo
|
||||
MPEG =
|
||||
NM = /usr/bin/nm -B
|
||||
PACKAGE = gimp
|
||||
PNG = png
|
||||
RANLIB = ranlib
|
||||
TIFF = tiff
|
||||
VERSION = 0.99.15
|
||||
XD =
|
||||
XPM = xpm
|
||||
gimpdatadir = ${prefix}/share/gimp
|
||||
gimpdir = .gimp
|
||||
gimpplugindir = ${exec_prefix}/lib/gimp/0.99.15
|
||||
|
||||
pluginlibdir = $(gimpplugindir)/plug-ins
|
||||
|
||||
pluginlib_PROGRAMS = gfig
|
||||
|
||||
gfig_SOURCES = \
|
||||
gfig.c
|
||||
|
||||
INCLUDES = \
|
||||
$(X_CFLAGS) \
|
||||
-I$(top_srcdir) \
|
||||
-I$(includedir)
|
||||
|
||||
LDADD = \
|
||||
$(top_builddir)/libgimp/libgimpui.la \
|
||||
$(top_builddir)/libgimp/libgimp.la \
|
||||
$(X_LIBS) \
|
||||
-lc
|
||||
|
||||
DEPS = \
|
||||
$(top_builddir)/libgimp/libgimpui.la \
|
||||
$(top_builddir)/libgimp/libgimp.la
|
||||
|
||||
gfig_DEPENDENCIES = $(DEPS)
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../../config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
PROGRAMS = $(pluginlib_PROGRAMS)
|
||||
|
||||
|
||||
DEFS = -DHAVE_CONFIG_H -I. -I$(srcdir) -I../..
|
||||
CPPFLAGS =
|
||||
LDFLAGS = -L/usr/X11R6/lib -lgtk -lgdk -lglib -lXext -lX11 -lm
|
||||
LIBS =
|
||||
X_CFLAGS = -I/usr/X11R6/include
|
||||
X_LIBS = -L/usr/X11R6/lib -lgtk -lgdk -lglib -lXext -lX11 -lm
|
||||
X_EXTRA_LIBS =
|
||||
X_PRE_LIBS = -lSM -lICE
|
||||
gfig_OBJECTS = gfig.o
|
||||
gfig_LDADD = $(LDADD)
|
||||
gfig_LDFLAGS =
|
||||
CFLAGS = -I/usr/X11R6/include -g -O2 -Wall
|
||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
|
||||
LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
DIST_COMMON = README Makefile.am Makefile.in
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
GZIP = --best
|
||||
DEP_FILES = .deps/gfig.P
|
||||
SOURCES = $(gfig_SOURCES)
|
||||
OBJECTS = $(gfig_OBJECTS)
|
||||
|
||||
default: all
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .lo .o
|
||||
$(srcdir)/Makefile.in: #M# Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnu plug-ins/gfig/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
|
||||
mostlyclean-pluginlibPROGRAMS:
|
||||
|
||||
clean-pluginlibPROGRAMS:
|
||||
-test -z "$(pluginlib_PROGRAMS)" || rm -f $(pluginlib_PROGRAMS)
|
||||
|
||||
distclean-pluginlibPROGRAMS:
|
||||
|
||||
maintainer-clean-pluginlibPROGRAMS:
|
||||
|
||||
install-pluginlibPROGRAMS: $(pluginlib_PROGRAMS)
|
||||
@$(NORMAL_INSTALL)
|
||||
$(mkinstalldirs) $(pluginlibdir)
|
||||
@list='$(pluginlib_PROGRAMS)'; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(pluginlibdir)/`echo $$p|sed '$(transform)'`"; \
|
||||
$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(pluginlibdir)/`echo $$p|sed '$(transform)'`; \
|
||||
else :; fi; \
|
||||
done
|
||||
|
||||
uninstall-pluginlibPROGRAMS:
|
||||
$(NORMAL_UNINSTALL)
|
||||
list='$(pluginlib_PROGRAMS)'; for p in $$list; do \
|
||||
rm -f $(pluginlibdir)/`echo $$p|sed '$(transform)'`; \
|
||||
done
|
||||
|
||||
.c.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.o core
|
||||
|
||||
clean-compile:
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
maintainer-clean-compile:
|
||||
|
||||
.c.lo:
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs
|
||||
|
||||
distclean-libtool:
|
||||
|
||||
maintainer-clean-libtool:
|
||||
|
||||
gfig: $(gfig_OBJECTS) $(gfig_DEPENDENCIES)
|
||||
@rm -f gfig
|
||||
$(LINK) $(gfig_LDFLAGS) $(gfig_OBJECTS) $(gfig_LDADD) $(LIBS)
|
||||
|
||||
tags: TAGS
|
||||
|
||||
ID: $(HEADERS) $(SOURCES)
|
||||
here=`pwd` && cd $(srcdir) && mkid -f$$here/ID $(SOURCES) $(HEADERS)
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
test -z "$(ETAGS_ARGS)$(SOURCES)$(HEADERS)$$tags" \
|
||||
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $(SOURCES) $(HEADERS) -o $$here/TAGS)
|
||||
|
||||
mostlyclean-tags:
|
||||
|
||||
clean-tags:
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID
|
||||
|
||||
maintainer-clean-tags:
|
||||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
subdir = plug-ins/gfig
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
here=`cd $(top_builddir) && pwd`; \
|
||||
top_distdir=`cd $(top_distdir) && pwd`; \
|
||||
distdir=`cd $(distdir) && pwd`; \
|
||||
cd $(top_srcdir) \
|
||||
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu plug-ins/gfig/Makefile
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file; \
|
||||
done
|
||||
|
||||
MKDEP = $(CC) -M $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
|
||||
|
||||
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
|
||||
-include .deps/.P
|
||||
.deps/.P: $(BUILT_SOURCES)
|
||||
echo > $@
|
||||
|
||||
-include $(DEP_FILES)
|
||||
|
||||
mostlyclean-depend:
|
||||
|
||||
clean-depend:
|
||||
|
||||
distclean-depend:
|
||||
|
||||
maintainer-clean-depend:
|
||||
-rm -rf .deps
|
||||
|
||||
.deps/%.P: %.c
|
||||
@echo "Computing dependencies for $<..."
|
||||
@o='o'; \
|
||||
test -n "$o" && o='$$o'; \
|
||||
$(MKDEP) $< >$@.tmp \
|
||||
&& sed "s,^\(.*\)\.o:,\1.$$o \1.l$$o $@:," < $@.tmp > $@ \
|
||||
&& rm -f $@.tmp
|
||||
info:
|
||||
dvi:
|
||||
check: all
|
||||
$(MAKE)
|
||||
installcheck:
|
||||
install-exec:
|
||||
@$(NORMAL_INSTALL)
|
||||
|
||||
install-data: install-pluginlibPROGRAMS
|
||||
@$(NORMAL_INSTALL)
|
||||
|
||||
install: install-exec install-data all
|
||||
@:
|
||||
|
||||
uninstall: uninstall-pluginlibPROGRAMS
|
||||
|
||||
all: Makefile $(PROGRAMS)
|
||||
|
||||
install-strip:
|
||||
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install
|
||||
installdirs:
|
||||
$(mkinstalldirs) $(pluginlibdir)
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
-test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
|
||||
|
||||
clean-generic:
|
||||
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(DISTCLEANFILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
|
||||
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
|
||||
mostlyclean: mostlyclean-pluginlibPROGRAMS mostlyclean-compile \
|
||||
mostlyclean-libtool mostlyclean-tags mostlyclean-depend \
|
||||
mostlyclean-generic
|
||||
|
||||
clean: clean-pluginlibPROGRAMS clean-compile clean-libtool clean-tags \
|
||||
clean-depend clean-generic mostlyclean
|
||||
|
||||
distclean: distclean-pluginlibPROGRAMS distclean-compile \
|
||||
distclean-libtool distclean-tags distclean-depend \
|
||||
distclean-generic clean
|
||||
-rm -f config.status
|
||||
-rm -f libtool
|
||||
|
||||
maintainer-clean: maintainer-clean-pluginlibPROGRAMS \
|
||||
maintainer-clean-compile maintainer-clean-libtool \
|
||||
maintainer-clean-tags maintainer-clean-depend \
|
||||
maintainer-clean-generic distclean
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
.PHONY: default mostlyclean-pluginlibPROGRAMS \
|
||||
distclean-pluginlibPROGRAMS clean-pluginlibPROGRAMS \
|
||||
maintainer-clean-pluginlibPROGRAMS uninstall-pluginlibPROGRAMS \
|
||||
install-pluginlibPROGRAMS mostlyclean-compile distclean-compile \
|
||||
clean-compile maintainer-clean-compile mostlyclean-libtool \
|
||||
distclean-libtool clean-libtool maintainer-clean-libtool tags \
|
||||
mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \
|
||||
distdir mostlyclean-depend distclean-depend clean-depend \
|
||||
maintainer-clean-depend info dvi installcheck install-exec install-data \
|
||||
install uninstall all installdirs mostlyclean-generic distclean-generic \
|
||||
clean-generic maintainer-clean-generic clean mostlyclean distclean \
|
||||
maintainer-clean
|
||||
|
||||
|
||||
.PHONY: files
|
||||
|
||||
files:
|
||||
@files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \
|
||||
echo $$p; \
|
||||
done
|
||||
@for subdir in $(SUBDIRS); do \
|
||||
files=`cd $$subdir; $(MAKE) files | grep -v "make\[[1-9]\]"`; \
|
||||
for file in $$files; do \
|
||||
echo $$subdir/$$file; \
|
||||
done; \
|
||||
done
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
#! /bin/sh
|
||||
|
||||
# gfig - temporary wrapper script for _libs/gfig
|
||||
# Generated by ltmain.sh - GNU libtool 1.0c
|
||||
#
|
||||
# The gfig program cannot be directly executed until all the libtool
|
||||
# libraries that it depends on are installed.
|
||||
#
|
||||
# This wrapper script should never be moved out of `/usr/local/src/cvs/gimp/plug-ins/gfig'.
|
||||
# If it is, it will not operate correctly.
|
||||
|
||||
# This environment variable determines our operation mode.
|
||||
if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then
|
||||
# install mode needs the following variables:
|
||||
link_against_libtool_libs=' ../../libgimp/libgimpui.la ../../libgimp/libgimp.la'
|
||||
finalize_command="gcc -g -O2 -Wall -o _libs/gfigT gfig.o -Wl,-rpath -Wl,/usr/lib -L/usr/lib -lgimpui -Wl,-rpath -Wl,/usr/lib -L/usr/lib -lgimp -L/usr/X11R6/lib -lgtk -lgdk -lglib -lX11 -lXext -lm -lc"
|
||||
else
|
||||
# When we are sourced in execute mode, $file and $echo are already set.
|
||||
if test "$libtool_execute_magic" = "%%%MAGIC variable%%%"; then :
|
||||
else
|
||||
echo='printf %s\n'
|
||||
file="$0"
|
||||
fi
|
||||
|
||||
# Find the directory that this script lives in.
|
||||
thisdir=`$echo "$file" | sed 's%/[^/]*$%%'`
|
||||
test "x$thisdir" = "x$file" && thisdir=.
|
||||
|
||||
# Try to get the absolute directory name.
|
||||
absdir=`cd "$thisdir" && pwd`
|
||||
test -n "$absdir" && thisdir="$absdir"
|
||||
|
||||
progdir="$thisdir/_libs"
|
||||
program='gfig'
|
||||
|
||||
# If the $file dir failed (maybe due to symlink), try a hardcoded dir.
|
||||
oprogdir="$progdir"
|
||||
if test -f "$progdir/$program"; then :
|
||||
else
|
||||
thisdir='/usr/local/src/cvs/gimp/plug-ins/gfig'
|
||||
progdir="$thisdir/_libs"
|
||||
fi
|
||||
|
||||
if test -f "$progdir/$program"; then
|
||||
# Add our own library path to LD_LIBRARY_PATH
|
||||
LD_LIBRARY_PATH="$thisdir/../../libgimp/_libs:$thisdir/../../libgimp/_libs:$LD_LIBRARY_PATH"
|
||||
|
||||
# Some systems cannot cope with colon-terminated LD_LIBRARY_PATH
|
||||
LD_LIBRARY_PATH=`$echo $LD_LIBRARY_PATH | sed -e 's/:*$//'`
|
||||
|
||||
export LD_LIBRARY_PATH
|
||||
|
||||
if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
|
||||
# Run the actual program with our arguments.
|
||||
args=
|
||||
for arg
|
||||
do
|
||||
# Quote arguments (to preserve shell metacharacters).
|
||||
sed_quote_subst='s/\([\\"$]\)/\\\1/g'
|
||||
arg=`$echo "$arg" | sed "$sed_quote_subst"`
|
||||
args="$args \"$arg\""
|
||||
done
|
||||
|
||||
# Export the path to the program.
|
||||
PATH="$progdir:$PATH"
|
||||
export PATH
|
||||
|
||||
eval "exec $program $args"
|
||||
|
||||
$echo "$0: cannot exec $program $args"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# The program doesn't exist.
|
||||
$echo "$0: error: neither $oprogdir/$program nor $progdir/$program exists" 1>&2
|
||||
$echo "This script is just a wrapper for $program." 1>&2
|
||||
$echo "See the libtool documentation for more information." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
4334
plug-ins/gfig/gfig.c
4334
plug-ins/gfig/gfig.c
File diff suppressed because it is too large
Load diff
Binary file not shown.
|
|
@ -32,6 +32,7 @@
|
|||
* 1.7 added patch from Art Haas to make it compile with HP-UX, a small clean-up
|
||||
* 1.8 Dscho added transform file load/save, bug-fixes
|
||||
* 1.9 rewrote renderloop.
|
||||
* 1.9a fixed a bug.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
@ -258,7 +259,6 @@ void run(char *name, int nparams, GParam *param, int *nreturn_vals, GParam **ret
|
|||
gint sel_x1, sel_y1, sel_x2, sel_y2;
|
||||
gint img_height, img_width, img_bpp, img_has_alpha;
|
||||
|
||||
GParam values[1];
|
||||
GDrawable *drawable;
|
||||
GRunModeType run_mode;
|
||||
GStatusType status;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
/****************************************************************************
|
||||
* This is a plugin for the GIMP v 0.99.8 or later.
|
||||
* This is a plugin for the GIMP v 0.99.8 or later. Documentation is
|
||||
* available at http://www.rru.com/~meo/gimp/ .
|
||||
*
|
||||
* Copyright (C) 1997 Miles O'Neal
|
||||
* Copyright (C) 1997 Miles O'Neal <meo@rru.com> http://www.rru.com/~meo/
|
||||
* Blur code Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
* GUI based on GTK code from:
|
||||
* plasma (Copyright (C) 1996 Stephen Norris),
|
||||
* oilify (Copyright (C) 1996 Torsten Martinsen),
|
||||
* ripple (Copyright (C) 1997 Brian Degenhardt) and
|
||||
* whirl (Copyright (C) 1997 Federico Mena Quintero).
|
||||
* alienmap (Copyright (C) 1996, 1997 Daniel Cotting)
|
||||
* plasma (Copyright (C) 1996 Stephen Norris),
|
||||
* oilify (Copyright (C) 1996 Torsten Martinsen),
|
||||
* ripple (Copyright (C) 1997 Brian Degenhardt) and
|
||||
* whirl (Copyright (C) 1997 Federico Mena Quintero).
|
||||
*
|
||||
* 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
|
||||
|
|
@ -28,8 +30,19 @@
|
|||
/****************************************************************************
|
||||
* Randomize:
|
||||
*
|
||||
* randomize version 0.4c (17 May 1997, MEO)
|
||||
* randomize version 1.0 (19 Oct 1997, MEO)
|
||||
* history
|
||||
* 1.1 - 30 Nov 1997 MEO
|
||||
* added tooltips
|
||||
* 1.0 - 19 Nov 1997 MEO
|
||||
* final cleanup for 1.0 GIMP release
|
||||
* - added email and URL info for author
|
||||
* - added doc URL info
|
||||
* - final FCS comment cleanup
|
||||
* - standardized constant strings
|
||||
* - restored proper behavior when repeating
|
||||
* - final UI labels
|
||||
* - better help text (for when GIMP help arrives)
|
||||
* 0.5 - 20 May 1997 MEO
|
||||
* added seed initialization choices (current time or user value)
|
||||
* added randomization type to progress label
|
||||
|
|
@ -99,7 +112,8 @@
|
|||
*
|
||||
* TODO List
|
||||
*
|
||||
* - Add a real melt function.
|
||||
* - add a real melt function
|
||||
* - split into multiple files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
|
@ -107,23 +121,25 @@
|
|||
#include "libgimp/gimp.h"
|
||||
#include "gtk/gtk.h"
|
||||
|
||||
/*********************************
|
||||
*
|
||||
* PLUGIN-SPECIFIC CONSTANTS
|
||||
*
|
||||
********************************/
|
||||
|
||||
/*
|
||||
* Set this to 0 for faster processing, to 1 if for some
|
||||
* Set this to 1 for faster processing, to 0 if for some
|
||||
* reason you want all functions to be subroutines
|
||||
*/
|
||||
#define SUBS_NOT_DEFINES 0
|
||||
#define OPTIMIZE_SUBS 0
|
||||
|
||||
/*
|
||||
* progress meter update frequency
|
||||
*/
|
||||
#define PROG_UPDATE_TIME ((row % 10) == 0)
|
||||
|
||||
#define RNDM_VERSION "Randomize 0.5"
|
||||
|
||||
/*********************************
|
||||
*
|
||||
* LOCAL DATA
|
||||
*
|
||||
********************************/
|
||||
#define PLUG_IN_NAME "plug_in_randomize"
|
||||
#define RNDM_VERSION "Randomize 1.1"
|
||||
|
||||
#define RNDM_BLUR 1
|
||||
#define RNDM_PICK 2
|
||||
|
|
@ -136,6 +152,12 @@
|
|||
#define ENTRY_WIDTH 75
|
||||
#define SCALE_WIDTH 100
|
||||
|
||||
/*********************************
|
||||
*
|
||||
* PLUGIN-SPECIFIC STRUCTURES AND DATA
|
||||
*
|
||||
********************************/
|
||||
|
||||
typedef struct {
|
||||
gint rndm_type; /* type of randomization to apply */
|
||||
gdouble rndm_pct; /* likelihood of randomization (as %age) */
|
||||
|
|
@ -185,14 +207,15 @@ GPlugInInfo PLUG_IN_INFO = {
|
|||
};
|
||||
|
||||
static void randomize(GDrawable *drawable);
|
||||
#if (SUBS_NOT_DEFINES == 1)
|
||||
static void randomize_prepare_row(
|
||||
GPixelRgn *pixel_rgn,
|
||||
guchar *data,
|
||||
int x,
|
||||
int y,
|
||||
int w
|
||||
);
|
||||
|
||||
#if (OPTIMIZE_SUBS == 0)
|
||||
static void randomize_prepare_row(
|
||||
GPixelRgn *pixel_rgn,
|
||||
guchar *data,
|
||||
int x,
|
||||
int y,
|
||||
int w
|
||||
);
|
||||
#endif
|
||||
|
||||
static gint randomize_dialog();
|
||||
|
|
@ -224,6 +247,14 @@ static void randomize_text_update(
|
|||
gpointer data
|
||||
);
|
||||
|
||||
static void set_tooltip(
|
||||
GtkWidget *widget,
|
||||
const char *tip
|
||||
);
|
||||
|
||||
static void setup_tooltips();
|
||||
|
||||
/************************************ Guts ***********************************/
|
||||
|
||||
MAIN()
|
||||
|
||||
|
|
@ -250,12 +281,18 @@ query()
|
|||
static int nargs = sizeof(args) / sizeof (args[0]);
|
||||
static int nreturn_vals = 0;
|
||||
|
||||
gimp_install_procedure("plug_in_randomize",
|
||||
"Add a random factor to the image, by blurring, picking a nearby pixel, slurring (similar to melting), or just hurling on it.",
|
||||
"This function randomly ``blurs'' the specified drawable, using either a 3x3 blur, picking a nearby pixel, slurring (cheezy melting), or hurling (spewing colors). The type and percentage are user selectable. Blurring is not supported for indexed images.",
|
||||
"Miles O'Neal",
|
||||
"Miles O'Neal, Spencer Kimball, Peter Mattis, Torsten Martinsen, Brian Degenhardt, Federico Mena Quintero",
|
||||
"1995-1997",
|
||||
const char *blurb = "Add a random factor to the image, by blurring, picking a nearby pixel, slurring (similar to melting), or just hurling on it.";
|
||||
const char *help = "This function randomly ``blurs'' the specified drawable, using either a 3x3 blur, picking a nearby pixel, slurring (cheezy melting), or hurling (spewing colors). The type and percentage are user selectable. Blurring is not supported for indexed images.";
|
||||
const char *author = "Miles O'Neal <meo@rru.com> http://www.rru.com/~meo/";
|
||||
const char *copyrights = "Miles O'Neal, Spencer Kimball, Peter Mattis, Torsten Martinsen, Brian Degenhardt, Federico Mena Quintero, Stephen Norris, Daniel Cotting";
|
||||
const char *copyright_date = "1995-1997";
|
||||
|
||||
gimp_install_procedure(PLUG_IN_NAME,
|
||||
(char *) blurb,
|
||||
(char *) help,
|
||||
(char *) author,
|
||||
(char *) copyrights,
|
||||
(char *) copyright_date,
|
||||
"<Image>/Filters/Distorts/Randomize",
|
||||
"RGB*, GRAY*, INDEXED*",
|
||||
PROC_PLUG_IN,
|
||||
|
|
@ -292,12 +329,12 @@ run(char *name, int nparams, GParam *param, int *nreturn_vals,
|
|||
GParam **return_vals)
|
||||
{
|
||||
|
||||
static GParam values[1];
|
||||
GDrawable *drawable;
|
||||
GRunModeType run_mode;
|
||||
GStatusType status = STATUS_SUCCESS; /* assume the best! */
|
||||
char *rndm_type_str = '\0';
|
||||
char prog_label[32];
|
||||
static GParam values[1];
|
||||
/*
|
||||
* Get the specified drawable, do standard initialization.
|
||||
*/
|
||||
|
|
@ -321,7 +358,7 @@ run(char *name, int nparams, GParam *param, int *nreturn_vals,
|
|||
*/
|
||||
case RUN_INTERACTIVE:
|
||||
FIX_INDEX_BLUR();
|
||||
gimp_get_data("plug_in_randomize", &pivals);
|
||||
gimp_get_data(PLUG_IN_NAME, &pivals);
|
||||
if (!randomize_dialog()) /* return on Cancel */
|
||||
return;
|
||||
break;
|
||||
|
|
@ -355,7 +392,7 @@ run(char *name, int nparams, GParam *param, int *nreturn_vals,
|
|||
* If we're running with the last set of values, get those values.
|
||||
*/
|
||||
case RUN_WITH_LAST_VALS:
|
||||
gimp_get_data("plug_in_randomize", &pivals);
|
||||
gimp_get_data(PLUG_IN_NAME, &pivals);
|
||||
break;
|
||||
/*
|
||||
* Hopefully we never get here!
|
||||
|
|
@ -376,7 +413,7 @@ run(char *name, int nparams, GParam *param, int *nreturn_vals,
|
|||
gimp_progress_init(prog_label);
|
||||
gimp_tile_cache_ntiles(2 * (drawable->width / gimp_tile_width() + 1));
|
||||
/*
|
||||
* Initialie the rand() function seed
|
||||
* Initialize the rand() function seed
|
||||
*/
|
||||
if (pivals.seed_type == SEED_TIME)
|
||||
srand(time(NULL));
|
||||
|
|
@ -394,7 +431,7 @@ run(char *name, int nparams, GParam *param, int *nreturn_vals,
|
|||
* If we use the dialog popup, set the data for future use.
|
||||
*/
|
||||
if (run_mode == RUN_INTERACTIVE) {
|
||||
gimp_set_data("plug_in_randomize", &pivals, sizeof(RandomizeVals));
|
||||
gimp_set_data(PLUG_IN_NAME, &pivals, sizeof(RandomizeVals));
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
|
|
@ -420,7 +457,7 @@ run(char *name, int nparams, GParam *param, int *nreturn_vals,
|
|||
*
|
||||
********************************/
|
||||
|
||||
#if (SUBS_NOT_DEFINES == 1)
|
||||
#if (OPTIMIZE_SUBS == 0)
|
||||
static void
|
||||
randomize_prepare_row(GPixelRgn *pixel_rgn, guchar *data, int x, int y, int w)
|
||||
{
|
||||
|
|
@ -474,7 +511,7 @@ randomize_prepare_row(GPixelRgn *pixel_rgn, guchar *data, int x, int y, int w)
|
|||
static void
|
||||
randomize(GDrawable *drawable)
|
||||
{
|
||||
GPixelRgn srcPR, destPR;
|
||||
GPixelRgn srcPR, destPR, destPR2, *sp, *dp, *tp;
|
||||
gint width, height;
|
||||
gint bytes;
|
||||
guchar *dest, *d;
|
||||
|
|
@ -509,27 +546,32 @@ randomize(GDrawable *drawable)
|
|||
next_row = (guchar *) malloc((x2 - x1 + 2) * bytes);
|
||||
dest = (guchar *) malloc((x2 - x1) * bytes);
|
||||
|
||||
for (cnt = 1; cnt <= pivals.rndm_rcount; cnt++) {
|
||||
/*
|
||||
* initialize the pixel regions
|
||||
*/
|
||||
gimp_pixel_rgn_init(&srcPR, drawable, 0, 0, width, height, FALSE, FALSE);
|
||||
gimp_pixel_rgn_init(&destPR, drawable, 0, 0, width, height, TRUE, TRUE);
|
||||
gimp_pixel_rgn_init(&srcPR, drawable, 0, 0, width, height, FALSE, FALSE);
|
||||
gimp_pixel_rgn_init(&destPR, drawable, 0, 0, width, height, TRUE, TRUE);
|
||||
gimp_pixel_rgn_init(&destPR2, drawable, 0, 0, width, height, TRUE, TRUE);
|
||||
sp = &srcPR;
|
||||
dp = &destPR;
|
||||
tp = NULL;
|
||||
|
||||
pr = prev_row + bytes;
|
||||
cr = cur_row + bytes;
|
||||
nr = next_row + bytes;
|
||||
pr = prev_row + bytes;
|
||||
cr = cur_row + bytes;
|
||||
nr = next_row + bytes;
|
||||
|
||||
for (cnt = 1; cnt <= pivals.rndm_rcount; cnt++) {
|
||||
/*
|
||||
* prepare the first row and previous row
|
||||
*/
|
||||
randomize_prepare_row(&srcPR, pr, x1, y1 - 1, (x2 - x1));
|
||||
randomize_prepare_row(&srcPR, cr, x1, y1, (x2 - x1));
|
||||
randomize_prepare_row(sp, pr, x1, y1 - 1, (x2 - x1));
|
||||
randomize_prepare_row(dp, cr, x1, y1, (x2 - x1));
|
||||
/*
|
||||
* loop through the rows, applying the selected convolution
|
||||
*/
|
||||
for (row = y1; row < y2; row++) {
|
||||
/* prepare the next row */
|
||||
randomize_prepare_row(&srcPR, nr, x1, row + 1, (x2 - x1));
|
||||
randomize_prepare_row(sp, nr, x1, row + 1, (x2 - x1));
|
||||
|
||||
d = dest;
|
||||
for (col = 0; col < (x2 - x1) * bytes; col++) {
|
||||
|
|
@ -621,7 +663,7 @@ randomize(GDrawable *drawable)
|
|||
* Save the modified row, shuffle the row pointers, and every
|
||||
* so often, update the progress meter.
|
||||
*/
|
||||
gimp_pixel_rgn_set_row(&destPR, dest, x1, row, (x2 - x1));
|
||||
gimp_pixel_rgn_set_row(dp, dest, x1, row, (x2 - x1));
|
||||
|
||||
tmp = pr;
|
||||
pr = cr;
|
||||
|
|
@ -631,6 +673,20 @@ randomize(GDrawable *drawable)
|
|||
if (PROG_UPDATE_TIME)
|
||||
gimp_progress_update((double) row / (double) (y2 - y1));
|
||||
}
|
||||
/*
|
||||
* if we have more cycles to perform, swap the src and dest Pixel Regions
|
||||
*/
|
||||
if (cnt < pivals.rndm_rcount) {
|
||||
if (tp != NULL) {
|
||||
tp = dp;
|
||||
dp = sp;
|
||||
sp = tp;
|
||||
} else {
|
||||
tp = &srcPR;
|
||||
sp = &destPR;
|
||||
dp = &destPR2;
|
||||
}
|
||||
}
|
||||
}
|
||||
gimp_progress_update((double) 100);
|
||||
/*
|
||||
|
|
@ -654,7 +710,7 @@ randomize(GDrawable *drawable)
|
|||
*
|
||||
********************************/
|
||||
|
||||
#define randomize_add_action_button(label, callback, dialog) \
|
||||
#define randomize_add_action_button(label, callback, dialog, tip) \
|
||||
{ \
|
||||
GtkWidget *button; \
|
||||
\
|
||||
|
|
@ -665,9 +721,10 @@ randomize(GDrawable *drawable)
|
|||
button, TRUE, TRUE, 0); \
|
||||
gtk_widget_grab_default(button); \
|
||||
gtk_widget_show(button); \
|
||||
set_tooltip(button, tip); \
|
||||
}
|
||||
|
||||
#define randomize_add_radio_button(group, label, box, callback, value) \
|
||||
#define randomize_add_radio_button(group, label, box, callback, value, tip) \
|
||||
{ \
|
||||
GtkWidget *toggle; \
|
||||
\
|
||||
|
|
@ -679,6 +736,7 @@ randomize(GDrawable *drawable)
|
|||
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(toggle), *value); \
|
||||
gtk_widget_show(toggle); \
|
||||
gtk_widget_show(box); \
|
||||
set_tooltip(toggle, tip); \
|
||||
}
|
||||
|
||||
/*********************************
|
||||
|
|
@ -723,13 +781,6 @@ randomize_dialog()
|
|||
gtk_window_position(GTK_WINDOW(dlg), GTK_WIN_POS_MOUSE);
|
||||
gtk_signal_connect(GTK_OBJECT(dlg), "destroy",
|
||||
(GtkSignalFunc) randomize_close_callback, NULL);
|
||||
/*
|
||||
* Action area OK & Cancel buttons
|
||||
*/
|
||||
randomize_add_action_button("OK",
|
||||
(GtkSignalFunc) randomize_ok_callback, dlg);
|
||||
randomize_add_action_button("Cancel",
|
||||
(GtkSignalFunc) randomize_cancel_callback, dlg);
|
||||
/*
|
||||
* Parameter settings
|
||||
*
|
||||
|
|
@ -742,6 +793,17 @@ randomize_dialog()
|
|||
table = gtk_table_new(4, 2, FALSE);
|
||||
gtk_container_border_width(GTK_CONTAINER(table), 10);
|
||||
gtk_container_add(GTK_CONTAINER(frame), table);
|
||||
gtk_widget_show(table);
|
||||
setup_tooltips(table);
|
||||
/*
|
||||
* Action area OK & Cancel buttons
|
||||
*/
|
||||
randomize_add_action_button("OK",
|
||||
(GtkSignalFunc) randomize_ok_callback, dlg,
|
||||
"Accept settings and apply filter to image");
|
||||
randomize_add_action_button("Cancel",
|
||||
(GtkSignalFunc) randomize_cancel_callback, dlg,
|
||||
"Close plug-in without making any changes");
|
||||
/*
|
||||
* Randomization Type - label & radio buttons
|
||||
*/
|
||||
|
|
@ -761,22 +823,25 @@ randomize_dialog()
|
|||
*/
|
||||
if (! is_indexed_drawable) {
|
||||
randomize_add_radio_button(type_group, "Blur", toggle_hbox,
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_blur);
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_blur,
|
||||
"Blur each pixel by averaging its value with those of its neighbors");
|
||||
}
|
||||
/*
|
||||
* Hurl, Pick and Slur buttons
|
||||
*/
|
||||
randomize_add_radio_button(type_group, "Hurl", toggle_hbox,
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_hurl);
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_hurl,
|
||||
"Hurl random colors onto pixels");
|
||||
randomize_add_radio_button(type_group, "Pick", toggle_hbox,
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_pick);
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_pick,
|
||||
"Pick at random from neighboring pixels");
|
||||
randomize_add_radio_button(type_group, "Slur", toggle_hbox,
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_slur);
|
||||
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_slur,
|
||||
"Simplistic melt");
|
||||
/*
|
||||
* Randomization seed initialization controls
|
||||
*/
|
||||
label = gtk_label_new("Seed");
|
||||
label = gtk_label_new("Randomization Seed");
|
||||
gtk_misc_set_alignment(GTK_MISC (label), 0.0, 0.5);
|
||||
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_FILL, 0, 5, 0);
|
||||
gtk_widget_show(label);
|
||||
|
|
@ -791,7 +856,8 @@ randomize_dialog()
|
|||
* Time button
|
||||
*/
|
||||
randomize_add_radio_button(seed_group, "Current Time", seed_vbox,
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_time);
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_time,
|
||||
"Seed random number generator from the current time - this guarantees a reasonable randomization");
|
||||
/*
|
||||
* Box to hold seed user initialization controls
|
||||
*/
|
||||
|
|
@ -801,10 +867,11 @@ randomize_dialog()
|
|||
/*
|
||||
* User button
|
||||
*/
|
||||
randomize_add_radio_button(seed_group, "User", seed_hbox,
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_user);
|
||||
randomize_add_radio_button(seed_group, "Other Value", seed_hbox,
|
||||
(GtkSignalFunc) randomize_toggle_update, &do_user,
|
||||
"Enable user-entered value for random number generator seed - this allows you to repeat a given \"random\" operation");
|
||||
/*
|
||||
* Randomization seed text
|
||||
* Randomization seed number (text)
|
||||
*/
|
||||
entry = gtk_entry_new();
|
||||
gtk_widget_set_usize(entry, ENTRY_WIDTH, 0);
|
||||
|
|
@ -814,8 +881,8 @@ randomize_dialog()
|
|||
gtk_signal_connect(GTK_OBJECT(entry), "changed",
|
||||
(GtkSignalFunc) randomize_text_update, &pivals.rndm_seed);
|
||||
gtk_widget_show(entry);
|
||||
set_tooltip(entry, "Value for seeding the random number generator");
|
||||
gtk_widget_show(seed_hbox);
|
||||
|
||||
/*
|
||||
* Randomization percentage label & scale (1 to 100)
|
||||
*/
|
||||
|
|
@ -837,6 +904,7 @@ randomize_dialog()
|
|||
(GtkSignalFunc) randomize_scale_update, &pivals.rndm_pct);
|
||||
gtk_widget_show(label);
|
||||
gtk_widget_show(scale);
|
||||
set_tooltip(scale, "Percentage of pixels to be filtered");
|
||||
/*
|
||||
* Repeat count label & scale (1 to 100)
|
||||
*/
|
||||
|
|
@ -858,11 +926,11 @@ randomize_dialog()
|
|||
(GtkSignalFunc) randomize_scale_update, &pivals.rndm_rcount);
|
||||
gtk_widget_show(label);
|
||||
gtk_widget_show(scale);
|
||||
set_tooltip(scale, "Number of times to apply filter");
|
||||
/*
|
||||
* Display everything.
|
||||
*/
|
||||
gtk_widget_show(frame);
|
||||
gtk_widget_show(table);
|
||||
gtk_widget_show(dlg);
|
||||
|
||||
gtk_main();
|
||||
|
|
@ -898,28 +966,42 @@ randomize_dialog()
|
|||
*
|
||||
********************************/
|
||||
|
||||
/*
|
||||
* DESTROY callback
|
||||
*/
|
||||
static void
|
||||
randomize_close_callback(GtkWidget *widget, gpointer data) {
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
/*
|
||||
* OK BUTTON callback
|
||||
*/
|
||||
static void
|
||||
randomize_ok_callback(GtkWidget *widget, gpointer data) {
|
||||
rndm_int.run = TRUE;
|
||||
gtk_widget_destroy(GTK_WIDGET(data));
|
||||
}
|
||||
|
||||
/*
|
||||
* CANCEL BUTTON callback
|
||||
*/
|
||||
static void
|
||||
randomize_cancel_callback(GtkWidget *widget, gpointer data) {
|
||||
gtk_widget_destroy(GTK_WIDGET(data));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* SCALE UPDATE callback
|
||||
*/
|
||||
static void
|
||||
randomize_scale_update(GtkAdjustment *adjustment, double *scale_val) {
|
||||
*scale_val = adjustment->value;
|
||||
}
|
||||
|
||||
/*
|
||||
* TOGGLE UPDATE callback
|
||||
*/
|
||||
static void
|
||||
randomize_toggle_update(GtkWidget *widget, gpointer data) {
|
||||
int *toggle_val;
|
||||
|
|
@ -932,6 +1014,9 @@ randomize_toggle_update(GtkWidget *widget, gpointer data) {
|
|||
*toggle_val = FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* TEXT UPDATE callback
|
||||
*/
|
||||
static void
|
||||
randomize_text_update(GtkWidget *widget, gpointer data) {
|
||||
gint *text_val;
|
||||
|
|
@ -940,3 +1025,39 @@ randomize_text_update(GtkWidget *widget, gpointer data) {
|
|||
|
||||
*text_val = atoi(gtk_entry_get_text(GTK_ENTRY(widget)));
|
||||
}
|
||||
|
||||
/*
|
||||
* TOOLTIPS ROUTINES
|
||||
*/
|
||||
static GtkTooltips *tips;
|
||||
|
||||
|
||||
void setup_tooltips(GtkWidget *parent)
|
||||
{
|
||||
static GdkColor tips_fg, tips_bg;
|
||||
|
||||
tips = gtk_tooltips_new();
|
||||
|
||||
/* black as foreground: */
|
||||
|
||||
tips_fg.red = 0;
|
||||
tips_fg.green = 0;
|
||||
tips_fg.blue = 0;
|
||||
gdk_color_alloc(gtk_widget_get_colormap(parent), &tips_fg);
|
||||
|
||||
/* postit yellow (khaki) as background: */
|
||||
|
||||
tips_bg.red = 61669;
|
||||
tips_bg.green = 59113;
|
||||
tips_bg.blue = 35979;
|
||||
gdk_color_alloc(gtk_widget_get_colormap(parent), &tips_bg);
|
||||
|
||||
gtk_tooltips_set_colors(tips, &tips_bg, &tips_fg);
|
||||
}
|
||||
|
||||
|
||||
void set_tooltip(GtkWidget *widget, const char *tip)
|
||||
{
|
||||
if (tip && tip[0])
|
||||
gtk_tooltips_set_tips(tips, widget, (char *) tip);
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue