Commit f4d470f3 authored by Debarshi Ray's avatar Debarshi Ray

gegl: Add photos_gegl_buffer_new_from_pixbuf

This is part of a new set of APIs for GeglBuffer that don't require the
creation of a graph. These will allow decoding and encoding image file
formats to and from a GeglBuffer through asynchronous and cancellable
methods with error handling. These will follow GIO idioms and be
similar to the codec APIs for GdkPixbuf. There will be a compatibility
layer to convert a GeglBuffer to and from GdkPixbuf for legacy reasons.

These APIs will address the current lack of cancellation and error
handling in gegl:load, and make it easier to port existing code away
from GdkPixbuf.

A subsequent commit will use this method to optimize the application of
a BaseItem's embedded orientation.

Bump minimum GdkPixbuf version to 2.32.

https://bugzilla.gnome.org/show_bug.cgi?id=781736
parent 25315e9d
......@@ -38,6 +38,7 @@ GLIB_GSETTINGS
CAIRO_MIN_VERSION=1.14.0
GDATA_MIN_VERSION=0.15.2
GDK_PIXBUF_MIN_VERSION=2.32
GEGL_MIN_VERSION=0.3.15
GFBGRAPH_MIN_VERSION=0.2.1
GLIB_MIN_VERSION=2.44.0
......@@ -103,7 +104,7 @@ PKG_CHECK_MODULES(GDATA, [libgdata >= $GDATA_MIN_VERSION])
PKG_CHECK_MODULES(GEGL, [gegl-0.3 >= $GEGL_MIN_VERSION])
PKG_CHECK_MODULES(GEOCODE, [geocode-glib-1.0])
PKG_CHECK_MODULES(GEXIV2, [gexiv2])
PKG_CHECK_MODULES(GDK_PIXBUF, [gdk-pixbuf-2.0])
PKG_CHECK_MODULES(GDK_PIXBUF, [gdk-pixbuf-2.0 >= $GDK_PIXBUF_MIN_VERSION])
PKG_CHECK_MODULES(GLIB, [glib-2.0 >= $GLIB_MIN_VERSION])
PKG_CHECK_MODULES(GIO, [gio-2.0 gio-unix-2.0])
......
......@@ -69,6 +69,36 @@ static const gchar *REQUIRED_GEGL_OPS[] =
};
GeglBuffer *
photos_gegl_buffer_new_from_pixbuf (GdkPixbuf *pixbuf)
{
const Babl *format;
GeglBuffer *buffer = NULL;
GeglRectangle bbox;
gint height;
gint stride;
gint width;
const guint8 *pixels;
height = gdk_pixbuf_get_height (pixbuf);
width = gdk_pixbuf_get_width (pixbuf);
gegl_rectangle_set (&bbox, 0, 0, (guint) width, (guint) height);
if (gdk_pixbuf_get_has_alpha (pixbuf))
format = babl_format ("R'G'B'A u8");
else
format = babl_format ("R'G'B' u8");
buffer = gegl_buffer_new (&bbox, format);
pixels = gdk_pixbuf_read_pixels (pixbuf);
stride = gdk_pixbuf_get_rowstride (pixbuf);
gegl_buffer_set (buffer, &bbox, 0, format, pixels, stride);
return buffer;
}
static GeglBuffer *
photos_gegl_buffer_zoom (GeglBuffer *buffer, gdouble zoom, GCancellable *cancellable, GError **error)
{
......
......@@ -29,6 +29,8 @@
G_BEGIN_DECLS
GeglBuffer *photos_gegl_buffer_new_from_pixbuf (GdkPixbuf *pixbuf);
void photos_gegl_buffer_zoom_async (GeglBuffer *buffer,
gdouble zoom,
GCancellable *cancellable,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment