--- tga.c.old 2003-04-18 03:06:10.000000000 +0900 +++ tga.c 2003-04-18 03:13:34.000000000 +0900 @@ -743,7 +743,8 @@ upsample (guchar *dest, guchar *src, guint width, - guint bytes) + guint bytes, + guint8 alphaBits) { gint x; @@ -758,7 +759,14 @@ dest[2] = ((src[0] << 3) & 0xf8); dest[2] += (dest[2] >> 5); - dest += 3; + /* alphaBits takes 0 or 1. */ + if(alphaBits == 1){ + dest[3] = (src[0] & 0x80)? 255: 0; + dest += 4; + } + else{ /* alphaBits == 0 */ + dest += 3; + } src += bytes; } } @@ -822,7 +830,7 @@ { if (info->bpp == 16 || info->bpp == 15) { - upsample (row, buffer, info->width, info->bytes); + upsample (row, buffer, info->width, info->bytes, info->alphaBits); } else { @@ -898,7 +906,7 @@ else if (info->colorMapSize == 24) bgr2rgb(gimp_cmap, tga_cmap, info->colorMapLength, cmap_bytes, 0); else if (info->colorMapSize == 16 || info->colorMapSize == 15) - upsample(gimp_cmap, tga_cmap, info->colorMapLength, cmap_bytes); + upsample(gimp_cmap, tga_cmap, info->colorMapLength, cmap_bytes, info->alphaBits); } else