[Geotiff] (no subject)

Frank Warmerdam warmerdam at pobox.com
Thu Sep 2 09:45:39 EDT 2004


usha devi regadi wrote:
>   how to write a 8-bit color map image in geotiff format from my native format where i have access to raw data
> 
>   i will be greateful for your prompt reply

Usha,

Writing the colormap is not really a GeoTIFF specific issue.  I would
suggest you review the libtiff documentation.

To give you an example, I use code something like this to set colortable
on a GeoTIFF or TIFF file in my GDAL library:

/* -------------------------------------------------------------------- */
/*      Write out the colortable, and update the configuration.         */
/* -------------------------------------------------------------------- */
     unsigned short	anTRed[256], anTGreen[256], anTBlue[256];

     for( int iColor = 0; iColor < 256; iColor++ )
     {
         if( iColor < poCT->GetColorEntryCount() )
         {
             GDALColorEntry  sRGB;

             poCT->GetColorEntryAsRGB( iColor, &sRGB );

             anTRed[iColor] = (unsigned short) (257 * sRGB.c1);
             anTGreen[iColor] = (unsigned short) (257 * sRGB.c2);
             anTBlue[iColor] = (unsigned short) (257 * sRGB.c3);
         }
         else
         {
             anTRed[iColor] = anTGreen[iColor] = anTBlue[iColor] = 0;
         }
     }

     TIFFSetField( poGDS->hTIFF, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE );
     TIFFSetField( poGDS->hTIFF, TIFFTAG_COLORMAP, anTRed, anTGreen, anTBlue );

Now that I re-read your message it looks like you are hoping for help on the
whole image writing process.  I would again suggest you review the libtiff
docs at http://www.remotesensing.org/libtiff.  There should be a good
link to a getting-started tutorial at the IBM DeveloperWorks web site.

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 Geotiff mailing list