[gimp] app: use GEGL to convert a TempBuf to a GdkPixbuf
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: use GEGL to convert a TempBuf to a GdkPixbuf
- Date: Wed, 2 May 2012 16:34:28 +0000 (UTC)
commit b521cb427294810873dc0f24060f2130d77f21c1
Author: Michael Natterer <mitch gimp org>
Date: Sun Apr 8 00:19:50 2012 +0200
app: use GEGL to convert a TempBuf to a GdkPixbuf
app/core/gimpviewable.c | 45 ++++++++++++++-------------------------------
1 files changed, 14 insertions(+), 31 deletions(-)
---
diff --git a/app/core/gimpviewable.c b/app/core/gimpviewable.c
index 8b46d0d..7eb2eb4 100644
--- a/app/core/gimpviewable.c
+++ b/app/core/gimpviewable.c
@@ -31,6 +31,8 @@
#include "base/temp-buf.h"
+#include "gegl/gimp-gegl-utils.h"
+
#include "gimp-utils.h"
#include "gimpcontext.h"
#include "gimpmarshal.h"
@@ -353,41 +355,22 @@ gimp_viewable_real_get_new_pixbuf (GimpViewable *viewable,
if (temp_buf)
{
- TempBuf *color_buf = NULL;
- gint width;
- gint height;
- gint bytes;
-
- bytes = temp_buf->bytes;
- width = temp_buf->width;
- height = temp_buf->height;
+ GeglBuffer *src_buffer;
+ GeglBuffer *dest_buffer;
- if (bytes == 1 || bytes == 2)
- {
- gint color_bytes;
+ pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
+ temp_buf->bytes == 4 || temp_buf->bytes == 2,
+ 8,
+ temp_buf->width,
+ temp_buf->height);
- color_bytes = (bytes == 2) ? 4 : 3;
+ src_buffer = gimp_temp_buf_create_buffer (temp_buf, NULL, FALSE);
+ dest_buffer = gimp_pixbuf_create_buffer (pixbuf);
- color_buf = temp_buf_new (width, height, color_bytes);
- temp_buf_copy (temp_buf, color_buf);
-
- temp_buf = color_buf;
- bytes = color_bytes;
- }
+ gegl_buffer_copy (src_buffer, NULL, dest_buffer, NULL);
- pixbuf = gdk_pixbuf_new_from_data (g_memdup (temp_buf_get_data (temp_buf),
- width * height * bytes),
- GDK_COLORSPACE_RGB,
- (bytes == 4),
- 8,
- width,
- height,
- width * bytes,
- (GdkPixbufDestroyNotify) g_free,
- NULL);
-
- if (color_buf)
- temp_buf_free (color_buf);
+ g_object_unref (src_buffer);
+ g_object_unref (dest_buffer);
}
return pixbuf;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]