[gdk-pixbuf/wip/otte/tga: 9/17] tga: Use gdk_pixbuf_new ()



commit 733f8b5536cbf037949ff615e8addff63fbf2c76
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 5fa1cc3..def2414 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]