RSS/Atom feed Twitter
Site is read-only, email is disabled

Gimp2 plugin porting problems

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

9 of 9 messages available
Toggle history

Please log in to manage your subscriptions.

Gimp2 plugin porting problems Stephan Menzel 02 May 19:47
  Gimp2 plugin porting problems Sven Neumann 02 May 20:39
   Gimp2 plugin porting problems Stephan Menzel 02 May 20:52
    Gimp2 plugin porting problems Jean-Luc 02 May 21:32
     Gimp2 plugin porting problems Stephan Menzel 03 May 13:39
      Gimp2 plugin porting problems Sven Neumann 03 May 13:51
      Gimp2 plugin porting problems Ernst Lippe 03 May 17:02
       Gimp2 plugin porting problems Stephan Menzel 03 May 17:19
        Gimp2 plugin porting problems Sven Neumann 03 May 18:05
Stephan Menzel
2004-05-02 19:47:17 UTC (almost 20 years ago)

Gimp2 plugin porting problems

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

G'day!

I started porting one of my favourite plugins for gimp 1.2 to the new 2.0.1. The sources are already compiling against the new headers and everything looks fine. Unfortunately, the gimp isn't loading the plugin properly. There is just a message like this:

(gimp-2.0:6432): LibGimpBase-WARNING **: gimp-2.0: wire_read(): error

However, the Gimp is starting normally without crashing but the plugin is not available. I suspect, there might be a problem with compiler options or some registering issue but I double checked it all (well, as far as I know which doesn't mean a lot). Does anybody have a clue what I could do?

Stephan

My system is: RedHat Linux 9
gcc 3.2.2
gnome2.2.0

-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFAlTQlbv5p9h9J588RAnmfAJ9Q9aOVTAKlYb/84CyL/3a87qgPpACcDMWp dpwU659smJQX3NmmJe/XpOo=
=6LW9
-----END PGP SIGNATURE-----

Sven Neumann
2004-05-02 20:39:53 UTC (almost 20 years ago)

Gimp2 plugin porting problems

Hi,

Stephan Menzel writes:

I started porting one of my favourite plugins for gimp 1.2 to the new 2.0.1. The sources are already compiling against the new headers and everything looks fine. Unfortunately, the gimp isn't loading the plugin properly. There is just a message like this:

(gimp-2.0:6432): LibGimpBase-WARNING **: gimp-2.0: wire_read(): error

However, the Gimp is starting normally without crashing but the plugin is not available. I suspect, there might be a problem with compiler options or some registering issue but I double checked it all (well, as far as I know which doesn't mean a lot). Does anybody have a clue what I could do?

Start gimp with the --verbose command-line option and check if it's seeing your plug-in at all. We didn't change the way that plug-ins are registered, so I don't know what could be causing this. I'd have to have a look at the source.

Sven

Stephan Menzel
2004-05-02 20:52:27 UTC (almost 20 years ago)

Gimp2 plugin porting problems

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

On Sunday 02 May 2004 20:39, Sven Neumann wrote:

Hi Sven,

Start gimp with the --verbose command-line option and check if it's seeing your plug-in at all.

Did that. The Plugin is recognized. Just the loading fails ist sais: ...
INIT: gimp_real_restore
Plugin »/home/stephan/.gimp-2.0/plug-ins/refocus« wird abgefragt

(gimp-2.0:6855): LibGimpBase-WARNING **: gimp-2.0: wire_read(): error ...
(Sorry for the german gibberish. To lazy to change local...)

We didn't change the way that plug-ins are registered, so I don't know what could be causing this. I'd have to have a look at the source.

The plugin in question is 'refocus' by Ernst Lippe. The whole lot is quite a fair bit but this is query():

MAIN () void query (void)
{
static GimpParamDef args[] = {
{GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive"}, {GIMP_PDB_IMAGE, "image", "Input image (unused)"}, {GIMP_PDB_DRAWABLE, "drawable", "Input drawable"}, {GIMP_PDB_INT32, "mat_size", "Size of matrix"}, {GIMP_PDB_FLOAT, "radius", "Circle radius"}, {GIMP_PDB_FLOAT, "gauss", "Parameter for Gaussian convolution"}, {GIMP_PDB_FLOAT, "correlation", "Correlation"}, {GIMP_PDB_FLOAT, "noise", "Noise to Signal ratio"}, };
static GimpParamDef *return_vals = NULL; static gint nargs = (gint) (sizeof (args) / sizeof (args[0])); static gint nreturn_vals = 0;

gimp_install_procedure ("plug_in_refocus", "Refocus with FIR Wiener Deconvolution", "refocus!", "Ernst Lippe", "Ernst Lippe", "1999",
"/Filters/Enhance/Refocus...", "RGB*, GRAY*", GIMP_PLUGIN, nargs, nreturn_vals, args, return_vals);

}

It is almost untouched by any modifications. Looks just like in all the other plugins to me. I assume the problem might be the Makefile:

...

CC = gcc GCC3 = gcc
GIMPTOOL = /usr/local/bin/gimptool-2.0 GIMP_CFLAGS = -g -O2 -Wall -I/usr/local/include/gimp-2.0 - -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 - -I/usr/include/pango-1.0 -I/usr/X11R6/include -I/usr/include/freetype2 - -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include GIMP_CFLAGS_NOUI = -I/usr/local/include/gimp-2.0 -I/usr/include/glib-2.0 - -I/usr/lib/glib-2.0/include
GIMP_DATA_DIR = /usr/local/share/gimp/2.0 GIMP_LIBS = -L/usr/local/lib -lgimpui-2.0 -lgimpwidgets-2.0 -lgimp-2.0 - -lgimpcolor-2.0 -lgimpmath-2.0 -lgimpbase-2.0 -Wl,--export-dynamic - -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 - -lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 GIMP_LIBS_NOUI = -L/usr/local/lib -lgimp-2.0 -lgimpcolor-2.0 -lgimpmath-2.0 - -lgimpbase-2.0 -lgobject-2.0 -lglib-2.0 GIMP_PLUGIN_DIR = /usr/local/lib/gimp/2.0 GLIB_CFLAGS = -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include GLIB_GENMARSHAL = glib-genmarshal
GLIB_LIBS = -lglib-2.0
GLIB_MKENUMS = glib-mkenums
GOBJECT_QUERY = gobject-query
GTKDOC = false
GTK_CFLAGS = -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include - -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/X11R6/include - -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include GTK_LIBS = -Wl,--export-dynamic -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 - -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 -lpangox-1.0 -lpango-1.0 -lgobject-2.0 - -lgmodule-2.0 -ldl -lglib-2.0
HTML_DIR = ${datadir}/gtk-doc/html
LAPACK_INCLUDE_DIR = ${top_srcdir}/lib LAPACK_LIB_DIR = ${top_srcdir}/lib
MAKEINFO = makeinfo
PACKAGE = refocus
PKG_CONFIG = /usr/bin/pkg-config
RANLIB = ranlib
VERSION = 0.9.0
#GTK_DOC_DIR = #gtk-doc
GTK_DOC_DIR =
...

Can you see anything wron in the compiler or linker options? I had to change ./configure's options to override the old gimp settings.

Thanks a lot!

Stephan

-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFAlUNrbv5p9h9J588RAu5PAKDGjM0LsNW7++ePX5MBtPPmKmEMuwCfT+bP aH7xXsGWuH/E/LfN7O/rHoc=
=GcAq
-----END PGP SIGNATURE-----

Jean-Luc
2004-05-02 21:32:34 UTC (almost 20 years ago)

Gimp2 plugin porting problems

On Sun, May 02, 2004 at 08:52:27PM +0200, Stephan Menzel wrote:

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

On Sunday 02 May 2004 20:39, Sven Neumann wrote:

Hi Sven,

Start gimp with the --verbose command-line option and check if it's seeing your plug-in at all.

Did that. The Plugin is recognized. Just the loading fails ist sais: ...
INIT: gimp_real_restore
Plugin »/home/stephan/.gimp-2.0/plug-ins/refocus« wird abgefragt

(gimp-2.0:6855): LibGimpBase-WARNING **: gimp-2.0: wire_read(): error ...
(Sorry for the german gibberish. To lazy to change local...)

We didn't change the way that plug-ins are registered, so I don't know what could be causing this. I'd have to have a look at the source.

The plugin in question is 'refocus' by Ernst Lippe. The whole lot is quite a fair bit but this is query():

[ ... ]

There is a patch for refocus on sourceforge. If was built for 1.3 but I have applied it and, with this patch applied, the plugin works for me [tm] with gimp 2.0.1.

You can find the patch at: http://sourceforge.net/tracker/?atid=535004&group_id=72588&func=browse

-- Regards
- Jean-Luc

Thanks a lot!

Stephan

-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFAlUNrbv5p9h9J588RAu5PAKDGjM0LsNW7++ePX5MBtPPmKmEMuwCfT+bP aH7xXsGWuH/E/LfN7O/rHoc=
=GcAq
-----END PGP SIGNATURE-----
_______________________________________________ Gimp-developer mailing list
Gimp-developer@lists.xcf.berkeley.edu http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer

Stephan Menzel
2004-05-03 13:39:31 UTC (almost 20 years ago)

Gimp2 plugin porting problems

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

G'day!

On Sunday 02 May 2004 21:32, Jean-Luc wrote:

There is a patch for refocus on sourceforge. If was built for 1.3 but I have applied it and, with this patch applied, the plugin works for me [tm] with gimp 2.0.1.

You can find the patch at: http://sourceforge.net/tracker/?atid=535004&group_id=72588&func=browse

Thank you for your efforts and for that clue. I applied this patch which did pretty much the same stuff I did, apart from some changes in the Makefile. However, it still doesn't work. The same problem. I could find out some more information though that might be helpful. In the src of refocus, there is a test-matrix module compiled, which is not installed by default. I just copied it to the plugin directory to see, what happens. And it is loaded, performs some tests and exits. But it is not a proper plugin. It simply contains a main like this..

int main (int argc, const char *argv[]) {}

Nothing else. No GimpPlugInInfo and no query(). Gimp2 loads and executes it. Is that supposed to happen?
It is built using the same Makefile as refocus itself and uses the very same routines too. I tried including a similar main() in the refocus source but it still doesn't load.
The next thing I tried was executing those binaries directly. And here it is the opposite. The modified refocus binary executes and prints my included 'hello world'. The untouched test-matrix binary just throws a segmentation fault. That brings me to the conclusion that although the Makefile looks identical, there must be some difference in the way those binaries are created.
I also tried a strace which showed nothing suspicious. The plugin is loaded with the same function and return code as all the others. I start to find all that rather interesting but i am still anoyed that I have to run two gimps at the same time now. The old one to do refocus and the new one for everything else. It's consuming lots of memory too so I would really like to see refocus working with 2.0. Any ideas or hints what to do or check next? Hoping it is alright for Ernst I include the src/Makefile and both sources.
Thanks a lot!

Stephan

src/Makefile: # Makefile.in generated automatically by automake 1.4-p5 from Makefile.am

# Copyright (C) 1994, 1995-8, 1999, 2001 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/local 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

DESTDIR =

pkgdatadir = $(datadir)/refocus pkglibdir = $(libdir)/refocus
pkgincludedir = $(includedir)/refocus

top_builddir = ..

ACLOCAL = aclocal-1.8 AUTOCONF = autoconf
AUTOMAKE = automake-1.8
AUTOHEADER = autoheader

INSTALL = /usr/bin/install -c INSTALL_PROGRAM = ${INSTALL} $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = ${INSTALL} -m 644
INSTALL_SCRIPT = ${INSTALL}
transform = s,x,x,

NORMAL_INSTALL = : PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
CC = gcc
GCC3 =
GIMPTOOL = /usr/bin/gimptool-2.0
GIMP_CFLAGS = -I/usr/include/gimp-2.0 -I/usr/include/glib-2.0 - -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include - -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/X11R6/include - -I/usr/include/freetype2
GIMP_CFLAGS_NOUI = -I/usr/include/gimp-2.0 -I/usr/include/glib-2.0 - -I/usr/lib/glib-2.0/include
GIMP_DATA_DIR = /usr/share/gimp/2.0
GIMP_LIBS = -Wl,--export-dynamic -lgimpui-2.0 -lgimpwidgets-2.0 -lgimp-2.0 - -lgimpmath-2.0 -lgimpcolor-2.0 -lgimpbase-2.0 -lgtk-x11-2.0 -lgdk-x11-2.0 - -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 -lpangox-1.0 -lpango-1.0 - -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 GIMP_LIBS_NOUI = -lgimp-2.0 -lgimpmath-2.0 -lgimpcolor-2.0 -lgimpbase-2.0 - -lglib-2.0
GIMP_PLUGIN_DIR = /usr/lib/gimp/2.0
GLIB_CFLAGS = -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include GLIB_GENMARSHAL = glib-genmarshal
GLIB_LIBS = -lglib-2.0
GLIB_MKENUMS = glib-mkenums
GOBJECT_QUERY = gobject-query
GTKDOC = false
GTK_CFLAGS = -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include - -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/X11R6/include - -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include GTK_LIBS = -Wl,--export-dynamic -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 - -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 -lpangox-1.0 -lpango-1.0 -lgobject-2.0 - -lgmodule-2.0 -ldl -lglib-2.0
HTML_DIR = ${datadir}/gtk-doc/html
LAPACK_INCLUDE_DIR = ${top_srcdir}/lib LAPACK_LIB_DIR = ${top_srcdir}/lib
MAKEINFO = makeinfo
PACKAGE = refocus
PKG_CONFIG = /usr/bin/pkg-config
RANLIB = ranlib
VERSION = 0.9.0

INCLUDES = -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include - -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/X11R6/include - -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include - -I/usr/include/gimp-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include - -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 - -I/usr/include/pango-1.0 -I/usr/X11R6/include -I/usr/include/freetype2 -I ${top_srcdir}/lib

bin_PROGRAMS = refocus noinst_PROGRAMS = test-matrix

ldadd_atlas = -L${top_srcdir}/lib -llapack -lcblas -latlas

noinst_HEADERS = bdclosure.h refocus.h matrix.h tilebuf.h conv.h fwlapack.h gimppreview.h prevman.h util.h
EXTRA_DIST = dummy-plugin.c

refocus_SOURCES = refocus.c conv.c gimppreview.c prevman.c util.c matrix.c tilebuf.c bdclosure.c fwlapack.c
refocus_LDADD = -Wl,--export-dynamic -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 - -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 -lpangox-1.0 -lpango-1.0 -lgobject-2.0 - -lgmodule-2.0 -ldl -lglib-2.0 -lgimp ${ldadd_atlas} refocus_DEPENDENCIES = ${top_srcdir}/lib/liblapack.a

test_matrix_SOURCES = matrix.c test-matrix.c fwlapack.c test_matrix_LDADD = -lm ${ldadd_atlas} -lglib-2.0 test_matrix_DEPENDENCIES = ${top_srcdir}/lib/liblapack.a mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_CLEAN_FILES =
PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)

DEFS = -DPACKAGE_NAME=\"refocus\" -DPACKAGE_TARNAME=\"refocus\" - -DPACKAGE_VERSION=\"0.9.0\" -DPACKAGE_STRING=\"refocus\ 0.9.0\" - -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"refocus\" -DVERSION=\"0.9.0\" - -DSTDC_HEADERS=1 -DHAVE_ERF=1 -I. -I$(srcdir) CPPFLAGS =
LDFLAGS =
LIBS =
refocus_OBJECTS = refocus.o conv.o gimppreview.o prevman.o util.o \ matrix.o tilebuf.o bdclosure.o fwlapack.o refocus_LDFLAGS =
test_matrix_OBJECTS = matrix.o test-matrix.o fwlapack.o test_matrix_LDFLAGS =
CFLAGS = -Wall -ansi -pedantic -ggdb -fomit-frame-pointer -O3 - -funroll-all-loops
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ HEADERS = $(noinst_HEADERS)

DIST_COMMON = Makefile.am Makefile.in

DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)

TAR = gtar GZIP_ENV = --best
SOURCES = $(refocus_SOURCES) $(test_matrix_SOURCES) OBJECTS = $(refocus_OBJECTS) $(test_matrix_OBJECTS)

all: all-redirect .SUFFIXES:
.SUFFIXES: .S .c .o .s
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps src/Makefile

Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status

mostlyclean-binPROGRAMS:

clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)

distclean-binPROGRAMS:

maintainer-clean-binPROGRAMS:

install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(bindir) @list='$(bin_PROGRAMS)'; for p in $$list; do \ if test -f $$p; then \
echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ else :; fi; \
done

uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
list='$(bin_PROGRAMS)'; for p in $$list; do \ rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ done

mostlyclean-noinstPROGRAMS:

clean-noinstPROGRAMS: -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)

distclean-noinstPROGRAMS:

maintainer-clean-noinstPROGRAMS:

.c.o: $(COMPILE) -c $<

.s.o:
$(COMPILE) -c $<

.S.o:
$(COMPILE) -c $<

mostlyclean-compile: -rm -f *.o core *.core

clean-compile:

distclean-compile: -rm -f *.tab.c

maintainer-clean-compile:

refocus: $(refocus_OBJECTS) $(refocus_DEPENDENCIES) @rm -f refocus
$(LINK) $(refocus_LDFLAGS) $(refocus_OBJECTS) $(refocus_LDADD) $(LIBS)

test-matrix: $(test_matrix_OBJECTS) $(test_matrix_DEPENDENCIES) @rm -f test-matrix
$(LINK) $(test_matrix_LDFLAGS) $(test_matrix_OBJECTS) $(test_matrix_LDADD) $(LIBS)

tags: TAGS

ID: $(HEADERS) $(SOURCES) $(LISP) list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \ here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)

TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)

mostlyclean-tags:

clean-tags:

distclean-tags: -rm -f TAGS ID

maintainer-clean-tags:

distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)

subdir = src

distdir: $(DISTFILES) @for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \ else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \ || cp -p $$d/$$file $(distdir)/$$file || :; \ fi; \
done
bdclosure.o: bdclosure.c bdclosure.h util.h conv.o: conv.c refocus.h util.h tilebuf.h prevman.h conv.h matrix.h \ bdclosure.h
dummy-plugin.o: dummy-plugin.c
fwlapack.o: fwlapack.c fwlapack.h util.h ../lib/f2c.h ../lib/clapack.h gimppreview.o: gimppreview.c gimppreview.h matrix.o: matrix.c fwlapack.h matrix.h refocus.h util.h prevman.o: prevman.c prevman.h util.h refocus.o: refocus.c gimppreview.h refocus.h prevman.h matrix.h conv.h \ tilebuf.h bdclosure.h util.h
test-matrix.o: test-matrix.c matrix.h refocus.h util.h tilebuf.o: tilebuf.c tilebuf.h prevman.h util.h util.o: util.c util.h

info-am: info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am: install-binPROGRAMS install-exec: install-exec-am

install-data-am: install-data: install-data-am

install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am install: install-am
uninstall-am: uninstall-binPROGRAMS
uninstall: uninstall-am
all-am: Makefile $(PROGRAMS) $(HEADERS) all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs:
$(mkinstalldirs) $(DESTDIR)$(bindir)

mostlyclean-generic:

clean-generic:

distclean-generic: -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]*

maintainer-clean-generic: mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-noinstPROGRAMS \ mostlyclean-compile mostlyclean-tags \ mostlyclean-generic

mostlyclean: mostlyclean-am

clean-am: clean-binPROGRAMS clean-noinstPROGRAMS clean-compile \ clean-tags clean-generic mostlyclean-am

clean: clean-am

distclean-am: distclean-binPROGRAMS distclean-noinstPROGRAMS \ distclean-compile distclean-tags distclean-generic \ clean-am

distclean: distclean-am

maintainer-clean-am: maintainer-clean-binPROGRAMS \ maintainer-clean-noinstPROGRAMS \
maintainer-clean-compile maintainer-clean-tags \ maintainer-clean-generic distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild."

maintainer-clean: maintainer-clean-am

.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \ maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \ mostlyclean-noinstPROGRAMS distclean-noinstPROGRAMS \ clean-noinstPROGRAMS maintainer-clean-noinstPROGRAMS \ mostlyclean-compile distclean-compile clean-compile \ maintainer-clean-compile tags mostlyclean-tags distclean-tags \ clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \ check-am installcheck-am installcheck install-exec-am install-exec \ install-data-am install-data install-am install uninstall-am uninstall \ all-redirect all-am all installdirs mostlyclean-generic \ distclean-generic clean-generic maintainer-clean-generic clean \ mostlyclean distclean maintainer-clean

install-bin: refocus @if test "x /usr/bin/gimptool-2.0" = "x" ; then \ echo "Warning: configure did not find gimptool" ; \ echo "install src/refocus manually in your plug-in directory" ; \ echo "e.g.: cp src/refocus ~/.gimp-1.2/plug-ins" ; \ else \
/usr/bin/gimptool-2.0 --install-bin refocus ; \ fi

install-admin-bin: refocus @if test "x /usr/bin/gimptool-2.0" = "x" ; then \ echo "Warning: configure did not find gimptool" ; \ echo "install src/refocus manually in your plug-in directory" ; \ echo "e.g.: install src/refocus /usr/local/lib/gimp-1.2/plug-ins" ; \ else \
/usr/bin/gimptool-2.0 --install-admin-bin refocus ; \ fi

${top_srcdir}/lib/liblapack.a: cd ${top_srcdir}/lib; make

%.s: %.c ${CC} ${CFLAGS} -S $< -o $@

# 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:

refocus.c:
/* Refocus plug-in
* Copyright (C) 1999-2003 Ernst Lippe *
* Based on the Convolution Matrix plug-in by Lauri Alanko *
* This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. *
* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* Version $Id: refocus.c,v 1.1.1.1 2003/01/30 21:30:19 ernstl Exp $ */

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "gimppreview.h"
#include "refocus.h"
#include "prevman.h"
#include "matrix.h"
#include "conv.h"
#include "bdclosure.h"
#include "util.h"

#ifndef lint static char vcid[] GCC_UNUSED = "$Id: refocus.c,v 1.1.1.1 2003/01/30 21:30:19 ernstl Exp $";
#endif /* lint */

GimpDrawable *drawable;

/* Declare local functions. */ static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam * param, gint * nreturn_vals, GimpParam ** return_vals); static gint dialog ();
static void doit (void);
static void check_config (void);

GimpPlugInInfo PLUG_IN_INFO = { NULL, /* init_proc */ NULL, /* quit_proc */ query, /* query_proc */ run, /* run_proc */ };

gint bytes;
gint sx1, sy1, sx2, sy2;
gint run_flag = 0;
CMat *matrix = NULL;
gboolean matrix_needs_updating = TRUE;

typedef struct {
gint mat_width;
gdouble radius, alpha, gamma, noise_factor; }
config;

const config default_config = { 5,
1,
0.0,
0.5,
0.01
};

config my_config;

struct {
GtkWidget *preview;
GtkWidget *mat_width_entry;
GtkWidget *radius_entry;
GtkWidget *alpha_entry;
GtkWidget *gamma_entry;
GtkWidget *noise_entry;
GtkWidget *ok_button;
GtkWidget *update_preview_button;
}
my_widgets;

MAIN ()
static void query ()
{
static GimpParamDef args[] = {
{GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive"}, {GIMP_PDB_IMAGE, "image", "Input image (unused)"}, {GIMP_PDB_DRAWABLE, "drawable", "Input drawable"}, {GIMP_PDB_INT32, "mat_size", "Size of matrix"}, {GIMP_PDB_FLOAT, "radius", "Circle radius"}, {GIMP_PDB_FLOAT, "gauss", "Parameter for Gaussian convolution"}, {GIMP_PDB_FLOAT, "correlation", "Correlation"}, {GIMP_PDB_FLOAT, "noise", "Noise to Signal ratio"}, };
static GimpParamDef *return_vals = NULL; static gint nreturn_vals = 0;

gimp_install_procedure ("plug_in_refocus", "Refocus with FIR Wiener Deconvolution", "",
"Ernst Lippe", "Ernst Lippe", "1999",
"/Filters/Enhance/Refocus ...", "RGB*, GRAY*", GIMP_PLUGIN, G_N_ELEMENTS(args), nreturn_vals, args, return_vals);
}

static void
run (const gchar *name, gint n_params, const GimpParam * param, gint * nreturn_vals, GimpParam ** return_vals) {
static GimpParam values[1];
GimpRunMode run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;

(void) name; /* Shut up warnings about unused parameters. */
/* Sleep so the debugger can attach to this proces */ /* sleep(30); */
*nreturn_vals = 1;
*return_vals = values;

run_mode = param[0].data.d_int32;

/* Get the specified drawable */ drawable = gimp_drawable_get (param[2].data.d_drawable);

my_config = default_config; /* Although the convolution should work fine with a tiny cache it is made bigger to improve scrolling speed */ gimp_tile_cache_ntiles (20);

if (run_mode == GIMP_RUN_NONINTERACTIVE) {
if (n_params != 8)
status = GIMP_PDB_CALLING_ERROR; else
{
my_config.mat_width = param[3].data.d_int32; my_config.radius = param[4].data.d_float; my_config.alpha = param[5].data.d_float; my_config.gamma = param[6].data.d_float; my_config.noise_factor = param[7].data.d_float; check_config ();
}
}
else
{
gimp_get_data ("plug_in_refocus", &my_config);

if (run_mode == GIMP_RUN_INTERACTIVE) {
/* Oh boy. We get to do a dialog box, because we can't really expect the
* user to set us up with the right values using gdb. */
check_config ();
if (!dialog ())
{
/* The dialog was closed, or something similarly evil happened. */
status = GIMP_PDB_EXECUTION_ERROR; }
}
}

if (status == GIMP_PDB_SUCCESS) {

/* Make sure that the drawable is gray or RGB color */ if (gimp_drawable_is_rgb (drawable->drawable_id) || gimp_drawable_is_gray (drawable->drawable_id)) {
doit ();

if (run_mode != GIMP_RUN_NONINTERACTIVE) gimp_displays_flush ();
if (run_mode == GIMP_RUN_INTERACTIVE) gimp_set_data ("plug_in_refocus", &my_config, sizeof (my_config)); }
else
{
status = GIMP_PDB_EXECUTION_ERROR; }
gimp_drawable_detach (drawable); }

values[0].type = GIMP_PDB_STATUS; values[0].data.d_status = status;
}

/* Matrix computing */
void
set_matrix_needs_updating (gboolean update_needed) {
matrix_needs_updating = update_needed; if (my_widgets.update_preview_button) {
gtk_widget_set_sensitive (my_widgets.update_preview_button, matrix_needs_updating); }
}

void
update_matrix (void)
/* Recompute matrix if needed */
{
CMat circle, gaussian, convolution;

if (matrix_needs_updating) {
if (matrix)
{
finish_c_mat (matrix);
};
make_gaussian_convolution (my_config.alpha, &gaussian, my_config.mat_width); make_circle_convolution (my_config.radius, &circle, my_config.mat_width); #ifdef RF_DEBUG
fprintf (stderr, "mat_width=%d alpha=%f radius=%f gamma=%f noise=%f\n", my_config.mat_width, my_config.alpha, my_config.radius, my_config.gamma, my_config.noise_factor); fprintf (stderr, "Gauss\n");
print_c_mat (stderr, &gaussian); fprintf (stderr, "Circle\n");
print_c_mat (stderr, &circle); #endif

/* TODO: must use normal convolution */ init_c_mat (&convolution, my_config.mat_width); convolve_star_mat (&convolution, &gaussian, &circle); matrix = compute_g_matrix (&convolution, my_config.mat_width, my_config.gamma, my_config.noise_factor, 0.0, TRUE); finish_c_mat (&convolution);
finish_c_mat (&gaussian);
finish_c_mat (&circle);
set_matrix_needs_updating (FALSE); }
}

/*************************************************** * GUI stuff
*/

static void
set_busy_cursor (GtkWidget * widget, gboolean busy_on) {
GdkCursor *cursor = (busy_on) ? gdk_cursor_new (GDK_WATCH) : NULL;

gdk_window_set_cursor (GTK_WIDGET (widget)->window, cursor); }

static void
redraw_all (void)
{
gtk_spin_button_set_value (GTK_SPIN_BUTTON (my_widgets.mat_width_entry), my_config.mat_width); gtk_spin_button_set_value (GTK_SPIN_BUTTON (my_widgets.radius_entry), my_config.radius); gtk_spin_button_set_value (GTK_SPIN_BUTTON (my_widgets.alpha_entry), my_config.alpha); gtk_spin_button_set_value (GTK_SPIN_BUTTON (my_widgets.gamma_entry), my_config.gamma); gtk_spin_button_set_value (GTK_SPIN_BUTTON (my_widgets.noise_entry), my_config.noise_factor); }

static void
close_callback (GtkWidget * widget, gpointer data) {
(void) widget; /* Shut up warnings about unused parameters. */
(void) data;
gtk_main_quit ();
}

static void
ok_callback (GtkWidget * widget, gpointer data) {
(void) widget; /* Shut up warnings about unused parameters. */
run_flag = 1;
gtk_widget_destroy (GTK_WIDGET (data)); }

/* Checks that the configuration is valid for the image type */ static void
check_config (void)
{
}

static void
defaults_callback (GtkWidget * widget, gpointer data) {
(void) widget; /* Shut up warnings about unused parameters. */
(void) data;
gtk_spin_button_set_value (GTK_SPIN_BUTTON (my_widgets.mat_width_entry), default_config.mat_width); gtk_spin_button_set_value (GTK_SPIN_BUTTON (my_widgets.radius_entry), default_config.radius); gtk_spin_button_set_value (GTK_SPIN_BUTTON (my_widgets.alpha_entry), default_config.alpha); gtk_spin_button_set_value (GTK_SPIN_BUTTON (my_widgets.gamma_entry), default_config.gamma); gtk_spin_button_set_value (GTK_SPIN_BUTTON (my_widgets.noise_entry), default_config.noise_factor); check_config ();
redraw_all ();
}

static void
update_callback (GtkWidget * widget, gpointer data) {
(void) widget; /* Shut up warnings about unused parameters. */
(void) data;
set_busy_cursor (widget, TRUE);
update_matrix ();
gimp_preview_update (GIMP_PREVIEW (my_widgets.preview)); set_busy_cursor (widget, FALSE);
}

static void
gdouble_entry_callback (GtkWidget * widget, gdouble * data) {
const gdouble epsilon = 1e-10;
gdouble new_value = gtk_spin_button_get_value (GTK_SPIN_BUTTON (widget)); if (fabs (new_value - *data) > epsilon) {
*data = new_value;
set_matrix_needs_updating (TRUE); }
}

static void
gint_entry_callback (GtkWidget * widget, gint * data) {
gint new_value =
gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget)); if (new_value != *data)
{
*data = new_value;
set_matrix_needs_updating (TRUE); }
}

gboolean
preview_progress_update_fun (const gpointer data, double arg) {
gint event_id = GPOINTER_TO_INT (data); return (gimp_preview_progress_set_fraction (GIMP_PREVIEW (my_widgets.preview), event_id, arg)); }

static void
preview_callback (GtkWidget * widget, GimpPreviewEvent * event, gpointer data) {
TileSource source;
TileSink sink;
gint row;
guchar *buf;
const gint im_width = event->image_width; const gint im_height = event->image_height; const gint image_x = event->image_x; const gint image_y = event->image_y; gboolean event_is_current = TRUE;
BDClosure update_progress_closure;

if (matrix) {
update_matrix ();
tile_source_init_from_drawable (&source, drawable, image_x, image_y, im_width, im_height); tile_sink_init_for_preview (&sink, drawable, image_x, image_y, im_width, im_height); gimp_preview_progress_set_fraction (GIMP_PREVIEW (my_widgets.preview), event->event_id, 0); bd_closure_init (&update_progress_closure, preview_progress_update_fun, GINT_TO_POINTER (event->event_id));

convolve_image (&source, &sink, image_x, image_y, im_width, im_height, TB_BOUNDARY_MIRROR, matrix, 2 * my_config.mat_width + 1, &update_progress_closure); buf = g_new (guchar, im_width * drawable->bpp); for (row = 0; event_is_current && (row < im_height); row++) {
tile_sink_get_row (&sink, buf, image_x, image_y + row, im_width); event_is_current =
gimp_preview_draw_unscaled_row (GIMP_PREVIEW (my_widgets.preview), event->event_id, gimp_drawable_type (drawable->drawable_id),
row, buf); };
g_free (buf);
tile_sink_free_buffers (&sink); }
}

static gint
dialog ()
{
GtkWidget *dlg;
GtkWidget *button;
GtkWidget *label;
GtkWidget *entry;
GtkWidget *outbox;
GtkWidget *vpaned;
GtkWidget *empty_box;
GtkWidget *table;
GtkWidget *preview;
gchar **argv;
gint argc;

argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup ("refocus");

gtk_init (&argc, &argv); gtk_rc_parse (gimp_gtkrc ());

dlg = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (dlg), "Refocus"); gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE); g_signal_connect (G_OBJECT (dlg), "destroy", G_CALLBACK (close_callback), NULL);

/* Action area */ my_widgets.ok_button = button = gtk_button_new_with_label ("OK"); GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (ok_callback), G_OBJECT (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 ("Defaults"); GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); g_signal_connect_object (G_OBJECT (button), "clicked", G_CALLBACK (defaults_callback), G_OBJECT (dlg), 0); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button, TRUE, TRUE, 0);
gtk_widget_show (button);

my_widgets.update_preview_button = button = gtk_button_new_with_label ("Preview"); GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); g_signal_connect_object (G_OBJECT (button), "clicked", G_CALLBACK (update_callback), G_OBJECT (dlg), 0); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button, TRUE, TRUE, 0);
gtk_widget_show (button);

button = gtk_button_new_with_label ("Cancel"); GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); g_signal_connect_object (G_OBJECT (button), "clicked", G_CALLBACK (close_callback), G_OBJECT (dlg), 0); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button, TRUE, TRUE, 0);
gtk_widget_show (button);

/* Outbox */ outbox = gtk_hpaned_new ();
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), outbox, TRUE, TRUE, 0);

/* Outbox:Preview */ vpaned = gtk_vpaned_new ();
preview = my_widgets.preview = gimp_preview_new (drawable); g_signal_connect (G_OBJECT (preview), "update_preview", G_CALLBACK (preview_callback), (gpointer) NULL); gtk_paned_pack1 (GTK_PANED (outbox), vpaned, TRUE, TRUE); gtk_paned_pack1 (GTK_PANED (vpaned), preview, TRUE, TRUE); empty_box = gtk_hbox_new (TRUE, 0); gtk_paned_pack2 (GTK_PANED (vpaned), empty_box, TRUE, TRUE); gtk_widget_show (empty_box);
gtk_widget_show (vpaned);
gtk_widget_show (preview);

/* Outbox:Table */ table = gtk_table_new (5, 2, FALSE); gtk_paned_pack2 (GTK_PANED (outbox), table, TRUE, TRUE);

/* mat_width */

label = gtk_label_new ("Matrix Size"); gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1); gtk_widget_show (label);

my_widgets.mat_width_entry = entry = gtk_spin_button_new_with_range (0.0, 25.0, 1.0); gtk_spin_button_set_digits (GTK_SPIN_BUTTON (entry), 0); gtk_table_attach_defaults (GTK_TABLE (table), entry, 1, 2, 0, 1); g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (gint_entry_callback), &my_config.mat_width); gtk_widget_show (entry);

/* Radius */

label = gtk_label_new ("Radius"); gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 1, 2); gtk_widget_show (label);

my_widgets.radius_entry = entry = gtk_spin_button_new_with_range (0.0, 25.0, 0.1); gtk_table_attach_defaults (GTK_TABLE (table), entry, 1, 2, 1, 2); gtk_spin_button_set_digits (GTK_SPIN_BUTTON (entry), 2); g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (gdouble_entry_callback), &my_config.radius); gtk_widget_show (entry);

/* Alpha */

label = gtk_label_new ("Gauss"); gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 2, 3); gtk_widget_show (label);

my_widgets.alpha_entry = entry = gtk_spin_button_new_with_range (0.0, 25.0, 0.1); gtk_spin_button_set_digits (GTK_SPIN_BUTTON (entry), 2); gtk_table_attach_defaults (GTK_TABLE (table), entry, 1, 2, 2, 3); g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (gdouble_entry_callback), &my_config.alpha); gtk_widget_show (entry);

/* gamma */

label = gtk_label_new ("Correlation"); gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 3, 4); gtk_widget_show (label);

my_widgets.gamma_entry = entry = gtk_spin_button_new_with_range (0.0, 1.0, 0.05); gtk_spin_button_set_digits (GTK_SPIN_BUTTON (entry), 3); gtk_table_attach_defaults (GTK_TABLE (table), entry, 1, 2, 3, 4); g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (gdouble_entry_callback), &my_config.gamma); gtk_widget_show (entry);

/* noise ratio */

label = gtk_label_new ("Noise"); gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 4, 5); gtk_widget_show (label);

my_widgets.noise_entry = entry = gtk_spin_button_new_with_range (0.0, 1.0, 0.01); gtk_spin_button_set_digits (GTK_SPIN_BUTTON (entry), 5);

gtk_table_attach_defaults (GTK_TABLE (table), entry, 1, 2, 4, 5); g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (gdouble_entry_callback), &my_config.noise_factor); gtk_widget_show (entry);

gtk_widget_show (table); gtk_widget_show (outbox);

gtk_widget_show (dlg); redraw_all ();
gimp_preview_update (GIMP_PREVIEW (preview)); gtk_main ();
gdk_flush ();
return run_flag;
}

static gboolean
gimp_progress_update_fun (gpointer data, gdouble fraction) {
return (gimp_progress_update (fraction)); }

void
doit (void)
{
TileSource source;
TileSink sink;
gint width, height;
BDClosure update_progress_closure;

bd_closure_init (&update_progress_closure, gimp_progress_update_fun, NULL); gimp_progress_init ("Computing matrix"); update_matrix ();
gimp_progress_init ("Applying convolution"); gimp_drawable_mask_bounds (drawable->drawable_id, &sx1, &sy1, &sx2, &sy2); width = sx2 - sx1;
height = sy2 - sy1;
tile_source_init_from_drawable (&source, drawable, sx1, sy1, width, height); tile_sink_init_from_drawable (&sink, drawable, sx1, sy1, width, height); convolve_image (&source, &sink, sx1, sy1, width, height, TB_BOUNDARY_MIRROR, matrix, 2 * my_config.mat_width + 1, &update_progress_closure); gimp_drawable_flush (drawable);
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE); gimp_drawable_update (drawable->drawable_id, sx1, sy1, width, height); g_free (matrix);
}

test-matrix.c:
/* Refocus plug-in
* Copyright (C) 1999-2003 Ernst Lippe *
* This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. *
* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* Version $Id: test-matrix.c,v 1.1.1.1 2003/01/30 21:30:19 ernstl Exp $ */

#include
#include "matrix.h"
#include "util.h"

#ifndef lint static char vcid[] GCC_UNUSED = "$Id: test-matrix.c,v 1.1.1.1 2003/01/30 21:30:19 ernstl Exp $";
#endif /* lint */

int
main (int argc, const char *argv[])
{
CMat *g;
gint m = strtol (argv[1], 0, 0);
REAL gamma = strtod (argv[2], 0);
REAL alpha = strtod (argv[3], 0);
REAL noise_factor = strtod (argv[4], 0); CMat convolution;

make_circle_convolution (alpha, &convolution, m); fprintf (stderr, "********* Convolution matrix ***********\n"); print_c_mat (stderr, &convolution);

fprintf (stderr, "********* Not Symmetric ***********\n"); g = compute_g_matrix (&convolution, m, gamma, noise_factor, 0.0, FALSE); fprintf (stderr,
"********* Not Symmetric Deconvolution matrix ***********\n"); print_c_mat (stderr, g);
fprintf (stderr, "********* Symmetric ***********\n"); g = compute_g_matrix (&convolution, m, gamma, noise_factor, 0.0, TRUE); fprintf (stderr, "********* Symmetric Deconvolution matrix ***********\n"); print_c_mat (stderr, g);

return (0); }

-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFAli90bv5p9h9J588RAoXwAJ4wMftPqIOCtFiazgGgp4CthjvNdwCff3Rz 4g26rMemU7K/r9fXoDjGDs0=
=fIVK
-----END PGP SIGNATURE-----

Sven Neumann
2004-05-03 13:51:57 UTC (almost 20 years ago)

Gimp2 plugin porting problems

Hi,

Stephan Menzel writes:

to run two gimps at the same time now. The old one to do refocus and the new one for everything else. It's consuming lots of memory too so I would really like to see refocus working with 2.0. Any ideas or hints what to do or check next? Hoping it is alright for Ernst I include the src/Makefile and both sources. Thanks a lot!

Including the Makefile is not really helpful since noone wants to read an automatically generated Makefile. It's Makefile.am that you should show us.

I suggest you use ldd to check what libraries the plug-in executables are linked to at run-time. That might give you a hint on what's going wrong.

Sven

Ernst Lippe
2004-05-03 17:02:10 UTC (almost 20 years ago)

Gimp2 plugin porting problems

On Monday 03 May 2004 13:39, Stephan Menzel wrote:

G'day!

On Sunday 02 May 2004 21:32, Jean-Luc wrote:

There is a patch for refocus on sourceforge. If was built for 1.3 but I have applied it and, with this patch applied, the plugin works for me [tm] with gimp 2.0.1.

You can find the patch at: http://sourceforge.net/tracker/?atid=535004&group_id=72588&func=browse

I think that I have found cause of the Stephan's problem. My plugin used GTK-2, so in the makefiles I had to use some tricks to get the correct include path and libraries. I could not directly use the output of the old gimptool, because that used the wrong GTK versions.

I did not have time to look at the patch at sourceforge, but it seems like Stephan is linking with the old version of the libgimp libraries. The obvious solution is to simply use the outputs from gimptool-2 instead of my hacked version. I am afraid that I don't have the time right now to suggest a good solution (anyhow I don't have Gimp-2 installed, so I can't test any modifications).

Ernst Lippe

Stephan Menzel
2004-05-03 17:19:29 UTC (almost 20 years ago)

Gimp2 plugin porting problems

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

On Monday 03 May 2004 17:02, Ernst Lippe wrote:

I think that I have found cause of the Stephan's problem. My plugin used GTK-2, so in the makefiles I had to use some tricks to get the correct include path and libraries. I could not directly use the output of the old gimptool, because that used the wrong GTK versions.

Hello Ernst!

yes, that seems right. gimptool caused problems during configure and I tried several workarounds that seemed to work in the first place but this was some kind of wishful thinking.

I did not have time to look at the patch at sourceforge, but it seems like Stephan is linking with the old version of the libgimp libraries. The obvious solution is to simply use the outputs from gimptool-2 instead of my hacked version. I am afraid that I don't have the time right now to suggest a good solution (anyhow I don't have Gimp-2 installed, so I can't test any modifications).

I just checked with ldd as Sven suggested and here's the output:

libgtk-x11-2.0.so.0 => /usr/lib/libgtk-x11-2.0.so.0 (0x40033000) libgdk-x11-2.0.so.0 => /usr/lib/libgdk-x11-2.0.so.0 (0x40288000) libatk-1.0.so.0 => /usr/lib/libatk-1.0.so.0 (0x402f7000) libgdk_pixbuf-2.0.so.0 => /usr/lib/libgdk_pixbuf-2.0.so.0 (0x40310000) libm.so.6 => /lib/tls/libm.so.6 (0x40324000) libpangoxft-1.0.so.0 => /usr/lib/libpangoxft-1.0.so.0 (0x40346000) libpangox-1.0.so.0 => /usr/lib/libpangox-1.0.so.0 (0x40367000) libpango-1.0.so.0 => /usr/lib/libpango-1.0.so.0 (0x40374000) libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0 (0x403a7000) libgmodule-2.0.so.0 => /usr/lib/libgmodule-2.0.so.0 (0x403dc000) libdl.so.2 => /lib/libdl.so.2 (0x403e1000) libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0x403e5000) libgimp-1.2.so.0 => /usr/lib/libgimp-1.2.so.0 (0x4044f000) libc.so.6 => /lib/tls/libc.so.6 (0x42000000) libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x40470000) libXrandr.so.2 => /usr/X11R6/lib/libXrandr.so.2 (0x4054e000) libXi.so.6 => /usr/X11R6/lib/libXi.so.6 (0x40553000) libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x4055b000) libXft.so.2 => /usr/X11R6/lib/libXft.so.2 (0x40569000) libXrender.so.1 => /usr/X11R6/lib/libXrender.so.1 (0x4057b000) libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0x40583000) libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x405aa000) libz.so.1 => /usr/lib/libz.so.1 (0x405fc000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) libglib-1.2.so.0 => /usr/lib/libglib-1.2.so.0 (0x4060a000) libexpat.so.0 => /usr/lib/libexpat.so.0 (0x4062f000)

I understand it links against libgimp-1.2 which is apparently wrong. Jean-Luc meanwhile sent me a compiled binary and refocus is running now with my gimp2 which is great and I can continue my work. However, I will try to work more on the problem and I will post a solution when I found it. Thank you so far!

Stephan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFAlmMGbv5p9h9J588RAjg/AJ9n3HGRpjihmhl12IJ35hCZuo3ZyQCggxBt 2DR9ndRyEMxbhdvOqSyaNUU=
=SQrB
-----END PGP SIGNATURE-----

Sven Neumann
2004-05-03 18:05:20 UTC (almost 20 years ago)

Gimp2 plugin porting problems

Hi,

Stephan Menzel writes:

gimptool caused problems during configure and I tried several workarounds that seemed to work in the first place but this was some kind of wishful thinking.

I did not have time to look at the patch at sourceforge, but it seems like Stephan is linking with the old version of the libgimp libraries. The obvious solution is to simply use the outputs from gimptool-2 instead of my hacked version. I am afraid that I don't have the time right now to suggest a good solution (anyhow I don't have Gimp-2 installed, so I can't test any modifications).

The best thing is not to use gimptool at all but to use pkg-config. For a plug-in that has a user interface, you'd use this:

pkg-config --cflags gimpui-2.0 pkg-config --libs gimpui-2.0

For a plug-in that just needs libgimp, the following should work:

pkg-config --cflags gimp-2.0 pkg-config --libs gimp-2.0

If you want to use libgimpthumb, you can use this:

pkg-config --cflags gimpui-2.0 gimpthumb-2.0 pkg-config --libs gimpui-2.0 gimpthumb-2.0

You should get the idea. If not, have a look at the pkg-config man-page.

Sven