[Gdal-dev] Bug 1384 on FWTools release 1.1.2 (GDAL 1.4.0beta2)

Dori izzybitsie at gmail.com
Tue Jan 2 13:03:46 EST 2007


I have already tried to use gdal by downloading FWTools updated with beta2
and a problem I experienced with previous gdal version is still there(pls.
see below description of original problem).

ORIGINAL PROBLEM: running gdal_merge.py -pct -o output.tif -pct in1.tif
in2.tif where in*tif = geotiff images with one band and same color table,
gave me a full black out.tif.
This was reported as a bug and it was fixed according to bugzilla report for

You can find the input images here if you would like to give it a try:


Updated colortable reading to look guess about the scaling problem, and
fix up on the fly if encountered.  Like this:

       int     nColorCount, nMaxColor = 0;
       GDALColorEntry oEntry;

       poColorTable = new GDALColorTable();

       nColorCount = 1 << nBitsPerSample;

       for( int iColor = nColorCount - 1; iColor >= 0; iColor-- )
           oEntry.c1 = panRed[iColor] / 256;
           oEntry.c2 = panGreen[iColor] / 256;
           oEntry.c3 = panBlue[iColor] / 256;
           oEntry.c4 = 255;

           poColorTable->SetColorEntry( iColor, &oEntry );

           nMaxColor = MAX(nMaxColor,panRed[iColor]);
           nMaxColor = MAX(nMaxColor,panGreen[iColor]);
           nMaxColor = MAX(nMaxColor,panBlue[iColor]);

       // Bug 1384 - Some TIFF files are generated with color map entry
       // values in range 0-255 instead of 0-65535 - try to handle these
       // gracefully.
       if( nMaxColor > 0 && nMaxColor < 256 )
           CPLDebug( "GTiff", "TIFF ColorTable seems to be improperly
fixing up." );

           for( int iColor = nColorCount - 1; iColor >= 0; iColor-- )
               oEntry.c1 = panRed[iColor];
               oEntry.c2 = panGreen[iColor];
               oEntry.c3 = panBlue[iColor];
               oEntry.c4 = 255;

               poColorTable->SetColorEntry( iColor, &oEntry );

The problem file has been archived in data/geotiff/misc as:



I checked geotiff.cpp downloaded with gdal1.4.0beta2 that includes code that
looks like the one above, but I don't see this fix in this code.  Am I
looking at the wrong code?

Does anyone know if fix for this bug was really included in FWTools1.1.2?
If so, does anyone have an idea on why I am still getting a black output
Is there any other way to compose these 2 images keeping the color table?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20070102/76053683/attachment.html

More information about the Gdal-dev mailing list