From 9d8461b2012adb25ba0b10deff31dc766f6ea8f2 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Fri, 10 Dec 2010 18:19:40 +0000 Subject: Release 10.35.78 git-svn-id: http://svn.code.sf.net/p/netpbm/code/super_stable@1375 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- converter/ppm/ilbmtoppm.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'converter/ppm/ilbmtoppm.c') diff --git a/converter/ppm/ilbmtoppm.c b/converter/ppm/ilbmtoppm.c index c88cdfb2..5001741a 100644 --- a/converter/ppm/ilbmtoppm.c +++ b/converter/ppm/ilbmtoppm.c @@ -94,7 +94,6 @@ static short wrotemask = 0; static IFF_ID typeid; /* ID_ILBM, ID_RGBN, ID_RGB8 */ static pixel *transpColor = NULL; /* transparent color */ -static short transpIndex = -1; static char *transpName = NULL; static bool debug = FALSE; @@ -776,15 +775,19 @@ check_cmap(bmhd, cmap) if( bmhd ) { if( bmhd->masking == mskHasTransparentColor || bmhd->masking == mskLasso ) { - transpIndex = bmhd->transparentColor; + unsigned short const transpIdx = bmhd->transparentColor; if( !transpName ) { MALLOCVAR_NOFAIL(transpColor); - if( transpIndex >= cmap->ncolors ) { - pm_message("using default transparent color (black)"); - PPM_ASSIGN(*transpColor, 0, 0, 0); + if (HAS_COLORMAP(cmap)) { + if( transpIdx >= cmap->ncolors ) { + pm_message("using default transparent color (black)"); + PPM_ASSIGN(*transpColor, 0, 0, 0); + } else + *transpColor = cmap->color[transpIdx]; + } else { + /* The color index is just a direct gray level */ + PPM_ASSIGN(*transpColor, transpIdx, transpIdx, transpIdx); } - else - *transpColor = cmap->color[transpIndex]; } } -- cgit 1.4.1