mirror of https://github.com/GNOME/gimp.git
app: add gimp_pixbuf_create_buffer() and use it in GimpBuffer
This commit is contained in:
parent
3ce071b89a
commit
553e65e859
|
@ -261,28 +261,14 @@ gimp_buffer_new_from_pixbuf (GdkPixbuf *pixbuf,
|
|||
{
|
||||
GimpBuffer *gimp_buffer;
|
||||
GeglBuffer *buffer;
|
||||
gint width;
|
||||
gint height;
|
||||
gint rowstride;
|
||||
gint channels;
|
||||
GeglRectangle rect = { 0, };
|
||||
|
||||
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
width = gdk_pixbuf_get_width (pixbuf);
|
||||
height = gdk_pixbuf_get_height (pixbuf);
|
||||
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
|
||||
channels = gdk_pixbuf_get_n_channels (pixbuf);
|
||||
|
||||
rect.width = width;
|
||||
rect.height = height;
|
||||
|
||||
buffer = gegl_buffer_linear_new_from_data (gdk_pixbuf_get_pixels (pixbuf),
|
||||
gimp_bpp_to_babl_format (channels,
|
||||
TRUE),
|
||||
&rect, rowstride,
|
||||
NULL, NULL);
|
||||
buffer = gimp_pixbuf_create_buffer (pixbuf);
|
||||
|
||||
gimp_buffer = gimp_buffer_new (buffer, name,
|
||||
GIMP_IMAGE_TYPE_FROM_BYTES (channels),
|
||||
|
|
|
@ -132,6 +132,33 @@ gimp_interpolation_to_gegl_filter (GimpInterpolationType interpolation)
|
|||
return "nearest";
|
||||
}
|
||||
|
||||
GeglBuffer *
|
||||
gimp_pixbuf_create_buffer (GdkPixbuf *pixbuf)
|
||||
{
|
||||
gint width;
|
||||
gint height;
|
||||
gint rowstride;
|
||||
gint channels;
|
||||
GeglRectangle rect = { 0, };
|
||||
|
||||
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
|
||||
|
||||
width = gdk_pixbuf_get_width (pixbuf);
|
||||
height = gdk_pixbuf_get_height (pixbuf);
|
||||
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
|
||||
channels = gdk_pixbuf_get_n_channels (pixbuf);
|
||||
|
||||
rect.width = width;
|
||||
rect.height = height;
|
||||
|
||||
return gegl_buffer_linear_new_from_data (gdk_pixbuf_get_pixels (pixbuf),
|
||||
gimp_bpp_to_babl_format (channels,
|
||||
TRUE),
|
||||
&rect, rowstride,
|
||||
(GDestroyNotify) g_object_unref,
|
||||
pixbuf);
|
||||
}
|
||||
|
||||
GeglBuffer *
|
||||
gimp_tile_manager_create_buffer (TileManager *tm,
|
||||
const Babl *format,
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
#define __GIMP_GEGL_UTILS_H__
|
||||
|
||||
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h> /* temp hack */
|
||||
|
||||
|
||||
const Babl * gimp_bpp_to_babl_format (guint bpp,
|
||||
gboolean linear) G_GNUC_CONST;
|
||||
|
||||
|
@ -31,6 +34,7 @@ const gchar * gimp_interpolation_to_gegl_filter (GimpInterpolationType interpol
|
|||
GeglBuffer * gimp_tile_manager_create_buffer (TileManager *tm,
|
||||
const Babl *format,
|
||||
gboolean write);
|
||||
GeglBuffer * gimp_pixbuf_create_buffer (GdkPixbuf *pixbuf);
|
||||
|
||||
void gimp_gegl_buffer_refetch_tiles (GeglBuffer *buffer);
|
||||
|
||||
|
|
Loading…
Reference in New Issue