Commit beddbcd6 authored by Manish Singh's avatar Manish Singh

Initial stable/unstable split done.

-Yosh
parent 6d3d7186
Fri Feb 20 02:38:24 PST 1998 Manish Singh <yosh@gimp.org>
* initial plug-in stable/unstable split
Wed Feb 18 16:46:37 1998 Owen Taylor <owt1@cornell.edu>
* plug-ins/ifscompose/ifscompose.c: refcounting fixups
......
......@@ -148,17 +148,17 @@ dnl Test for libmpeg
AC_MSG_WARN(*** MPEG plug-in will not be built ***))
fi
dnl Test for libtcl
if test -z "$LIBTCL_LIB"; then
AC_CHECK_LIB(dl, dlopen, DL_LIBRARY=-ldl)
AC_ARG_WITH(tcl, --with-{tcl/tk} use this tcl/tk library,
AC_CHECK_LIB($with_tcl, Tcl_StaticPackage,
GIMPTCL='gimptcl'; LIBTCL_LIB="-l$with_tcl -l$with_tk $DL_LIBRARY",
AC_MSG_WARN(*** gimptcl plug-in will not be built ***), -lm $DL_LIBRARY),
AC_CHECK_LIB(tcl, Tcl_StaticPackage,
GIMPTCL='gimptcl'; LIBTCL_LIB="-ltcl -ltk $DL_LIBRARY",
AC_MSG_WARN(*** gimptcl plug-in will not be built ***), -lm $DL_LIBRARY))
fi
#dnl Test for libtcl
# if test -z "$LIBTCL_LIB"; then
# AC_CHECK_LIB(dl, dlopen, DL_LIBRARY=-ldl)
# AC_ARG_WITH(tcl, --with-{tcl/tk} use this tcl/tk library,
# AC_CHECK_LIB($with_tcl, Tcl_StaticPackage,
# GIMPTCL='gimptcl'; LIBTCL_LIB="-l$with_tcl -l$with_tk $DL_LIBRARY",
# AC_MSG_WARN(*** gimptcl plug-in will not be built ***), -lm $DL_LIBRARY),
# AC_CHECK_LIB(tcl, Tcl_StaticPackage,
# GIMPTCL='gimptcl'; LIBTCL_LIB="-ltcl -ltk $DL_LIBRARY",
# AC_MSG_WARN(*** gimptcl plug-in will not be built ***), -lm $DL_LIBRARY))
# fi
dnl Test for libxdelta
if test -z "$LIBXDELTA_LIB"; then
......@@ -256,8 +256,8 @@ AC_SUBST(PNG)
AC_SUBST(LIBPNG_LIB)
AC_SUBST(MPEG)
AC_SUBST(LIBMPEG_LIB)
AC_SUBST(GIMPTCL)
AC_SUBST(LIBTCL_LIB)
#AC_SUBST(GIMPTCL)
#AC_SUBST(LIBTCL_LIB)
AC_SUBST(XD)
AC_SUBST(LIBXDELTA_LIB)
AC_SUBST(XPM)
......@@ -288,7 +288,6 @@ plug-ins/mblur/Makefile
plug-ins/maze/Makefile
plug-ins/max_rgb/Makefile
plug-ins/mail/Makefile
plug-ins/magiceye/Makefile
plug-ins/laplace/Makefile
plug-ins/ifscompose/Makefile
plug-ins/iwarp/Makefile
......@@ -319,7 +318,6 @@ plug-ins/depthmerge/Makefile
plug-ins/deinterlace/Makefile
plug-ins/decompose/Makefile
plug-ins/cubism/Makefile
plug-ins/coordmap/Makefile
plug-ins/compose/Makefile
plug-ins/checkerboard/Makefile
plug-ins/bz2/Makefile
......@@ -338,10 +336,7 @@ plug-ins/bmp/Makefile
plug-ins/megawidget/Makefile
plug-ins/blur/Makefile
plug-ins/flame/Makefile
plug-ins/gimptcl/Makefile
plug-ins/gimptcl/scripts/Makefile
plug-ins/struc/Makefile
plug-ins/user_filter/Makefile
plug-ins/zealouscrop/Makefile
plug-ins/xwd/Makefile
plug-ins/whirlpinch/Makefile
......@@ -350,14 +345,12 @@ plug-ins/vpropagate/Makefile
plug-ins/vinvert/Makefile
plug-ins/video/Makefile
plug-ins/url/Makefile
plug-ins/universal/Makefile
plug-ins/tiler/Makefile
plug-ins/tile/Makefile
plug-ins/tileit/Makefile
plug-ins/threshold_alpha/Makefile
plug-ins/tga/Makefile
plug-ins/sunras/Makefile
plug-ins/stereogram/Makefile
plug-ins/spread/Makefile
plug-ins/sparkle/Makefile
plug-ins/sobel/Makefile
......@@ -366,14 +359,12 @@ plug-ins/snoise/Makefile
plug-ins/smooth_palette/Makefile
plug-ins/sinus/Makefile
plug-ins/shift/Makefile
plug-ins/sharpen/Makefile
plug-ins/sgi/Makefile
plug-ins/scatter_hsv/Makefile
plug-ins/rotators/Makefile
plug-ins/rotate/Makefile
plug-ins/ripple/Makefile
plug-ins/randomize/Makefile
plug-ins/psd/Makefile
plug-ins/ps/Makefile
plug-ins/print/Makefile
plug-ins/polar/Makefile
......@@ -382,7 +373,6 @@ plug-ins/plasma/Makefile
plug-ins/pixelize/Makefile
plug-ins/pcx/Makefile
plug-ins/pat/Makefile
plug-ins/blur2/Makefile
plug-ins/blinds/Makefile
plug-ins/autostretch_hsv/Makefile
plug-ins/autocrop/Makefile
......
......@@ -2,10 +2,8 @@
SUBDIRS = \
megawidget \
libgck \
AlienMap \
dbbrowser \
@GIMPTCL@ \
script-fu \
struc \
@TIFF@ \
......@@ -22,7 +20,6 @@ SUBDIRS = \
autostretch_hsv \
blinds \
blur \
blur2 \
bmp \
bumpmap \
bz2 \
......@@ -32,7 +29,6 @@ SUBDIRS = \
colorify \
compose \
convmatrix \
coordmap \
cubism \
decompose \
deinterlace \
......@@ -69,7 +65,6 @@ SUBDIRS = \
illusion \
iwarp \
laplace \
magiceye \
mail \
max_rgb \
maze \
......@@ -97,7 +92,6 @@ SUBDIRS = \
rotators \
scatter_hsv \
sgi \
sharpen \
shift \
sinus \
smooth_palette \
......@@ -106,14 +100,12 @@ SUBDIRS = \
sobel \
sparkle \
spread \
stereogram \
sunras \
tga \
threshold_alpha \
tile \
tileit \
tiler \
universal \
url \
video \
vinvert \
......
Makefile.in
Makefile
.deps
_libs
.libs
blur2
## Process this file with automake to produce Makefile.in
pluginlibdir = $(gimpplugindir)/plug-ins
pluginlib_PROGRAMS = blur2
blur2_SOURCES = \
blur2.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
blur2_DEPENDENCIES = $(DEPS)
.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
/*
* This is a plug-in for the GIMP.
*
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
* Copyright (C) 1996 Torsten Martinsen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id$
*/
/*
* This filter is like the standard 'blur', except that it uses
* a convolution kernel of variable size.
*
* I am greatly indebted to Johan Klockars <d8klojo@dtek.chalmers.se>
* for supplying the algorithm used here, which is of complexity O(1).
* Compared with the original naive algorithm, which is O(k^2) (where
* k is the kernel size), it gives _massive_ speed improvements.
* The code is quite simple, too.
*/
#include <stdlib.h>
#include <stdio.h> /**/
#include "gtk/gtk.h"
#include "libgimp/gimp.h"
#define ENTRY_WIDTH 30
#define SCALE_WIDTH 125
typedef struct {
gdouble mask_size;
} BlurVals;
typedef struct {
gint run;
} BlurInterface;
/* Declare local functions.
*/
static void query(void);
static void run(char *name,
int nparams,
GParam * param,
int *nreturn_vals,
GParam ** return_vals);
static void blur(GDrawable * drawable);
static gint blur2_dialog ();
static void blur2_close_callback (GtkWidget *widget,
gpointer data);
static void blur2_ok_callback (GtkWidget *widget,
gpointer data);
static void blur2_scale_update (GtkAdjustment *adjustment,
double *scale_val);
static void blur2_entry_update (GtkWidget *widget,
gdouble *value);
static void dialog_create_value (char *title,
GtkTable *table,
int row,
gdouble *value,
double left,
double right);
GPlugInInfo PLUG_IN_INFO =
{
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
};
static BlurVals bvals =
{
6+5.0 /* mask size */
};
static BlurInterface bint =
{
FALSE /* run */
};
MAIN()
static void
query()
{
static GParamDef args[] =
{
{PARAM_INT32, "run_mode", "Interactive, non-interactive"},
{PARAM_IMAGE, "image", "Input image (unused)"},
{PARAM_DRAWABLE, "drawable", "Input drawable"},
{PARAM_INT32, "mask_size", "Blur mask size"},
};
static GParamDef *return_vals = NULL;
static int nargs = sizeof(args) / sizeof(args[0]);
static int nreturn_vals = 0;
gimp_install_procedure("plug_in_blur2",
"Blur the contents of the specified drawable",
"This function applies a NxN blurring convolution kernel to the specified drawable.",
"Torsten Martinsen",
"Torsten Martinsen",
"1996-1997",
"<Image>/Filters/Blur/Variable Blur",
"RGB, GRAY",
PROC_PLUG_IN,
nargs, nreturn_vals,
args, return_vals);
}
static void
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;
run_mode = param[0].data.d_int32;
switch (run_mode) {
case RUN_INTERACTIVE:
/* Possibly retrieve data */
gimp_get_data("plug_in_blur2", &bvals);
/* First acquire information with a dialog */
if (!blur2_dialog())
return;
break;
case RUN_NONINTERACTIVE:
/* Make sure all the arguments are there! */
if (nparams != 4)
status = STATUS_CALLING_ERROR;
if (status == STATUS_SUCCESS) {
bvals.mask_size = (gdouble) param[3].data.d_int32;
}
if (status == STATUS_SUCCESS &&
(bvals.mask_size < 1.0))
status = STATUS_CALLING_ERROR;
break;
case RUN_WITH_LAST_VALS:
/* Possibly retrieve data */
gimp_get_data("plug_in_blur2", &bvals);
break;
default:
break;
}
/* Get the specified drawable */
drawable = gimp_drawable_get(param[2].data.d_drawable);
/* Make sure that the drawable is gray or RGB color */
if (gimp_drawable_color(drawable->id) || gimp_drawable_gray(drawable->id)) {
gimp_progress_init("Variable Blur");
gimp_tile_cache_ntiles(2 * (drawable->width / gimp_tile_width() + 1));
blur(drawable);
if (run_mode != RUN_NONINTERACTIVE)
gimp_displays_flush();
/* Store data */
if (run_mode == RUN_INTERACTIVE)
gimp_set_data ("plug_in_blur2", &bvals, sizeof (BlurVals));
} else {
/* gimp_message ("blur2: cannot operate on indexed color images"); */
status = STATUS_EXECUTION_ERROR;
}
*nreturn_vals = 1;
*return_vals = values;
values[0].type = PARAM_STATUS;
values[0].data.d_status = status;
gimp_drawable_detach(drawable);
}
static void
blur(GDrawable * drawable)
{
GPixelRgn srcPR, destPR;
gint width, height;
gint bytes;
guchar *dest, *d;
guchar *cr, *cc;
gint sum[4];
gint row, col, i, n, div;
gint x1, y1, x2, y2;
/* Get the input area. This is the bounding box of the selection in
* the image (or the entire image if there is no selection). Only
* operating on the input area is simply an optimization. It doesn't
* need to be done for correct operation. (It simply makes it go
* faster, since fewer pixels need to be operated on).
*/
gimp_drawable_mask_bounds(drawable->id, &x1, &y1, &x2, &y2);
/* Get the size of the input image. (This will/must be the same
* as the size of the output image).
*/
width = drawable->width;
height = drawable->height;
bytes = drawable->bpp;
n = bvals.mask_size;
/* Include edges if possible */
x1 = MAX(x1 - n / 2, 0);
x2 = MIN(x2 + n / 2 + 1, width);
y1 = MAX(y1 - n / 2, 0);
y2 = MIN(y2 + n / 2 + 1, height);
/* 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);
/* allocate row buffers */
cr = (guchar *) malloc((x2 - x1 + 2) * bytes);
dest = (guchar *) malloc((x2 - x1) * bytes);
/* loop through the rows, applying horizontal blur */
for (row = y1; row < y2; row++) {
gimp_pixel_rgn_get_row(&srcPR, cr, x1, row, (x2 - x1));
d = dest + bytes * (n / 2);
for (i = 0; i < bytes; ++i)
sum[i] = 0;
for (i = 0; i < n * bytes; ++i)
sum[i % bytes] += cr[i];
for (col = 0; col < (x2 - x1 - n) * bytes; col++) {
sum[col % bytes] += cr[col + n * bytes] - cr[col];
*d++ = sum[col % bytes]/n;
}
/* store the dest */
gimp_pixel_rgn_set_row(&destPR, dest, x1, row, (x2 - x1));
if ((row % 5) == 0)
gimp_progress_update((double) (row/2) / (double) (x2 - x1));
}
free(cr);
free(dest);
cc = (guchar *) malloc((y2 - y1 + 2) * bytes);
dest = (guchar *) malloc((y2 - y1) * bytes);
/* loop through the columns, applying vertical blur */
for (col = x1; col < x2; col++) {
gimp_pixel_rgn_get_col(&destPR, cc, col, y1, (y2 - y1));
d = dest + bytes * (n / 2);
for (i = 0; i < bytes; ++i)
sum[i] = 0;
for (i = 0; i < n * bytes; ++i)
sum[i % bytes] += cc[i];
for (row = 0; row < (y2 - y1 - n) * bytes; row++) {
sum[row % bytes] += cc[row + n * bytes] - cc[row];
*d++ = sum[row % bytes]/n;
}
/* store the dest */
gimp_pixel_rgn_set_col(&destPR, dest, col, y1, (y2 - y1));
if ((col % 5) == 0)
gimp_progress_update(((double) (x2-x1)/2+(col/2)) / (double) (x2-x1));
}
div = n/2+1;
if (y1-n/2 < 0)
for (col = x1; col < x2; ++col) {
gimp_pixel_rgn_get_col(&srcPR, cc, col, 0, div);
gimp_pixel_rgn_set_col(&destPR, cc, col, 0, div);
}
if (y2+n/2 > height)
for (col = x1; col < x2; ++col) {
gimp_pixel_rgn_get_col(&srcPR, cc, col, height-div, div);
gimp_pixel_rgn_set_col(&destPR, cc, col, height-div, div);
}
if (x1-n/2 < 0)
for (row = y1; row < y2; ++row) {
gimp_pixel_rgn_get_row(&srcPR, cr, 0, row, div);
gimp_pixel_rgn_set_row(&destPR, cr, 0, row, div);
}
if (x2+n/2 > width)
for (row = y1; row < y2; ++row) {
gimp_pixel_rgn_get_row(&srcPR, cr, width-div, row, div);
gimp_pixel_rgn_set_row(&destPR, cr, width-div, row, div);
}
#if 0
/* Do remaining top pixels, if any */
if (y1-n/2 < 0) {
for (col = x1; col < x2; ++col) {
div = n/2+1;
gimp_pixel_rgn_get_col(&srcPR, cc, col, 0, div);
d = dest;
s = cc;
for (i = 0; i < bytes; ++i)
sum[i] = 0;
for (i = 0; i < div * bytes; ++i)
sum[i % bytes] += *s++;
memset(dest, 0, (y2 - y1) * bytes);
for (i = 0; i < bytes; ++i)
*d++ = sum[i]/div;
for (row = 0; row < n/2; ++row) {
++div;
for (i = 0; i < bytes; ++i) {
sum[i] += *s++;
*d++ = sum[i]/div;
}
}
gimp_pixel_rgn_set_col(&destPR, dest, col, 0, n/2+1);
}
}
/* Do remaining bottom pixels, if any */
if (y2+n/2 > height) {
for (col = x1; col < x2; ++col) {
div = n/2+1;
gimp_pixel_rgn_get_col(&srcPR, cc, col, height-1-div, div);
s = cc+div*bytes-1;
d = dest+div*bytes-1; /* points to last byte */
for (i = 0; i < bytes; ++i)
sum[i] = 0;
for (i = 0; i < div * bytes; ++i)
sum[i % bytes] += *s--;
for (i = 0; i < bytes; ++i)
*d-- = sum[i]/div;
for (row = 0; row < n/2; ++row) {
for (i = 0; i < bytes; ++i) {
sum[i] += *s--;
*d-- = sum[i]/div;
}
++div;
}
gimp_pixel_rgn_set_col(&destPR, dest, col, height-1-div, n/2+1);
}
}
#endif
free(cc);
free(dest);
/* update the blurred region */
gimp_drawable_flush(drawable);
gimp_drawable_merge_shadow(drawable->id, TRUE);
gimp_drawable_update(drawable->id, x1, y1, (x2 - x1), (y2 - y1));
}
static gint
blur2_dialog ()
{
GtkWidget *dlg;
GtkWidget *button;
GtkWidget *frame;
GtkWidget *table;
gchar **argv;
gint argc;
argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup ("blur2");
gtk_init (&argc, &argv);
dlg = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (dlg), "Variable Blur");
gtk_window_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
(GtkSignalFunc) blur2_close_callback,
NULL);
/* Action area */
button = gtk_button_new_with_label ("OK");
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) blur2_ok_callback,
dlg);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button, TRUE, TRUE, 0);
gtk_widget_grab_default (button);
gtk_widget_show (button);
button = gtk_button_new_with_label ("Cancel");
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) gtk_widget_destroy,