[gimp/gimp-2-8] file-tga: Handle 16-bit palettes with transparency (#687802)
- From: Mukund Sivaraman <muks src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-8] file-tga: Handle 16-bit palettes with transparency (#687802)
- Date: Tue, 4 Dec 2012 19:10:29 +0000 (UTC)
commit 050fcb4b37ca8b5bd6abcf7d63d74e3d907a1436
Author: Mukund Sivaraman <muks banu com>
Date: Tue Dec 4 23:30:26 2012 +0530
file-tga: Handle 16-bit palettes with transparency (#687802)
Primarily, this fixes a buffer overflow in the colormap buffer.
* We promote such images to GIMP_RGBA_IMAGE now.
* The alpha handling for the colormap to RGBA conversion has been
fixed.
* Inverted transparency in upsampling has been fixed.
plug-ins/common/file-tga.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/plug-ins/common/file-tga.c b/plug-ins/common/file-tga.c
index c1d05dd..95410bf 100644
--- a/plug-ins/common/file-tga.c
+++ b/plug-ins/common/file-tga.c
@@ -812,7 +812,7 @@ upsample (guchar *dest,
if (alpha)
{
- dest[3] = (src[1] & 0x80) ? 0 : 255;
+ dest[3] = (src[1] & 0x80) ? 255 : 0;
dest += 4;
}
else
@@ -927,8 +927,12 @@ read_line (FILE *fp,
}
else if (convert_cmap)
{
- apply_colormap (row, buffer, info->width, convert_cmap,
- (info->colorMapSize > 24));
+ gboolean has_alpha = (info->colorMapSize > 24) ||
+ ((info->colorMapSize == 16 ||
+ info->colorMapSize == 15) &&
+ (info->alphaBits > 0));
+
+ apply_colormap (row, buffer, info->width, convert_cmap, has_alpha);
}
else
{
@@ -978,6 +982,13 @@ ReadImage (FILE *fp,
dtype = GIMP_RGB_IMAGE;
convert_cmap = g_new (guchar, info->colorMapLength * 3);
}
+ else if (info->alphaBits > 0)
+ {
+ /* if alpha exists here, promote to RGB */
+ itype = GIMP_RGB;
+ dtype = GIMP_RGBA_IMAGE;
+ convert_cmap = g_new (guchar, info->colorMapLength * 4);
+ }
else
{
itype = GIMP_INDEXED;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]