bug 93: default unmarked 4th sample as alpha

This commit is contained in:
Frank Warmerdam 2001-12-15 15:11:22 +00:00
parent 05d24d304f
commit 62d3736392
3 changed files with 39 additions and 2 deletions

View File

@ -1,3 +1,15 @@
2001-12-15 Frank Warmerdam <warmerdam@pobox.com>
* libtiff/tif_getimage.c: If DEFAULT_EXTRASAMPLE_AS_ALPHA is 1
(defined in tiffconf.h - 1 by default) then the RGBA interface
will assume that a fourth extra sample is ASSOCALPHA if the
EXTRASAMPLE value isn't set for it. This changes the behaviour of
the library, but makes it work better with RGBA files produced by
lots of applications that don't mark the alpha values properly.
http://bugzilla.remotesensing.org/show_bug.cgi?id=93
http://bugzilla.remotesensing.org/show_bug.cgi?id=65
2001-12-12 Frank Warmerdam <warmerdam@pobox.com>
* libtiff/tif_jpeg.c: allow jpeg data stream sampling values to

View File

@ -1,4 +1,4 @@
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_getimage.c,v 1.15 2001-09-24 19:40:37 warmerda Exp $ */
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_getimage.c,v 1.16 2001-12-15 15:11:22 warmerda Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
@ -220,12 +220,28 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024])
TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES,
&extrasamples, &sampleinfo);
if (extrasamples == 1)
{
switch (sampleinfo[0]) {
case EXTRASAMPLE_ASSOCALPHA: /* data is pre-multiplied */
case EXTRASAMPLE_UNASSALPHA: /* data is not pre-multiplied */
img->alpha = sampleinfo[0];
break;
}
}
#if DEFAULT_EXTRASAMPLE_AS_ALPHA == 1
if( !TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric))
img->photometric = PHOTOMETRIC_MINISWHITE;
if( extrasamples == 0
&& img->samplesperpixel == 4
&& img->photometric == PHOTOMETRIC_RGB )
{
img->alpha = EXTRASAMPLE_ASSOCALPHA;
extrasamples = 1;
}
#endif
colorchannels = img->samplesperpixel - extrasamples;
TIFFGetFieldDefaulted(tif, TIFFTAG_COMPRESSION, &compress);
TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planarconfig);

View File

@ -1,4 +1,4 @@
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/Attic/tiffconf.h,v 1.3 2001-05-12 03:59:50 warmerda Exp $ */
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/Attic/tiffconf.h,v 1.4 2001-12-15 15:11:22 warmerda Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
@ -133,6 +133,11 @@
* or not to convert single-strip uncompressed images
* to mutiple strips of ~8Kb--to reduce memory use)
* SUBIFD_SUPPORT enable support for SubIFD tag (thumbnails and such)
* DEFAULT_EXTRASAMPLE_AS_ALPHA
* The RGBA interface will treat a fourth sample with
* no EXTRASAMPLE_ value as being ASSOCALPHA. Many
* packages produce RGBA files but don't mark the alpha
* properly.
*/
#ifndef STRIPCHOP_DEFAULT
#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP /* default is to enable */
@ -140,4 +145,8 @@
#ifndef SUBIFD_SUPPORT
#define SUBIFD_SUPPORT 1 /* enable SubIFD tag (330) support */
#endif
#ifndef DEFAULT_EXTRASAMPLE_AS_ALPHA
#define DEFAULT_EXTRASAMPLE_AS_ALPHA 1
#endif
#endif /* _TIFFCONF_ */