diff --git a/ChangeLog b/ChangeLog index ac20efab..c3f55963 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-05-31 Frank Warmerdam + + * libtiff/tif_getimage.c: Add support for greyscale+alpha c/o Jérémie Laval. + http://bugzilla.maptools.org/show_bug.cgi?id=2398 + 2012-05-29 Frank Warmerdam * libtiff/tif_dir.c: avoid using specific set/get logic to process fields in custom directories, @@ -72,6 +77,7 @@ 2011-12-22 Bob Friesenhahn * libtiff/tif_win32.c: Eliminate some minor 64-bit warnings in + tif_win32.c. Patch by Edward Lam. * configure.ac: Add libtiff private dependency on -llzma for diff --git a/libtiff/tif_getimage.c b/libtiff/tif_getimage.c index c897f5af..88adf1dc 100644 --- a/libtiff/tif_getimage.c +++ b/libtiff/tif_getimage.c @@ -1,4 +1,4 @@ -/* $Id: tif_getimage.c,v 1.79 2012-04-06 16:46:46 fwarmerdam Exp $ */ +/* $Id: tif_getimage.c,v 1.80 2012-06-01 00:38:39 fwarmerdam Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -1208,6 +1208,26 @@ DECLAREContigPutFunc(putgreytile) } } +/* + * 8-bit greyscale with associated alpha => colormap/RGBA + */ +DECLAREContigPutFunc(putagreytile) +{ + int samplesperpixel = img->samplesperpixel; + uint32** BWmap = img->BWmap; + + (void) y; + while (h-- > 0) { + for (x = w; x-- > 0;) + { + *cp++ = BWmap[*pp][0] & (*(pp+1) << 24 | ~A1); + pp += samplesperpixel; + } + cp += toskew; + pp += fromskew; + } +} + /* * 16-bit greyscale => colormap/RGB */ @@ -2473,7 +2493,10 @@ PickContigCase(TIFFRGBAImage* img) img->put.contig = put16bitbwtile; break; case 8: - img->put.contig = putgreytile; + if (img->alpha && img->samplesperpixel == 2) + img->put.contig = putagreytile; + else + img->put.contig = putgreytile; break; case 4: img->put.contig = put4bitbwtile;