summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2015-09-20 21:44:08 +0200
committerBenjamin Otte <otte@redhat.com>2015-09-24 12:48:31 +0200
commit89ce7bd0075256c8c19eb217fe813181ad712f39 (patch)
tree253d05bea67d1838b2b3a922aa55cdc80171f7d4
parenta758a063e8cbab1f9274248fb7b864d20c1b64d8 (diff)
downloadgdk-pixbuf-89ce7bd0075256c8c19eb217fe813181ad712f39.tar.gz
tga: Support 16bpp images
-rw-r--r--gdk-pixbuf/io-tga.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/gdk-pixbuf/io-tga.c b/gdk-pixbuf/io-tga.c
index 99d113465..58dba063e 100644
--- a/gdk-pixbuf/io-tga.c
+++ b/gdk-pixbuf/io-tga.c
@@ -253,7 +253,8 @@ tga_format_supported (guint type,
case TGA_TYPE_TRUECOLOR:
case TGA_TYPE_RLE_TRUECOLOR:
- return bits_per_pixel == 24
+ return bits_per_pixel == 16
+ || bits_per_pixel == 24
|| bits_per_pixel == 32;
case TGA_TYPE_GRAYSCALE:
@@ -280,13 +281,27 @@ tga_read_pixel (TGAContext *ctx,
case TGA_TYPE_TRUECOLOR:
case TGA_TYPE_RLE_TRUECOLOR:
- color->b = data[0];
- color->g = data[1];
- color->r = data[2];
- if (ctx->hdr->bpp == 32)
- color->a = data[3];
+ if (ctx->hdr->bpp == 16)
+ {
+ guint16 col = data[0] + (data[1] << 8);
+ color->r = (col >> 7) & 0xf8;
+ color->r |= color->r >> 5;
+ color->g = (col >> 2) & 0xf8;
+ color->g |= color->g >> 5;
+ color->b = col << 3;
+ color->b |= color->b >> 5;
+ color->a = 255;
+ }
else
- color->a = 255;
+ {
+ color->b = data[0];
+ color->g = data[1];
+ color->r = data[2];
+ if (ctx->hdr->bpp == 32)
+ color->a = data[3];
+ else
+ color->a = 255;
+ }
break;
case TGA_TYPE_GRAYSCALE: