[gdk-pixbuf/wip/otte/tga: 9/24] tga: Use gdk_pixbuf_new ()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdk-pixbuf/wip/otte/tga: 9/24] tga: Use gdk_pixbuf_new ()
- Date: Wed, 30 Sep 2015 01:29:57 +0000 (UTC)
commit a1760607065332d3a4f82b2ce26182acbba81b38
Author: Benjamin Otte <otte redhat com>
Date: Sun Sep 20 18:04:09 2015 +0200
tga: Use gdk_pixbuf_new ()
We don't need contiguous pixbufs anymore.
gdk-pixbuf/io-tga.c | 33 +--------------------------------
1 files changed, 1 insertions(+), 32 deletions(-)
---
diff --git a/gdk-pixbuf/io-tga.c b/gdk-pixbuf/io-tga.c
index e313843..b4ab70b 100644
--- a/gdk-pixbuf/io-tga.c
+++ b/gdk-pixbuf/io-tga.c
@@ -133,11 +133,6 @@ struct _TGAContext {
gpointer udata;
};
-static void free_buffer(guchar *pixels, gpointer data)
-{
- g_free(pixels);
-}
-
static TGAColormap *
colormap_new (guint n_colors)
{
@@ -192,32 +187,6 @@ tga_skip_rest_of_image (TGAContext *ctx,
return TRUE;
}
-static GdkPixbuf *get_contiguous_pixbuf (guint width,
- guint height,
- gboolean has_alpha)
-{
- guchar *pixels;
- guint channels, rowstride;
-
- if (has_alpha)
- channels = 4;
- else
- channels = 3;
-
- rowstride = width * channels;
-
- if (rowstride / channels != width)
- return NULL;
-
- pixels = g_try_malloc_n (height, rowstride);
-
- if (!pixels)
- return NULL;
-
- return gdk_pixbuf_new_from_data (pixels, GDK_COLORSPACE_RGB, has_alpha, 8,
- width, height, rowstride, free_buffer, NULL);
-}
-
static inline void
tga_write_pixel (TGAContext *ctx,
const TGAColor *color)
@@ -324,7 +293,7 @@ static gboolean fill_in_context(TGAContext *ctx, GError **err)
return FALSE;
}
- ctx->pbuf = get_contiguous_pixbuf (w, h, alpha);
+ ctx->pbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, alpha, 8, w, h);
if (!ctx->pbuf) {
g_set_error_literal(err, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]