aboutsummaryrefslogtreecommitdiff
path: root/graphics/gimp-refocus-plugin
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/gimp-refocus-plugin')
-rw-r--r--graphics/gimp-refocus-plugin/Makefile84
-rw-r--r--graphics/gimp-refocus-plugin/distinfo2
-rw-r--r--graphics/gimp-refocus-plugin/files/patch-configure.in85
-rw-r--r--graphics/gimp-refocus-plugin/files/patch-lib__Makefile.am7
-rw-r--r--graphics/gimp-refocus-plugin/files/patch-src__Makefile.am47
-rw-r--r--graphics/gimp-refocus-plugin/files/patch-src__conv.c34
-rw-r--r--graphics/gimp-refocus-plugin/files/patch-src__gimppreview.c384
-rw-r--r--graphics/gimp-refocus-plugin/files/patch-src__gimppreview.h82
-rw-r--r--graphics/gimp-refocus-plugin/files/patch-src__prevman.c29
-rw-r--r--graphics/gimp-refocus-plugin/files/patch-src__refocus.c124
-rw-r--r--graphics/gimp-refocus-plugin/files/patch-src__tilebuf.c189
-rw-r--r--graphics/gimp-refocus-plugin/files/patch-src__util.c49
-rw-r--r--graphics/gimp-refocus-plugin/pkg-descr18
13 files changed, 1134 insertions, 0 deletions
diff --git a/graphics/gimp-refocus-plugin/Makefile b/graphics/gimp-refocus-plugin/Makefile
new file mode 100644
index 000000000000..8469f3918907
--- /dev/null
+++ b/graphics/gimp-refocus-plugin/Makefile
@@ -0,0 +1,84 @@
+# Created by: Mario Sergio Fujikawa Ferreira <lioux@FreeBSD.org>
+# $FreeBSD$
+
+PORTNAME= refocus
+PORTVERSION= 0.9.0
+CATEGORIES= graphics
+MASTER_SITES= SF
+PKGNAMEPREFIX= gimp-
+PKGNAMESUFFIX= -plugin
+
+MAINTAINER= lioux@FreeBSD.org
+COMMENT= GIMP plugin to "refocus" images through FIR Wiener filtering
+
+LICENSE= GPLv2
+
+BUILD_DEPENDS= ${LOCALBASE}/libdata/pkgconfig/gimp-2.0.pc:${PORTSDIR}/graphics/gimp-app
+RUN_DEPENDS= ${LOCALBASE}/libdata/pkgconfig/gimp-2.0.pc:${PORTSDIR}/graphics/gimp-app
+
+OPTIONS_DEFINE= ATLAS DOCS OPTIMIZED_CFLAGS
+OPTIONS_DEFAULT= OPTIMIZED_CFLAGS
+
+ATLAS_DESC= Build with optimized math/atlas instead of builtin
+
+USES= gettext gmake pathfix pkgconfig
+
+# GCC required due to fortran dependency, e.g., math/atlas
+USE_GCC= yes
+
+USE_AUTOTOOLS= aclocal autoconf automake
+AUTOMAKE_ARGS= --add-missing
+GNU_CONFIGURE= yes
+CONFIGURE_ENV= GIMPTOOL=${LOCALBASE}/bin/gimptool-2.0
+
+GIMP_PLUGIN_DIR= libexec/gimp/2.2/plug-ins
+
+# installed files
+PLIST_FILES= ${GIMP_PLUGIN_DIR}/${PORTNAME}
+
+# installed dirs
+PLIST_DIRSTRY= libexec/gimp/2.2/plug-ins \
+ libexec/gimp/2.2 \
+ libexec/gimp
+
+post-patch:
+ @${FIND} ${WRKSRC} -name Makefile.am \
+ -exec ${REINPLACE_CMD} -e "s|; make|; ${GMAKE}|" {} \;
+ @${REINPLACE_CMD} -e "s|%%WRKSRC%%|${WRKSRC}|" \
+ ${WRKSRC}/configure.in
+
+.include <bsd.port.options.mk>
+
+# math/atlas library
+.if ${PORT_OPTIONS:MATLAS}
+BUILD_DEPENDS+= \
+ ${LOCALBASE}/include/f2c.h:${PORTSDIR}/lang/f2c \
+ ${LOCALBASE}/include/clapack.h:${PORTSDIR}/math/atlas
+RUN_DEPENDS+= \
+ ${LOCALBASE}/include/clapack.h:${PORTSDIR}/math/atlas
+
+CONFIGURE_ARGS+= --with-lapack-libs="-L${LOCALBASE}/lib -latlas -lblas -lcblas -llapack" \
+ --with-lapack-includes="-I${LOCALBASE}/include"
+.endif
+
+# optimized CFLAGS
+.if ${PORT_OPTIONS:MOPTIMIZED_CFLAGS}
+CFLAGS+= -O3
+.endif
+
+# documentation
+PORTDOCS= *
+
+do-install:
+# plugin
+ @${MKDIR} ${STAGEDIR}${PREFIX}/${GIMP_PLUGIN_DIR}/
+ ${INSTALL_PROGRAM} ${WRKSRC}/src/${PORTNAME} \
+ ${STAGEDIR}${PREFIX}/${GIMP_PLUGIN_DIR}/
+# docs
+.if ${PORT_OPTIONS:MDOCS}
+ @${MKDIR} ${STAGEDIR}${DOCSDIR}
+ ${INSTALL_DATA} ${WRKSRC}/doc/*html ${STAGEDIR}${DOCSDIR}
+ ${INSTALL_DATA} ${WRKSRC}/doc/*pdf ${STAGEDIR}${DOCSDIR}
+.endif
+
+.include <bsd.port.mk>
diff --git a/graphics/gimp-refocus-plugin/distinfo b/graphics/gimp-refocus-plugin/distinfo
new file mode 100644
index 000000000000..856a1b5af600
--- /dev/null
+++ b/graphics/gimp-refocus-plugin/distinfo
@@ -0,0 +1,2 @@
+SHA256 (refocus-0.9.0.tar.gz) = 35cc4ed11c14406a71a27977dd6c1fb3a3071695511cb9546643709b904befe4
+SIZE (refocus-0.9.0.tar.gz) = 381967
diff --git a/graphics/gimp-refocus-plugin/files/patch-configure.in b/graphics/gimp-refocus-plugin/files/patch-configure.in
new file mode 100644
index 000000000000..138fc38d4ca6
--- /dev/null
+++ b/graphics/gimp-refocus-plugin/files/patch-configure.in
@@ -0,0 +1,85 @@
+--- configure.in.orig 2003-01-30 19:29:29.000000000 -0200
++++ configure.in 2014-04-01 22:37:57.000000000 -0300
+@@ -1,8 +1,8 @@
+ dnl Process this file with autoconf to produce a configure script.
+
+-AC_INIT(README)
+-
+-AM_INIT_AUTOMAKE(refocus, 0.9.0)
++AC_INIT([refocus],[0.9.0])
++AC_CONFIG_SRCDIR(README)
++AM_INIT_AUTOMAKE
+
+ AC_PROG_CC
+ AC_CHECK_PROG(GCC3, gcc3, gcc3)
+@@ -12,31 +12,32 @@
+ AC_MSG_RESULT([using $CC as compiler])
+ fi
+
+-AC_STDC_HEADERS
++AC_HEADER_STDC([])
+ AC_PROG_RANLIB
+
+-# Check if the user has ATLAS installed in ./lib-atlas
+-fw_save_LIBS=$LIBS
+-LIBS=-L./lib-atlas/lib ${LDFLAGS}
+-AC_CHECK_LIB(lapack, clapack_dgesv,
+-AC_MSG_RESULT([using atlas in lib-atlas/lib])
+-AC_DEFINE(HAVE_ATLAS)
+-have_atlas=yes
+-LAPACK_LIB_DIR='${top_srcdir}/lib-atlas/lib'
+-LAPACK_INCLUDE_DIR='${top_srcdir}/lib-atlas/include'
+-,
+-AC_MSG_RESULT([using unoptimized lapack in lib])
++BUNDLED_LAPACK_LIB_DIR='${top_srcdir}/lib'
++AC_SUBST(BUNDLED_LAPACK_LIB_DIR)
++
+ have_atlas=no
+-LAPACK_LIB_DIR='${top_srcdir}/lib'
+-LAPACK_INCLUDE_DIR='${top_srcdir}/lib'
+-,
+-[-lcblas -latlas])
+-LIBS=$fw_save_LIBS
+-AC_SUBST(LAPACK_LIB_DIR)
+-AC_SUBST(LAPACK_INCLUDE_DIR)
++AC_ARG_WITH(lapack-libs, [ --with-lapack-libs=LIBS ])
++if test "x$with_lapack_libs" = "x" ; then
++ LAPACK_LIBS='-L${top_srcdir}/lib -latlas -lcblas -llapack'
++else
++ LAPACK_LIBS="$with_lapack_libs"
++ have_atlas=yes
++fi
++AC_SUBST(LAPACK_LIBS)
+ AM_CONDITIONAL(HAVE_ATLAS, test x${have_atlas} = xyes)
+
+-AM_PATH_GIMP(1.2.0)
++AC_ARG_WITH(lapack-includes, [ --with-lapack-includes=INCLUDES ])
++if test "x$with_lapack_includes" = "x" ; then
++ LAPACK_INCLUDES='-I ${top_srcdir}/lib'
++else
++ LAPACK_INCLUDES="$with_lapack_includes"
++fi
++AC_SUBST(LAPACK_INCLUDES)
++
++AM_PATH_GIMP_2_0(2.0.0)
+ AM_PATH_GTK_2_0(2.0.0)
+ AM_PATH_GLIB_2_0(2.0.0)
+
+@@ -96,15 +97,9 @@
+ AC_DEFINE(PREVIEW_DEBUG)
+ fi
+
+-# If we have gcc set the CFLAGS
+-# This is done here because otherwise configure would use
+-# these flags for compiling test-programs.
+-if test "$GCC" = yes; then
+- CFLAGS="-Wall -ansi -pedantic -ggdb -fomit-frame-pointer -O3 -funroll-all-loops"
+-fi
+-
+ #Check if erf is defined in the mathlibrary
+ AC_CHECK_LIB(m, erf, AC_DEFINE(HAVE_ERF))
+
+-AC_OUTPUT([Makefile src/Makefile lib/Makefile doc/Makefile gtk-doc/Makefile ])
++AC_CONFIG_FILES([Makefile src/Makefile lib/Makefile doc/Makefile gtk-doc/Makefile ])
++AC_OUTPUT
+
diff --git a/graphics/gimp-refocus-plugin/files/patch-lib__Makefile.am b/graphics/gimp-refocus-plugin/files/patch-lib__Makefile.am
new file mode 100644
index 000000000000..02b07f4434b5
--- /dev/null
+++ b/graphics/gimp-refocus-plugin/files/patch-lib__Makefile.am
@@ -0,0 +1,7 @@
+--- lib/Makefile.am.orig 2003-01-30 19:29:52.000000000 -0200
++++ lib/Makefile.am 2014-04-01 22:13:34.000000000 -0300
+@@ -1,4 +1,3 @@
+-CFLAGS=-fomit-frame-pointer -O3 -funroll-all-loops
+
+
+ noinst_LIBRARIES = liblapack.a libatlas.a libcblas.a
diff --git a/graphics/gimp-refocus-plugin/files/patch-src__Makefile.am b/graphics/gimp-refocus-plugin/files/patch-src__Makefile.am
new file mode 100644
index 000000000000..a69d09eeebe9
--- /dev/null
+++ b/graphics/gimp-refocus-plugin/files/patch-src__Makefile.am
@@ -0,0 +1,47 @@
+--- src/Makefile.am.orig 2003-01-30 19:30:18.000000000 -0200
++++ src/Makefile.am 2014-04-01 22:12:45.000000000 -0300
+@@ -1,22 +1,28 @@
+ ## Process this file with automake to produce Makefile.in
+
+-INCLUDES=@GTK_CFLAGS@ @GIMP_CFLAGS@ -I @LAPACK_INCLUDE_DIR@
++INCLUDES=@GTK_CFLAGS@ @GIMP_CFLAGS@ @LAPACK_INCLUDES@
+
+ bin_PROGRAMS = refocus
+ noinst_PROGRAMS = test-matrix
+
+-ldadd_atlas=-L@LAPACK_LIB_DIR@ -llapack -lcblas -latlas
++ldadd_atlas=@LAPACK_LIBS@
+
+ 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 = @GTK_LIBS@ -lgimp ${ldadd_atlas}
+-refocus_DEPENDENCIES=@LAPACK_LIB_DIR@/liblapack.a
++refocus_LDADD = -lm ${ldadd_atlas} @GIMP_LIBS@
++if HAVE_ATLAS
++else
++refocus_DEPENDENCIES=@BUNDLED_LAPACK_LIB_DIR@/liblapack.a
++endif
+
+ test_matrix_SOURCES = matrix.c test-matrix.c fwlapack.c
+ test_matrix_LDADD = -lm ${ldadd_atlas} @GLIB_LIBS@
+-test_matrix_DEPENDENCIES=@LAPACK_LIB_DIR@/liblapack.a
++if HAVE_ATLAS
++else
++test_matrix_DEPENDENCIES=@BUNDLED_LAPACK_LIB_DIR@/liblapack.a
++endif
+
+ install-bin: refocus
+ @if test "x@GIMPTOOL@" = "x" ; then \
+@@ -36,8 +42,8 @@
+ @GIMPTOOL@ --install-admin-bin refocus ; \
+ fi
+
+-@LAPACK_LIB_DIR@/liblapack.a:
+- cd @LAPACK_LIB_DIR@; make
++@BUNDLED_LAPACK_LIB_DIR@/liblapack.a:
++ cd @BUNDLED_LAPACK_LIB_DIR@; gmake
+
+ %.s: %.c
+ ${CC} ${CFLAGS} -S $< -o $@
diff --git a/graphics/gimp-refocus-plugin/files/patch-src__conv.c b/graphics/gimp-refocus-plugin/files/patch-src__conv.c
new file mode 100644
index 000000000000..70742b2adaac
--- /dev/null
+++ b/graphics/gimp-refocus-plugin/files/patch-src__conv.c
@@ -0,0 +1,34 @@
+--- src/conv.c 2014-03-27 20:00:17.000000000 -0300
++++ src/conv.c 2014-03-27 20:00:58.000000000 -0300
+@@ -421,13 +421,19 @@
+ gint x, buf_start_y, total_tiles, tile_nr = 0;
+ /* Will be false when progress_update tells us that the data is no longer needed */
+ gboolean ok = TRUE;
+-
++ /*
++ tile_height() [util.c]
++ tile_width() [util.c]
++ */
+ initialize_buf (&buf, source, mat_size / 2, sx, sy, width, height,
+ boundary_type);
+ total_tiles = (1 + floor ((buf.x + buf.width - 1) / tile_width ())
+ - floor ((buf.x) / tile_width ())) *
+ (1 + floor ((buf.y_limit - 1) / tile_height ())
+ - floor ((buf.y) / tile_height ()));
++#ifdef RLXTEST
++ printf("convolve_image: total_tiles %d\n",total_tiles);
++#endif
+
+ buf_start_y = buf.y;
+ while (ok && shift_buf (&buf, source))
+@@ -437,6 +443,10 @@
+ {
+ const gint ncolors = source->bpp - source->has_alpha;
+ GimpTile *tile = tile_sink_get_tile (sink, x, buf.y);
++#ifdef RLXTEST
++ printf("convolve_image: x %d, y %d, tile->eheight %d\n",
++ x, buf.y, tile->eheight);
++#endif
+ convolve_tile (tile, pixpos_in_buf (&buf, x, buf.y), buf.row_stride,
+ ncolors, sink->bpp, mat->data, mat_size);
+ tile_sink_tile_unref (sink, tile);
diff --git a/graphics/gimp-refocus-plugin/files/patch-src__gimppreview.c b/graphics/gimp-refocus-plugin/files/patch-src__gimppreview.c
new file mode 100644
index 000000000000..9c076e4a9161
--- /dev/null
+++ b/graphics/gimp-refocus-plugin/files/patch-src__gimppreview.c
@@ -0,0 +1,384 @@
+--- src/gimppreview.c 2014-03-27 20:00:17.000000000 -0300
++++ src/gimppreview.c 2014-03-27 20:00:38.000000000 -0300
+@@ -36,18 +36,18 @@
+ #include "gimppreview.h"
+
+
+-static void gimp_preview_init (GimpPreview * preview);
+-static void gimp_preview_class_init (GimpPreviewClass * klass);
++static void gimp_preview_init (myGimpPreview * preview);
++static void gimp_preview_class_init (myGimpPreviewClass * klass);
+
+ static void gimp_preview_plus_callback (GtkWidget * widget, gpointer data);
+ static void gimp_preview_minus_callback (GtkWidget * widget, gpointer data);
+ static gint gimp_preview_event (GtkWidget * widget, GdkEvent * event,
+ gpointer data);
+-static void gimp_preview_recompute_sizes (GimpPreview * preview,
++static void gimp_preview_recompute_sizes (myGimpPreview * preview,
+ gdouble newscale);
+-static void gimp_preview_update_preview (GimpPreview * preview);
++static void gimp_preview_update_preview (myGimpPreview * preview);
+
+-static void gimp_preview_image_set_size (GimpPreview * preview, gint width,
++static void gimp_preview_image_set_size (myGimpPreview * preview, gint width,
+ gint height);
+ static void gimp_preview_size_request (GtkWidget * widget,
+ GtkRequisition * requisition);
+@@ -58,7 +58,7 @@
+ GtkCallback callback,
+ gpointer callback_data);
+ gboolean gimp_preview_update_preview_idle_fun (gpointer data);
+-void gimp_preview_schedule_update (GimpPreview * preview);
++void gimp_preview_schedule_update (myGimpPreview * preview);
+
+ #define PROGRESS_BAR_HEIGHT (10)
+ #define PREVIEW_SIZE (100)
+@@ -94,11 +94,11 @@
+
+
+ /*
+- * Apps which use a GimpPreview widget should not be accessing the private
++ * Apps which use a myGimpPreview widget should not be accessing the private
+ * data!
+ */
+ #define PREVIEW_DATA(preview) \
+- ((GimpPreviewData*)(GIMP_PREVIEW (preview)->private_data))
++ ((myGimpPreviewData*)(MY_GIMP_PREVIEW (preview)->private_data))
+
+ typedef struct
+ {
+@@ -126,7 +126,7 @@
+ GtkWidget *image;
+ GtkWidget *progress_bar;
+ }
+-GimpPreviewData;
++myGimpPreviewData;
+
+
+ /* Convert coordinate in preview space to image coordinates */
+@@ -155,20 +155,20 @@
+ if (!preview_type)
+ {
+ GTypeInfo preview_info = {
+- sizeof (GimpPreviewClass),
++ sizeof (myGimpPreviewClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) gimp_preview_class_init,
+ (GClassFinalizeFunc) NULL,
+ (gconstpointer) NULL, /* class_data */
+- sizeof (GimpPreview),
++ sizeof (myGimpPreview),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gimp_preview_init,
+ (GTypeValueTable *) NULL /* value_table */
+ };
+
+ preview_type =
+- g_type_register_static (GTK_TYPE_CONTAINER, "GimpPreview",
++ g_type_register_static (GTK_TYPE_CONTAINER, "myGimpPreview",
+ &preview_info, 0);
+ }
+
+@@ -181,7 +181,7 @@
+ * by GTK's internal mechanisms.
+ */
+ static void
+-gimp_preview_class_init (GimpPreviewClass * klass)
++gimp_preview_class_init (myGimpPreviewClass * klass)
+ {
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
+@@ -190,7 +190,7 @@
+ g_signal_new ("update_preview",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+- G_STRUCT_OFFSET (GimpPreviewClass, update_preview),
++ G_STRUCT_OFFSET (myGimpPreviewClass, update_preview),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__POINTER,
+@@ -200,7 +200,7 @@
+ g_signal_new ("preview_changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+- G_STRUCT_OFFSET (GimpPreviewClass, preview_changed),
++ G_STRUCT_OFFSET (myGimpPreviewClass, preview_changed),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
+ klass->update_preview = NULL;
+@@ -212,7 +212,7 @@
+
+
+ void
+-gimp_preview_set_scale_amount(GimpPreview *preview, gdouble scale_amount)
++gimp_preview_set_scale_amount(myGimpPreview *preview, gdouble scale_amount)
+ {
+ /*
+ * If the caller wants to set the scale amount, let them do so.
+@@ -269,7 +269,7 @@
+ * by GTK's internal mechanisms.
+ */
+ static void
+-gimp_preview_init (GimpPreview * preview)
++gimp_preview_init (myGimpPreview * preview)
+ {
+ gchar buffer[10];
+
+@@ -277,7 +277,7 @@
+ GTK_WIDGET_SET_FLAGS (preview, GTK_NO_WINDOW);
+ GTK_CONTAINER (preview)->resize_mode = GTK_RESIZE_IMMEDIATE;
+
+- preview->private_data = g_malloc0 (sizeof (GimpPreviewData));
++ preview->private_data = g_malloc0 (sizeof (myGimpPreviewData));
+
+
+ PREVIEW_DATA (preview)->label = gtk_label_new ("");
+@@ -307,7 +307,7 @@
+ gimp_preview_new_with_args (GimpDrawable * drawable, gint cb_preview_size,
+ gdouble cb_scale_amount, gint cb_allow_scale)
+ {
+- GimpPreview *preview;
++ myGimpPreview *preview;
+ GtkWidget *frame;
+ GtkWidget *hbox;
+ GtkWidget *event_box;
+@@ -337,14 +337,14 @@
+
+
+ /* Now allocate the actual preview window. */
+- preview = GIMP_PREVIEW (g_object_new (gimp_preview_get_type (), NULL));
++ preview = MY_GIMP_PREVIEW (g_object_new (gimp_preview_get_type (), NULL));
+
+ /* Set the scale amount. */
+ gimp_preview_set_scale_amount(preview, cb_scale_amount);
+
+ /* Save the drawable info. */
+ preview->drawable = drawable;
+- preview->drawable_has_alpha = gimp_drawable_has_alpha (drawable->id);
++ preview->drawable_has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
+
+ /* Calculate our preview size. */
+ if (preview_size == PREVIEW_FIXED_SIZE)
+@@ -352,8 +352,8 @@
+ preview_width = i2p (drawable->width, preview->scale);
+ preview_height = i2p (drawable->height, preview->scale);
+
+- GIMP_PREVIEW (preview)->width = preview_width;
+- GIMP_PREVIEW (preview)->height = preview_height;
++ MY_GIMP_PREVIEW (preview)->width = preview_width;
++ MY_GIMP_PREVIEW (preview)->height = preview_height;
+ }
+ else
+ {
+@@ -454,7 +454,7 @@
+ static void
+ gimp_preview_size_request (GtkWidget * widget, GtkRequisition * requisition)
+ {
+- GimpPreview *preview = GIMP_PREVIEW (widget);
++ myGimpPreview *preview = MY_GIMP_PREVIEW (widget);
+ GtkRequisition resize_box_requisition;
+
+ #ifdef PREVIEW_DEBUG
+@@ -478,7 +478,7 @@
+ static void
+ gimp_preview_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
+ {
+- GimpPreview *preview = GIMP_PREVIEW (widget);
++ myGimpPreview *preview = MY_GIMP_PREVIEW (widget);
+ GtkAllocation resize_box_allocation, progress_bar_allocation,
+ event_box_allocation;
+ GtkRequisition resize_box_requisition;
+@@ -543,7 +543,7 @@
+ gboolean include_internals,
+ GtkCallback callback, gpointer callback_data)
+ {
+- GimpPreview *preview = GIMP_PREVIEW (container);
++ myGimpPreview *preview = MY_GIMP_PREVIEW (container);
+
+ if (PREVIEW_DATA (preview)->resize_box)
+ {
+@@ -564,7 +564,7 @@
+ * Plug-ins call this to do an update of the preview area.
+ */
+ void
+-gimp_preview_update (GimpPreview * preview)
++gimp_preview_update (myGimpPreview * preview)
+ {
+ gimp_preview_recompute_sizes (preview, preview->scale);
+ gimp_preview_update_preview (preview);
+@@ -579,11 +579,11 @@
+ static void
+ gimp_preview_plus_callback (GtkWidget * widget, gpointer data)
+ {
+- GimpPreview *preview;
++ myGimpPreview *preview;
+ gchar buffer[10];
+ gdouble new_scale;
+
+- preview = GIMP_PREVIEW (data);
++ preview = MY_GIMP_PREVIEW (data);
+ if (PREVIEW_DATA (preview)->scale_n == PREVIEW_SCALE_LAST)
+ return;
+
+@@ -616,11 +616,11 @@
+ static void
+ gimp_preview_minus_callback (GtkWidget * widget, gpointer data)
+ {
+- GimpPreview *preview;
++ myGimpPreview *preview;
+ gchar buffer[10];
+ gdouble new_scale;
+
+- preview = GIMP_PREVIEW (data);
++ preview = MY_GIMP_PREVIEW (data);
+ if (PREVIEW_DATA (preview)->scale_n == 0)
+ return;
+
+@@ -651,12 +651,12 @@
+ static gint
+ gimp_preview_event (GtkWidget * widget, GdkEvent * event, gpointer data)
+ {
+- GimpPreview *preview;
++ myGimpPreview *preview;
+ GdkEventButton *button_event;
+ gint x, y;
+ gint dx, dy;
+
+- preview = GIMP_PREVIEW (data);
++ preview = MY_GIMP_PREVIEW (data);
+ button_event = (GdkEventButton *) event;
+
+ switch (event->type)
+@@ -733,7 +733,7 @@
+ * This function is also used for initializing the preview.
+ */
+ static void
+-gimp_preview_recompute_sizes (GimpPreview * preview, gdouble new_scale)
++gimp_preview_recompute_sizes (myGimpPreview * preview, gdouble new_scale)
+ {
+
+ /* The center of the preview in image coordinates.
+@@ -765,7 +765,7 @@
+ }
+
+ void
+-gimp_preview_generate_update_event (GimpPreview * preview)
++gimp_preview_generate_update_event (myGimpPreview * preview)
+ /* Signal the user that the preview must be updated */
+ {
+ const gdouble scale = preview->scale;
+@@ -783,7 +783,7 @@
+ 0,
+ preview->drawable->height - image_y);
+
+- GimpPreviewEvent preview_event;
++ myGimpPreviewEvent preview_event;
+
+ preview_event.event_id = PREVIEW_DATA (preview)->current_event_id;
+ preview_event.scale = preview->scale;
+@@ -814,7 +814,7 @@
+ * to step through source and destination!
+ */
+ static void
+-gimp_preview_update_preview (GimpPreview * preview)
++gimp_preview_update_preview (myGimpPreview * preview)
+ {
+ GimpPixelRgn region;
+ guchar *image_data = NULL;
+@@ -1012,7 +1012,7 @@
+
+
+ void
+-gimp_preview_force_redraw (GimpPreview * preview)
++gimp_preview_force_redraw (myGimpPreview * preview)
+ {
+ gtk_widget_queue_draw (GTK_WIDGET (PREVIEW_DATA (preview)->image));
+ }
+@@ -1022,7 +1022,7 @@
+ gboolean
+ gimp_preview_update_preview_idle_fun (gpointer data)
+ {
+- GimpPreview *preview = GIMP_PREVIEW (data);
++ myGimpPreview *preview = MY_GIMP_PREVIEW (data);
+ gint event_id = PREVIEW_DATA (preview)->current_event_id;
+
+ #ifdef PREVIEW_DEBUG
+@@ -1041,7 +1041,7 @@
+ }
+
+ void
+-gimp_preview_schedule_update (GimpPreview * preview)
++gimp_preview_schedule_update (myGimpPreview * preview)
+ {
+ PREVIEW_DATA (preview)->current_event_id++;
+
+@@ -1082,7 +1082,7 @@
+ }
+
+ void
+-gimp_preview_image_set_size (GimpPreview * preview, gint width, gint height)
++gimp_preview_image_set_size (myGimpPreview * preview, gint width, gint height)
+ {
+ const gint real_width = MIN (preview->max_width, width);
+ const gint real_height = MIN (preview->max_height, height);
+@@ -1120,8 +1120,8 @@
+
+ /**
+ * gimp_preview_draw_row:
+- * @preview: the #GimpPreview
+- * @event_id: event_id that was sent with the #GimpPreviewEvent.
++ * @preview: the #myGimpPreview
++ * @event_id: event_id that was sent with the #myGimpPreviewEvent.
+ * @type: the format of the data (e.g. %GIMP_RGBA_IMAGE).
+ * @row:the relative number of the row within the preview.
+ * The top row of the preview is number 0.
+@@ -1137,7 +1137,7 @@
+ * with the same event-id will be ignored by the preview.
+ **/
+ gboolean
+-gimp_preview_draw_row (GimpPreview * preview, const gint event_id,
++gimp_preview_draw_row (myGimpPreview * preview, const gint event_id,
+ GimpImageType type, gint row,
+ const guchar * const data)
+ {
+@@ -1247,8 +1247,8 @@
+
+ /**
+ * gimp_preview_draw_unscaled_row:
+- * @preview: the #GimpPreview
+- * @event_id: event_id that was sent with the #GimpPreviewEvent.
++ * @preview: the #myGimpPreview
++ * @event_id: event_id that was sent with the #myGimpPreviewEvent.
+ * @type: the format of the data (e.g. %GIMP_RGBA_IMAGE).
+ * @row:row is the relative position of the row w.r.t. preview_event->image_y.
+ * The top row has number 0.
+@@ -1267,7 +1267,7 @@
+ * with the same event-id will be ignored by the preview.
+ **/
+ gboolean
+-gimp_preview_draw_unscaled_row (GimpPreview * preview, const gint event_id,
++gimp_preview_draw_unscaled_row (myGimpPreview * preview, const gint event_id,
+ GimpImageType type, const gint row,
+ const guchar * const data)
+ {
+@@ -1445,8 +1445,8 @@
+
+ /**
+ * gimp_preview_progress_set_fraction:
+- * @preview: the #GimpPreview.
+- * @event_id: event_id that was sent with the #GimpPreviewEvent.
++ * @preview: the #myGimpPreview.
++ * @event_id: event_id that was sent with the #myGimpPreviewEvent.
+ * @fraction: the fraction completed.
+ *
+ * Set the progress bar of the preview to @fraction completed.
+@@ -1456,7 +1456,7 @@
+ * with the same event-id will be ignored by the preview.
+ **/
+ gboolean
+-gimp_preview_progress_set_fraction (GimpPreview * preview,
++gimp_preview_progress_set_fraction (myGimpPreview * preview,
+ const gint event_id, double fraction)
+ {
+ const gboolean return_status =
diff --git a/graphics/gimp-refocus-plugin/files/patch-src__gimppreview.h b/graphics/gimp-refocus-plugin/files/patch-src__gimppreview.h
new file mode 100644
index 000000000000..61623c921bc8
--- /dev/null
+++ b/graphics/gimp-refocus-plugin/files/patch-src__gimppreview.h
@@ -0,0 +1,82 @@
+--- src/gimppreview.h 2014-03-27 20:00:17.000000000 -0300
++++ src/gimppreview.h 2014-03-27 20:00:38.000000000 -0300
+@@ -32,25 +32,25 @@
+
+ #define PREVIEW_FIXED_SIZE 0
+ #define PREVIEW_DEFAULT_SIZE -1
+-#define GIMP_TYPE_PREVIEW (gimp_preview_get_type ())
+-#define GIMP_PREVIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_PREVIEW, GimpPreview))
+-#define GIMP_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PREVIEW, GimpPreviewClass))
+-#define GIMP_IS_PREVIEW(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_PREVIEW))
+-#define GIMP_IS_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PREVIEW))
+-typedef struct _GimpPreview GimpPreview;
+-typedef struct _GimpPreviewClass GimpPreviewClass;
+-typedef struct _GimpPreviewEvent GimpPreviewEvent;
++//#define GIMP_TYPE_PREVIEW (gimp_preview_get_type ())
++#define MY_GIMP_PREVIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_PREVIEW, myGimpPreview))
++#define MY_GIMP_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PREVIEW, myGimpPreviewClass))
++//#define GIMP_IS_PREVIEW(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_PREVIEW))
++//#define GIMP_IS_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PREVIEW))
++typedef struct _myGimpPreview myGimpPreview;
++typedef struct _myGimpPreviewClass myGimpPreviewClass;
++typedef struct _myGimpPreviewEvent myGimpPreviewEvent;
+
+-struct _GimpPreviewClass
++struct _myGimpPreviewClass
+ {
+ GtkContainerClass parent_class;
+
+- void (*update_preview) (GimpPreview * preview, GimpPreviewEvent * event);
+- void (*preview_changed) (GimpPreview * preview);
++ void (*update_preview) (myGimpPreview * preview, myGimpPreviewEvent * event);
++ void (*preview_changed) (myGimpPreview * preview);
+ };
+
+
+-struct _GimpPreview
++struct _myGimpPreview
+ {
+ GtkContainer parent;
+
+@@ -75,13 +75,13 @@
+ };
+
+ /**
+- * GimpPreviewEvent:
++ * myGimpPreviewEvent:
+ * @event_id: Id of this event. This is needed for gimp_preview_draw_row,
+ * gimp_preview_draw_unscaled_row and gimp_preview_progress_set_fraction.
+ * @scale: Current scale of the preview.
+ *
+ **/
+-struct _GimpPreviewEvent
++struct _myGimpPreviewEvent
+ {
+ gint event_id; /* Id of this event */
+ gdouble scale; /* Scale of preview */
+@@ -113,20 +113,20 @@
+ gint preview_size,
+ gdouble scale_amount,
+ gint allow_scale);
+-void gimp_preview_update (GimpPreview * preview);
++void gimp_preview_update (myGimpPreview * preview);
+
+-gboolean gimp_preview_draw_row (GimpPreview * preview, const gint event_id,
++gboolean gimp_preview_draw_row (myGimpPreview * preview, const gint event_id,
+ GimpImageType type, const gint row,
+ const guchar * const data);
+
+-gboolean gimp_preview_draw_unscaled_row (GimpPreview * preview,
++gboolean gimp_preview_draw_unscaled_row (myGimpPreview * preview,
+ const gint event_id,
+ GimpImageType type, const gint row,
+ const guchar * const data);
+
+-void gimp_preview_force_redraw (GimpPreview * preview);
++void gimp_preview_force_redraw (myGimpPreview * preview);
+
+-gboolean gimp_preview_progress_set_fraction (GimpPreview * preview,
++gboolean gimp_preview_progress_set_fraction (myGimpPreview * preview,
+ const gint event_id,
+ double fraction);
+
diff --git a/graphics/gimp-refocus-plugin/files/patch-src__prevman.c b/graphics/gimp-refocus-plugin/files/patch-src__prevman.c
new file mode 100644
index 000000000000..394dda32c0d8
--- /dev/null
+++ b/graphics/gimp-refocus-plugin/files/patch-src__prevman.c
@@ -0,0 +1,29 @@
+--- src/prevman.c 2014-03-27 20:00:17.000000000 -0300
++++ src/prevman.c 2014-03-27 20:00:23.000000000 -0300
+@@ -52,7 +52,7 @@
+ tile_source->width = drawable->width;
+ tile_source->height = drawable->height;
+ tile_source->bpp = drawable->bpp;
+- tile_source->has_alpha = gimp_drawable_has_alpha (drawable->id);
++ tile_source->has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
+ tile_source->un.drw.drawable = drawable;
+ gimp_pixel_rgn_init (&tile_source->un.drw.pixel_rgn, drawable, x, y, width,
+ height, FALSE, FALSE);
+@@ -144,7 +144,7 @@
+ tile_sink->width = drawable->width;
+ tile_sink->height = drawable->height;
+ tile_sink->bpp = drawable->bpp;
+- tile_sink->has_alpha = gimp_drawable_has_alpha (drawable->id);
++ tile_sink->has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
+ gimp_pixel_rgn_init (&tile_sink->un.drw.pixel_rgn, drawable, x, y, width,
+ height, TRUE, TRUE);
+ }
+@@ -159,7 +159,7 @@
+ tile_sink->width = width;
+ tile_sink->height = height;
+ tile_sink->bpp = drawable->bpp;
+- tile_sink->has_alpha = gimp_drawable_has_alpha (drawable->id);
++ tile_sink->has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
+ tile_sink->un.prv.data = g_new (guchar,
+ tile_sink->width * tile_sink->height *
+ tile_sink->bpp);
diff --git a/graphics/gimp-refocus-plugin/files/patch-src__refocus.c b/graphics/gimp-refocus-plugin/files/patch-src__refocus.c
new file mode 100644
index 000000000000..b7810df041ca
--- /dev/null
+++ b/graphics/gimp-refocus-plugin/files/patch-src__refocus.c
@@ -0,0 +1,124 @@
+--- src/refocus.c 2014-03-27 20:00:17.000000000 -0300
++++ src/refocus.c 2014-03-27 20:00:38.000000000 -0300
+@@ -45,9 +45,9 @@
+
+ /* Declare local functions. */
+ static void query (void);
+-static void run (char *name,
++static void run (const gchar *name,
+ gint nparams,
+- GimpParam * param,
++ const GimpParam * param,
+ gint * nreturn_vals, GimpParam ** return_vals);
+ static gint dialog ();
+ static void doit (void);
+@@ -111,7 +111,6 @@
+ {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",
+@@ -123,15 +122,15 @@
+ "<Image>/Filters/Enhance/Refocus ...",
+ "RGB*, GRAY*",
+ GIMP_PLUGIN,
+- nargs, nreturn_vals, args, return_vals);
++ G_N_ELEMENTS(args), nreturn_vals, args, return_vals);
+ }
+
+ static void
+-run (char *name, gint n_params, GimpParam * param,
++run (const gchar *name, gint n_params, const GimpParam * param,
+ gint * nreturn_vals, GimpParam ** return_vals)
+ {
+ static GimpParam values[1];
+- GimpRunModeType run_mode;
++ GimpRunMode run_mode;
+ GimpPDBStatusType status = GIMP_PDB_SUCCESS;
+
+ (void) name; /* Shut up warnings about unused parameters. */
+@@ -186,8 +185,8 @@
+ {
+
+ /* Make sure that the drawable is gray or RGB color */
+- if (gimp_drawable_is_rgb (drawable->id) ||
+- gimp_drawable_is_gray (drawable->id))
++ if (gimp_drawable_is_rgb (drawable->drawable_id) ||
++ gimp_drawable_is_gray (drawable->drawable_id))
+ {
+ doit ();
+
+@@ -336,7 +335,7 @@
+ (void) data;
+ set_busy_cursor (widget, TRUE);
+ update_matrix ();
+- gimp_preview_update (GIMP_PREVIEW (my_widgets.preview));
++ gimp_preview_update (MY_GIMP_PREVIEW (my_widgets.preview));
+ set_busy_cursor (widget, FALSE);
+ }
+
+@@ -369,11 +368,11 @@
+ {
+ gint event_id = GPOINTER_TO_INT (data);
+ return (gimp_preview_progress_set_fraction
+- (GIMP_PREVIEW (my_widgets.preview), event_id, arg));
++ (MY_GIMP_PREVIEW (my_widgets.preview), event_id, arg));
+ }
+
+ static void
+-preview_callback (GtkWidget * widget, GimpPreviewEvent * event, gpointer data)
++preview_callback (GtkWidget * widget, myGimpPreviewEvent * event, gpointer data)
+ {
+ TileSource source;
+ TileSink sink;
+@@ -393,7 +392,7 @@
+ 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),
++ gimp_preview_progress_set_fraction (MY_GIMP_PREVIEW (my_widgets.preview),
+ event->event_id, 0);
+ bd_closure_init (&update_progress_closure,
+ preview_progress_update_fun,
+@@ -409,9 +408,9 @@
+ {
+ 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),
++ gimp_preview_draw_unscaled_row (MY_GIMP_PREVIEW (my_widgets.preview),
+ event->event_id,
+- gimp_drawable_type (drawable->id),
++ gimp_drawable_type (drawable->drawable_id),
+ row, buf);
+ };
+ g_free (buf);
+@@ -583,7 +582,7 @@
+
+ gtk_widget_show (dlg);
+ redraw_all ();
+- gimp_preview_update (GIMP_PREVIEW (preview));
++ gimp_preview_update (MY_GIMP_PREVIEW (preview));
+ gtk_main ();
+ gdk_flush ();
+ return run_flag;
+@@ -608,7 +607,7 @@
+ gimp_progress_init ("Computing matrix");
+ update_matrix ();
+ gimp_progress_init ("Applying convolution");
+- gimp_drawable_mask_bounds (drawable->id, &sx1, &sy1, &sx2, &sy2);
++ 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);
+@@ -618,7 +617,7 @@
+ matrix, 2 * my_config.mat_width + 1,
+ &update_progress_closure);
+ gimp_drawable_flush (drawable);
+- gimp_drawable_merge_shadow (drawable->id, TRUE);
+- gimp_drawable_update (drawable->id, sx1, sy1, width, height);
++ gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
++ gimp_drawable_update (drawable->drawable_id, sx1, sy1, width, height);
+ g_free (matrix);
+ }
diff --git a/graphics/gimp-refocus-plugin/files/patch-src__tilebuf.c b/graphics/gimp-refocus-plugin/files/patch-src__tilebuf.c
new file mode 100644
index 000000000000..1b308c2aec59
--- /dev/null
+++ b/graphics/gimp-refocus-plugin/files/patch-src__tilebuf.c
@@ -0,0 +1,189 @@
+--- src/tilebuf.c 2014-03-27 20:00:17.000000000 -0300
++++ src/tilebuf.c 2014-03-27 20:00:58.000000000 -0300
+@@ -18,6 +18,7 @@
+ * Version $Id: tilebuf.c,v 1.1.1.1 2003/01/30 21:30:19 ernstl Exp $
+ */
+
++#include <stdio.h>
+ #include "tilebuf.h"
+ #include "util.h"
+ #include <string.h>
+@@ -39,6 +40,11 @@
+ guchar *
+ pixpos_in_buf (TileStripBuffer * buf, const gint x, const gint y)
+ {
++ /*
++ & data = array(? lines x row_stride columns)
++ & pixpos_in_buf = &data[(x - real_x)*bytes_per_pixel, y - real_y]
++ & (real_x, real_y) = origin of tile.
++ */
+ return (&buf->data[buf->row_stride * (y - buf->real_y) +
+ buf->bpp * (x - buf->real_x)]);
+ }
+@@ -140,7 +146,10 @@
+
+ for (x = x_lo - 1; x >= buf->real_x; x--)
+ {
+- copy_col (buf, 2 * x_lo - x, y_start, y_end - y_start, x);
++ gint sx = 2 * x_lo - x;
++ copy_col (buf,
++ sx<=buf->real_x+buf->real_width-1?sx:buf->real_x+buf->real_width-1,
++ y_start, y_end - y_start, x);
+ };
+ }
+ break;
+@@ -171,7 +180,9 @@
+
+ for (x = x_hi; x < buf->real_x + buf->real_width; x++)
+ {
+- copy_col (buf, 2 * (x_hi - 1) - x, y_start, y_end - y_start, x);
++ gint sx = 2 * (x_hi - 1) - x;
++ copy_col (buf, sx>=buf->real_x?sx:buf->real_x,
++ y_start, y_end - y_start, x);
+ };
+ }
+ break;
+@@ -200,7 +211,10 @@
+
+ for (y = y_lo - 1; y >= buf->real_y; y--)
+ {
+- copy_row (buf, buf->real_x, 2 * y_lo - y, buf->real_width, y);
++ gint sy = 2 * y_lo - y;
++ copy_row (buf, buf->real_x,
++ sy<=buf->real_y+buf->real_height-1?sy:buf->real_y+buf->real_height-1,
++ buf->real_width, y);
+ };
+ }
+ break;
+@@ -212,7 +226,7 @@
+ static void
+ fix_bottom_boundary (TileStripBuffer * buf, const gint y_hi)
+ {
+- if (y_hi >= buf->real_y + buf->real_height)
++ if (y_hi >= buf->real_y + buf->real_height) /* (1) */
+ {
+ return;
+ };
+@@ -226,12 +240,32 @@
+ break;
+ case TB_BOUNDARY_MIRROR:
+ {
+- register gint y;
++ register gint y2;
+
+- for (y = y_hi; y < buf->real_y + buf->real_height; y++)
++ /*if (y_hi < buf->y_limit)*/
++ for (y2 = y_hi; y2 < buf->real_y + buf->real_height; y2++) /*(2)*/
+ {
+- copy_row (buf, buf->real_x, 2 * (y_hi - 1) - y, buf->real_width,
+- y);
++ /*
++ &1 y < y_hi [domain of y, definition of y_hi, (1)]
++ &2 y_hi <= y2 < buf->real_y + buf->real_height [(1),(2)]
++ &3 i = 0, 1, ...
++ &4 y=y_hi-i-1 -> y2=y_hi+i [definition of mirror]
++ &5 y = y2 - 2*i - 1 [4]
++ &6 y = 2*y2 - 2*i - y2 - 1 [5,algebra]
++ &7 y = 2*y_hi - y2 - 1 [4,6]
++ */
++ gint y = 2*y_hi - y2 - 1;
++ if (y < buf->real_y) break;
++#ifdef RLXTEST
++ printf("fix_bottom_boundary: Copying row %d to %d, width %d, buf_loc %d %d, real_y %d\n",
++ 2*y_hi - y2 - 1, y2, buf->real_width,
++ buf->row_stride * (2*y_hi - y2 - 1 - buf->real_y) +
++ buf->bpp * (buf->real_x - buf->real_x),
++ buf->row_stride * (y2 - buf->real_y) +
++ buf->bpp * (buf->real_x - buf->real_x),
++ buf->real_y);
++#endif
++ copy_row (buf, buf->real_x, y, buf->real_width,y2);
+ };
+ }
+ break;
+@@ -253,7 +287,21 @@
+ const gint y_lo = MAX (buf->real_y, source->y);
+ const gint y_hi = MIN (buf->real_y + buf->real_height,
+ source->y + source->height);
+-
++ /*
++ y: domain of y.
++ & 0 <= y. y is a 0-index.
++ & | & y in the source image
++ & 0 <= source->y <= y < source->y + source->height
++ | & y in the buffer
++ & 0 <= buf->real_y <= y < buf->real_y + buf->real_height
++ x: domain of x = domain of y with mapping y -> x, height -> width.
++ */
++
++#ifdef RLXTEST
++ printf("buf->real_y %d, buf->real_height %d, source->y %d, source->heigh %d, y_hi %d\n",
++ buf->real_y, buf->real_height,
++ source->y, source->height, y_hi);
++#endif
+ fix_left_boundary (buf, x_lo, first_time ? buf->y : buf->y + tile_height (),
+ y_hi);
+ fix_right_boundary (buf, x_hi,
+@@ -262,7 +310,15 @@
+ {
+ fix_top_boundary (buf, y_lo);
+ };
++#ifdef RLXTEST
++ printf("fix_boundaries: Now goto fix_bottom_boundary: y_hi %d, real_y + real_height %d, data[%d]\n",
++ y_hi, buf->real_y + buf->real_height,
++ buf->real_height * buf->row_stride);
++#endif
+ fix_bottom_boundary (buf, y_hi);
++#ifdef RLXTEST
++ printf("bottom boundary fixed\n");
++#endif
+ }
+
+ void
+@@ -309,6 +365,14 @@
+ gint x;
+ gboolean not_finished = TRUE;
+
++ /*
++ & y_limit = height of picture, if full picture.
++ */
++#ifdef RLXTEST
++ printf("buf->y %d + tile_height%d () >= buf->y_limit %d\n",
++ buf->y,tile_height(),buf->y_limit);
++#endif
++
+ if (buf->first_time)
+ {
+ /* Buf must already have been initialized so there is nothing to do */
+@@ -321,19 +385,31 @@
+ }
+ else
+ {
++#ifdef RLXTEST
++ printf("shift_buf: tile_height %d\n", tile_height());
++#endif
+ memmove (pixpos_in_buf (buf, buf->real_x,
+ buf->real_y),
+ pixpos_in_buf (buf, buf->real_x,
+ buf->real_y + tile_height ()),
+ buf->row_stride * (tile_height () + buf->border_width));
+ buf->y += tile_height ();
++#ifdef RLXTEST
++ printf("shift_buf: y %d, y_limit %d\n", buf->y, buf->y_limit);
++#endif
+ buf->real_y = buf->y - buf->border_width;
+ for (x = buf->x - tile_width ();
+ x <= buf->x + buf->width; x += tile_width ())
+ {
+ copy_tile_to_buf (buf, source, x, buf->y + tile_height ());
++#ifdef RLXTEST
++ printf("shift_buf: x %d\n", x);
++#endif
+ };
+ fix_boundaries (buf, source, FALSE);
+ };
++#ifdef RLXTEST
++ printf("shift_buf: done\n");
++#endif
+ return (not_finished);
+ }
diff --git a/graphics/gimp-refocus-plugin/files/patch-src__util.c b/graphics/gimp-refocus-plugin/files/patch-src__util.c
new file mode 100644
index 000000000000..c1dd86d9d7c0
--- /dev/null
+++ b/graphics/gimp-refocus-plugin/files/patch-src__util.c
@@ -0,0 +1,49 @@
+--- src/util.c 2014-03-27 20:00:17.000000000 -0300
++++ src/util.c 2014-03-27 20:00:58.000000000 -0300
+@@ -18,6 +18,7 @@
+ * Version $Id: util.c,v 1.1.1.1 2003/01/30 21:30:19 ernstl Exp $
+ */
+
++#include <stdio.h>
+ #include "util.h"
+ #include <string.h>
+ #include <math.h>
+@@ -30,14 +31,38 @@
+ gint
+ floorm (gint a, gint b)
+ /* return largest multiple of b that is <= a */
++ /*
++ & & m = floorm(a,b)
++ & a = b*m + r
++ & 0 <= r < b
++ */
+ {
++#ifdef RLXTEST
++ printf("floorm: a/b %d, fl %g\n", a/b, floor ((gdouble) a / b));
++#endif
+ return (b * floor ((gdouble) a / b));
+ }
+
+ gint
+ ceilm (gint a, gint b)
+ /* return least multiple of b that is >= a */
++ /*
++ & m = ceilm(a,b)
++ & a = b*m - r;
++ & m = a/b
++ % r = a%b
++ & -a = -b*m + r
++
++ & ceilm = (r == 0 ? b*m : (b+1)*m)
++ */
+ {
++#ifdef RLXTEST
++ printf("ceil: a %d, b %d, -(-a/b) %d,a/b+(a%b != 0 ? 1:0) %d, fl %g\n",
++ a,b,
++ -((-a)/b),
++ a/b+(a%b != 0 ? 1:0),
++ ceil ((gdouble) a / b) );
++#endif
+ return (b * ceil ((gdouble) a / b));
+ }
+
diff --git a/graphics/gimp-refocus-plugin/pkg-descr b/graphics/gimp-refocus-plugin/pkg-descr
new file mode 100644
index 000000000000..8b303dfb911d
--- /dev/null
+++ b/graphics/gimp-refocus-plugin/pkg-descr
@@ -0,0 +1,18 @@
+[ edited excerpt from developer's www site ]
+
+During image processing operations such as scanning and scaling,
+images tend to get blurry.
+
+The blurred impression of these images is due to the fact that image
+pixels are averaged with their neighbors. Blurred images don't have
+sharp boundaries and look as though they have been taken with an
+unfocussed camera.
+
+Refocus is a GIMP plug-in to "refocus" the image, using a technique
+called FIR Wiener filtering. The traditional technique for sharpening
+images is to use unsharp masking. Refocus generally produces better
+results than unsharp masking.
+
+The plugin can be found under "Filters > Enhance > Refocus"
+
+WWW: http://refocus.sourceforge.net/