Changeset 11849
- Timestamp:
- 08/07/07 02:37:45 (1 year ago)
- Files:
-
- branches/1.4/gdal/frmts/gtiff/geotiff.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.4/gdal/frmts/gtiff/geotiff.cpp
r11821 r11849 1956 1956 /* Do we have a palette? If so, create a TIFF compatible version. */ 1957 1957 /* -------------------------------------------------------------------- */ 1958 unsigned short anTRed[65536], anTGreen[65536], anTBlue[65536];1958 std::vector<unsigned short> anTRed, anTGreen, anTBlue; 1959 1959 unsigned short *panRed=NULL, *panGreen=NULL, *panBlue=NULL; 1960 1960 … … 1967 1967 else 1968 1968 nColors = 65536; 1969 1970 anTRed.resize(nColors,0); 1971 anTGreen.resize(nColors,0); 1972 anTBlue.resize(nColors,0); 1969 1973 1970 1974 for( int iColor = 0; iColor < nColors; iColor++ ) … … 1986 1990 } 1987 1991 1988 panRed = anTRed;1989 panGreen = anTGreen;1990 panBlue = anTBlue;1992 panRed = &(anTRed[0]); 1993 panGreen = &(anTGreen[0]); 1994 panBlue = &(anTBlue[0]); 1991 1995 } 1992 1996 … … 3876 3880 && eType == GDT_UInt16 ) 3877 3881 { 3878 unsigned short anTRed[65536], anTGreen[65536], anTBlue[65536];3882 unsigned short *panTRed, *panTGreen, *panTBlue; 3879 3883 GDALColorTable *poCT; 3884 3885 panTRed = (unsigned short *) CPLMalloc(65536*sizeof(unsigned short)); 3886 panTGreen = (unsigned short *) CPLMalloc(65536*sizeof(unsigned short)); 3887 panTBlue = (unsigned short *) CPLMalloc(65536*sizeof(unsigned short)); 3880 3888 3881 3889 poCT = poSrcDS->GetRasterBand(1)->GetColorTable(); … … 3889 3897 poCT->GetColorEntryAsRGB( iColor, &sRGB ); 3890 3898 3891 anTRed[iColor] = (unsigned short) (256 * sRGB.c1);3892 anTGreen[iColor] = (unsigned short) (256 * sRGB.c2);3893 anTBlue[iColor] = (unsigned short) (256 * sRGB.c3);3899 panTRed[iColor] = (unsigned short) (256 * sRGB.c1); 3900 panTGreen[iColor] = (unsigned short) (256 * sRGB.c2); 3901 panTBlue[iColor] = (unsigned short) (256 * sRGB.c3); 3894 3902 } 3895 3903 else 3896 3904 { 3897 anTRed[iColor] = anTGreen[iColor] =anTBlue[iColor] = 0;3905 panTRed[iColor] = panTGreen[iColor] = panTBlue[iColor] = 0; 3898 3906 } 3899 3907 } … … 3901 3909 if( !bForcePhotometric ) 3902 3910 TIFFSetField( hTIFF, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE ); 3903 TIFFSetField( hTIFF, TIFFTAG_COLORMAP, anTRed, anTGreen, anTBlue ); 3911 TIFFSetField( hTIFF, TIFFTAG_COLORMAP, panTRed, panTGreen, panTBlue ); 3912 3913 CPLFree( panTRed ); 3914 CPLFree( panTGreen ); 3915 CPLFree( panTBlue ); 3904 3916 } 3905 3917 else if( poSrcDS->GetRasterBand(1)->GetColorTable() != NULL )
