Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#4547 closed defect (fixed)

SetColorInterpretation(GCI_PaletteIndex) doesn't work with GTiffDriver->Create()

Reported by: cleo Owned by: warmerdam
Priority: normal Milestone:
Component: GDAL_Raster Version: 1.9.0
Severity: normal Keywords: gtiff
Cc:

Description

GDALDataset *m_pDataSet = poDriver->Create(

in_fileName.c_str(), 32, 32, 1, GDT_Byte, NULL);

Then if you do:

m_pDataSet->GetBand(1)->SetColorInterpretation(GCI_PaletteIndex);

it won't give an error, but when you do GetColorInterpretation(), it returns GCI_GrayIndex. Works fine for RGB 24 and 32 bit colour though. Doesn't matter if I set the ColorInterpretation before setting the color table, after or both. It stays at GCI_GrayIndex no matter what. If I reload the newly created file, everything is fine with GCI_PaletteIndex.

Change History (2)

comment:1 by Even Rouault, 12 years ago

Resolution: fixed
Status: newclosed

r24075 /trunk/gdal/frmts/gtiff/geotiff.cpp: GTiff: set color interpretation to GCI_PaletteIndex after calling SetColorTable() (#4547)

This is a partial fix, but there's not much more that we can do. SetColorInterpretation() on the GTiff driver only really work on alpha bands. The color interpretation is dedecuded from the TIFF Photometric TAG, the presence of color table and the value of the ExtraSamples tag.

comment:2 by cleo, 12 years ago

Perfect! Thanks for looking into it. Main concern is expected behaviour. If SetColorTable() sets the proper color interpretation, that means no special case on our end. Also, thanks for the explanation on SetColorInterpretation().

Note: See TracTickets for help on using tickets.