[gdk-pixbuf] tga: Fill remaining pixels when closing incompletely loaded image



commit 6f71effa78e8366caedc28962d1d74661a90df03
Author: Benjamin Otte <otte redhat com>
Date:   Mon Sep 21 23:16:38 2015 +0200

    tga: Fill remaining pixels when closing incompletely loaded image
    
    This way, the images are neatly transparent/black instead of random
    colors.

 gdk-pixbuf/io-tga.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/gdk-pixbuf/io-tga.c b/gdk-pixbuf/io-tga.c
index 848b76e..b915d98 100644
--- a/gdk-pixbuf/io-tga.c
+++ b/gdk-pixbuf/io-tga.c
@@ -685,6 +685,17 @@ static gboolean gdk_pixbuf__tga_stop_load(gpointer data, GError **err)
        TGAContext *ctx = (TGAContext *) data;
        g_return_val_if_fail(ctx != NULL, FALSE);
 
+        if (ctx->pbuf)
+          {
+            TGAColor transparent_black = { 0, 0, 0, 0 };
+            gsize remaining;
+
+            for (remaining = tga_pixels_remaining (ctx); remaining; remaining--)
+              {
+                tga_write_pixel (ctx, &transparent_black);
+              }
+          }
+
        g_free (ctx->hdr);
        if (ctx->cmap)
           colormap_free (ctx->cmap);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]