Make libgimp depend on GdkPixbuf

Move the pixbuf layer and image thumbnail function from libgimpui to
libgimp and move gimp_layer_new_from_pixbuf() to gimplayer.[ch] where
it belongs. Change gimp-2.0.pc accordingly, adapt plug-in Makefiles
and update devel-docs.
This commit is contained in:
Michael Natterer 2011-04-20 20:04:35 +02:00
parent 5d771014d4
commit 26bf2b0cd7
15 changed files with 163 additions and 162 deletions

View File

@ -118,8 +118,10 @@ AC_SUBST(GIMP_FULL_NAME)
# These are used in the .pc files
GLIB_REQUIRED_VERSION=glib_required_version
GTK_REQUIRED_VERSION=gtk_required_version
GDK_PIXBUF_REQUIRED_VERSION=gdk_pixbuf_required_version
AC_SUBST(GLIB_REQUIRED_VERSION)
AC_SUBST(GTK_REQUIRED_VERSION)
AC_SUBST(GDK_PIXBUF_REQUIRED_VERSION)
# The symbol GIMP_UNSTABLE is defined above for substitution in
# Makefiles and conditionally defined here as a preprocessor symbol

View File

@ -55,6 +55,7 @@
<xi:include href="xml/gimpitemtransform.xml" />
<xi:include href="xml/gimplayer.xml" />
<xi:include href="xml/gimppaths.xml" />
<xi:include href="xml/gimppixbuf.xml" />
<xi:include href="xml/gimppixelfetcher.xml" />
<xi:include href="xml/gimppixelrgn.xml" />
<xi:include href="xml/gimpregioniterator.xml" />
@ -114,7 +115,6 @@
<xi:include href="xml/gimpzoompreview.xml" />
<xi:include href="xml/gimpitemcombobox.xml" />
<xi:include href="xml/gimpimagecombobox.xml" />
<xi:include href="xml/gimppixbuf.xml" />
<xi:include href="xml/gimpprogressbar.xml" />
<xi:include href="xml/gimpmenu.xml" />
<xi:include href="xml/gimpbrushmenu.xml" />

View File

@ -695,6 +695,7 @@ gimp_item_transform_matrix
gimp_layer_new
gimp_layer_new_from_drawable
gimp_layer_new_from_visible
gimp_layer_new_from_pixbuf
gimp_layer_group_new
gimp_layer_copy
gimp_layer_scale
@ -1097,7 +1098,6 @@ GimpPixbufTransparency
gimp_image_get_thumbnail
gimp_drawable_get_thumbnail
gimp_drawable_get_sub_thumbnail
gimp_layer_new_from_pixbuf
</SECTION>
<SECTION>

View File

@ -12,6 +12,6 @@ gimplocaledir=@gimplocaledir@
Name: GIMP
Description: GIMP Library
Version: @GIMP_REAL_VERSION@
Requires: glib-2.0 >= @GLIB_REQUIRED_VERSION@
Requires: gdk-pixbuf-2.0 >= @GDK_PIXBUF_REQUIRED_VERSION@
Libs: -L${libdir} -lgimp-@GIMP_API_VERSION@ -lgimpmath-@GIMP_API_VERSION@ -lgimpconfig-@GIMP_API_VERSION@ -lgimpcolor-@GIMP_API_VERSION@ -lgimpbase-@GIMP_API_VERSION@ @RT_LIBS@
Cflags: -I${includedir}/gimp-@GIMP_API_VERSION@

View File

@ -208,6 +208,8 @@ libgimp_2_0_la_sources = \
gimppatterns.h \
gimppatternselect.c \
gimppatternselect.h \
gimppixbuf.c \
gimppixbuf.h \
gimppixelfetcher.c \
gimppixelfetcher.h \
gimppixelrgn.c \
@ -276,8 +278,6 @@ libgimpui_2_0_la_sources = \
gimppatternmenu.h \
gimppatternselectbutton.c \
gimppatternselectbutton.h \
gimppixbuf.c \
gimppixbuf.h \
gimpprocbrowserdialog.c \
gimpprocbrowserdialog.h \
gimpprocview.c \

View File

@ -21,7 +21,7 @@
#ifndef __GIMP_H__
#define __GIMP_H__
#include <glib-object.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libgimpbase/gimpbase.h>
#include <libgimpcolor/gimpcolor.h>
@ -46,6 +46,7 @@
#include <libgimp/gimppaletteselect.h>
#include <libgimp/gimppatterns.h>
#include <libgimp/gimppatternselect.h>
#include <libgimp/gimppixbuf.h>
#include <libgimp/gimppixelfetcher.h>
#include <libgimp/gimppixelrgn.h>
#include <libgimp/gimpplugin.h>

View File

@ -20,6 +20,8 @@
#include "config.h"
#include <string.h>
#include "gimp.h"
#undef GIMP_DISABLE_DEPRECATED
#undef __GIMP_LAYER_H__
@ -82,6 +84,120 @@ gimp_layer_copy (gint32 layer_ID)
return _gimp_layer_copy (layer_ID, FALSE);
}
/**
* gimp_layer_new_from_pixbuf:
* @image_ID: The RGB image to which to add the layer.
* @name: The layer name.
* @pixbuf: A GdkPixbuf.
* @opacity: The layer opacity.
* @mode: The layer combination mode.
* @progress_start: start of progress
* @progress_end: end of progress
*
* Create a new layer from a %GdkPixbuf.
*
* This procedure creates a new layer from the given %GdkPixbuf. The
* image has to be an RGB image and just like with gimp_layer_new()
* you will still need to add the layer to it.
*
* If you pass @progress_end > @progress_start to this function,
* gimp_progress_update() will be called for. You have to call
* gimp_progress_init() beforehand then.
*
* Returns: The newly created layer.
*
* Since: GIMP 2.4
*/
gint32
gimp_layer_new_from_pixbuf (gint32 image_ID,
const gchar *name,
GdkPixbuf *pixbuf,
gdouble opacity,
GimpLayerModeEffects mode,
gdouble progress_start,
gdouble progress_end)
{
GimpDrawable *drawable;
GimpPixelRgn rgn;
const guchar *pixels;
gpointer pr;
gint32 layer;
gint width;
gint height;
gint rowstride;
gint bpp;
gdouble range = progress_end - progress_start;
guint count = 0;
guint done = 0;
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
if (gimp_image_base_type (image_ID) != GIMP_RGB)
{
g_warning ("gimp_layer_new_from_pixbuf() needs an RGB image");
return -1;
}
if (gdk_pixbuf_get_colorspace (pixbuf) != GDK_COLORSPACE_RGB)
{
g_warning ("gimp_layer_new_from_pixbuf() assumes that GdkPixbuf is RGB");
return -1;
}
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
bpp = gdk_pixbuf_get_n_channels (pixbuf);
layer = gimp_layer_new (image_ID, name, width, height,
bpp == 3 ? GIMP_RGB_IMAGE : GIMP_RGBA_IMAGE,
opacity, mode);
if (layer == -1)
return -1;
drawable = gimp_drawable_get (layer);
gimp_pixel_rgn_init (&rgn, drawable, 0, 0, width, height, TRUE, FALSE);
g_assert (bpp == rgn.bpp);
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
pixels = gdk_pixbuf_get_pixels (pixbuf);
for (pr = gimp_pixel_rgns_register (1, &rgn);
pr != NULL;
pr = gimp_pixel_rgns_process (pr))
{
const guchar *src = pixels + rgn.y * rowstride + rgn.x * bpp;
guchar *dest = rgn.data;
gint y;
for (y = 0; y < rgn.h; y++)
{
memcpy (dest, src, rgn.w * rgn.bpp);
src += rowstride;
dest += rgn.rowstride;
}
if (range > 0.0)
{
done += rgn.h * rgn.w;
if (count++ % 32 == 0)
gimp_progress_update (progress_start +
(gdouble) done / (width * height) * range);
}
}
if (range > 0.0)
gimp_progress_update (progress_end);
gimp_drawable_detach (drawable);
return layer;
}
/**
* gimp_layer_get_preserve_trans:
* @layer_ID: The layer.

View File

@ -35,6 +35,14 @@ gint32 gimp_layer_new (gint32 image_ID,
GimpLayerModeEffects mode);
gint32 gimp_layer_copy (gint32 layer_ID);
gint32 gimp_layer_new_from_pixbuf (gint32 image_ID,
const gchar *name,
GdkPixbuf *pixbuf,
gdouble opacity,
GimpLayerModeEffects mode,
gdouble progress_start,
gdouble progress_end);
#ifndef GIMP_DISABLE_DEPRECATED
gboolean gimp_layer_get_preserve_trans (gint32 layer_ID);

View File

@ -21,10 +21,6 @@
#include "config.h"
#include <string.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "gimp.h"
#include "gimppixbuf.h"
@ -184,120 +180,6 @@ gimp_drawable_get_sub_thumbnail (gint32 drawable_ID,
return NULL;
}
/**
* gimp_layer_new_from_pixbuf:
* @image_ID: The RGB image to which to add the layer.
* @name: The layer name.
* @pixbuf: A GdkPixbuf.
* @opacity: The layer opacity.
* @mode: The layer combination mode.
* @progress_start: start of progress
* @progress_end: end of progress
*
* Create a new layer from a %GdkPixbuf.
*
* This procedure creates a new layer from the given %GdkPixbuf. The
* image has to be an RGB image and just like with gimp_layer_new()
* you will still need to add the layer to it.
*
* If you pass @progress_end > @progress_start to this function,
* gimp_progress_update() will be called for. You have to call
* gimp_progress_init() beforehand then.
*
* Returns: The newly created layer.
*
* Since: GIMP 2.4
*/
gint32
gimp_layer_new_from_pixbuf (gint32 image_ID,
const gchar *name,
GdkPixbuf *pixbuf,
gdouble opacity,
GimpLayerModeEffects mode,
gdouble progress_start,
gdouble progress_end)
{
GimpDrawable *drawable;
GimpPixelRgn rgn;
const guchar *pixels;
gpointer pr;
gint32 layer;
gint width;
gint height;
gint rowstride;
gint bpp;
gdouble range = progress_end - progress_start;
guint count = 0;
guint done = 0;
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
if (gimp_image_base_type (image_ID) != GIMP_RGB)
{
g_warning ("gimp_layer_new_from_pixbuf() needs an RGB image");
return -1;
}
if (gdk_pixbuf_get_colorspace (pixbuf) != GDK_COLORSPACE_RGB)
{
g_warning ("gimp_layer_new_from_pixbuf() assumes that GdkPixbuf is RGB");
return -1;
}
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
bpp = gdk_pixbuf_get_n_channels (pixbuf);
layer = gimp_layer_new (image_ID, name, width, height,
bpp == 3 ? GIMP_RGB_IMAGE : GIMP_RGBA_IMAGE,
opacity, mode);
if (layer == -1)
return -1;
drawable = gimp_drawable_get (layer);
gimp_pixel_rgn_init (&rgn, drawable, 0, 0, width, height, TRUE, FALSE);
g_assert (bpp == rgn.bpp);
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
pixels = gdk_pixbuf_get_pixels (pixbuf);
for (pr = gimp_pixel_rgns_register (1, &rgn);
pr != NULL;
pr = gimp_pixel_rgns_process (pr))
{
const guchar *src = pixels + rgn.y * rowstride + rgn.x * bpp;
guchar *dest = rgn.data;
gint y;
for (y = 0; y < rgn.h; y++)
{
memcpy (dest, src, rgn.w * rgn.bpp);
src += rowstride;
dest += rgn.rowstride;
}
if (range > 0.0)
{
done += rgn.h * rgn.w;
if (count++ % 32 == 0)
gimp_progress_update (progress_start +
(gdouble) done / (width * height) * range);
}
}
if (range > 0.0)
gimp_progress_update (progress_end);
gimp_drawable_detach (drawable);
return layer;
}
/*
* The data that is passed to this function is either freed here or

View File

@ -53,15 +53,6 @@ GdkPixbuf * gimp_drawable_get_sub_thumbnail (gint32 drawable_ID
gint dest_height,
GimpPixbufTransparency alpha);
gint32 gimp_layer_new_from_pixbuf (gint32 image_ID,
const gchar *name,
GdkPixbuf *pixbuf,
gdouble opacity,
GimpLayerModeEffects mode,
gdouble progress_start,
gdouble progress_end);
G_END_DECLS
#endif /* __GIMP_PIXBUF_H__ */

View File

@ -34,7 +34,6 @@
#include <libgimp/gimpgradientmenu.h>
#include <libgimp/gimppalettemenu.h>
#include <libgimp/gimppatternmenu.h>
#include <libgimp/gimppixbuf.h>
#include <libgimp/gimpprocbrowserdialog.h>
#include <libgimp/gimpprocview.h>
#include <libgimp/gimpprogressbar.h>

View File

@ -264,7 +264,7 @@ animation_optimize_LDADD = \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(animation_optimize_RC)
@ -295,7 +295,7 @@ antialias_LDADD = \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(antialias_RC)
@ -343,7 +343,7 @@ blur_LDADD = \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(blur_RC)
@ -631,7 +631,7 @@ contrast_normalize_LDADD = \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(contrast_normalize_RC)
@ -662,7 +662,7 @@ contrast_stretch_LDADD = \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(contrast_stretch_RC)
@ -676,7 +676,7 @@ contrast_stretch_hsv_LDADD = \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(contrast_stretch_hsv_RC)
@ -707,7 +707,7 @@ crop_auto_LDADD = \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(crop_auto_RC)
@ -721,7 +721,7 @@ crop_zealous_LDADD = \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(crop_zealous_RC)
@ -922,7 +922,7 @@ edge_laplace_LDADD = \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(edge_laplace_RC)
@ -1039,7 +1039,7 @@ file_compressor_LDADD = \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(file_compressor_RC)
@ -1070,7 +1070,7 @@ file_desktop_link_LDADD = \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(file_desktop_link_RC)
@ -1120,7 +1120,7 @@ file_gif_load_LDADD = \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(file_gif_load_RC)
@ -1168,7 +1168,7 @@ file_glob_LDADD = \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(file_glob_RC)
@ -1216,7 +1216,7 @@ file_jp2_load_LDADD = \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(JP2_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
@ -1660,7 +1660,7 @@ gradient_map_LDADD = \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(gradient_map_RC)
@ -1691,7 +1691,7 @@ guillotine_LDADD = \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(guillotine_RC)
@ -2201,7 +2201,7 @@ rotate_LDADD = \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(rotate_RC)
@ -2252,7 +2252,7 @@ semi_flatten_LDADD = \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(semi_flatten_RC)
@ -2453,7 +2453,7 @@ tile_seamless_LDADD = \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(tile_seamless_RC)
@ -2518,7 +2518,7 @@ value_invert_LDADD = \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(value_invert_RC)

View File

@ -137,9 +137,9 @@ foreach (sort keys %plugins) {
my $glib;
if (exists $plugins{$_}->{ui}) {
$glib = "\$(GTK_LIBS)"
$glib = "\$(GTK_LIBS)\t\t\\"
} else {
$glib = "\$(GLIB_LIBS)"
$glib = "\$(GDK_PIXBUF_LIBS)\t\\"
}
my $optlib = "";
@ -177,7 +177,7 @@ ${makename}_SOURCES = \\
${makename}_LDADD = \\
$libgimp \\
$glib \\$optlib
$glib$optlib
$deplib \\
$rclib
EOT

View File

@ -29,8 +29,8 @@ file_faxg3_SOURCES = \
g3.h
INCLUDES = \
-I$(top_srcdir) \
$(GLIB_CFLAGS) \
-I$(top_srcdir) \
$(GDK_PIXBUF_CFLAGS) \
-I$(includedir)
LDADD = \
@ -39,7 +39,7 @@ LDADD = \
$(libgimpcolor) \
$(libgimpbase) \
$(libgimpmath) \
$(GLIB_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(file_faxg3_RC)

View File

@ -43,8 +43,9 @@ libexec_PROGRAMS = help
help_SOURCES = help.c
INCLUDES = \
-I$(top_srcdir) \
$(GIO_CFLAGS) \
-I$(top_srcdir) \
$(GIO_CFLAGS) \
$(GDK_PIXBUF_CFLAGS) \
-I$(includedir)
LDADD = \
@ -55,6 +56,7 @@ LDADD = \
$(libgimpbase) \
$(libgimpmath) \
$(GIO_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(help_RC)