[Gdal-dev] colortable: unwanted increase of colors

Chris cb at delta-h.de
Fri Dec 2 10:39:30 EST 2005


Hello!

When I use gdal to copy an existing .tif file, which has two colors in 
it's colortable, the copy gets 256 colors, which has the nasty 
side-effect of larger files and slower performance (while displaying the 
file in my app).

How can I save a copy with exactly the same colortable as my original file?

Attached you find the method I use, stripped to the minimum.

Thanks in advance!

Chris

---8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<----

void SaveAs(const std::string& origFile, const std::string& fname)
{
    GDALAllRegister();
    GDALDataset  *poDataset = (GDALDataset *) GDALOpen( 
origFile.c_str(), GA_ReadOnly );

    GDALDataset* poDstDS =
        poDataset->GetDriver()->CreateCopy(
                fname.c_str(),
                poDataset,
                FALSE,
                NULL,
                GDALTermProgress,
                NULL);
    delete poDstDS;
}





More information about the Gdal-dev mailing list