From 6f71effa78e8366caedc28962d1d74661a90df03 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Sep 2015 23:16:38 +0200 Subject: 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 file changed, 11 insertions(+) (limited to 'gdk-pixbuf') diff --git a/gdk-pixbuf/io-tga.c b/gdk-pixbuf/io-tga.c index 848b76e6e..b915d98ab 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); -- cgit v1.2.1