[Mapserver-users] 16 color tiffs don't display correctly

Frank Warmerdam warmerdam at pobox.com
Mon Jun 16 06:06:12 PDT 2003


Twan Kogels wrote:
> Hello,
> 
> I've managed to let mapserver display a couple of tiff files at 1:1 
> resolution so no distortion (from resample or resize) occur. But i have 
> a problem with displaying tiff files with only 16 colors:
> ==============
> Driver: GTiff/GeoTIFF
...
> Band 1 Block=1778x8 Type=Byte, ColorInterp=Red
> Band 2 Block=1778x8 Type=Byte, ColorInterp=Green
> Band 3 Block=1778x8 Type=Byte, ColorInterp=Blue
> Band 4 Block=1778x8 Type=Byte, ColorInterp=Alpha

Twan,

The issue here for GDAL is that it uses the generic "convert to
32bit RGBA" logic in libtiff for some more esoteric styles of TIFF
file, including files with 2-7 bits per pixel.  In this case I presume
your 16 color file is a 4bit TIFF image.

When converted t 24bit, and then back to 8bit for final display through
mapserver some colors are lost in the 24bit->8bit color compression
logic.  Overall performance suffers because of the extra work expanding
and recompressing the data.

I could add futher special cases to GDAL (as I have done for 1 bit) to
handle 2 bit and 4 bit TIFF files, but in this situation you are likely
just as well off to expand the file to 8bit yourself using external
tools.

Best regards,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent





More information about the MapServer-users mailing list