Changeset 11848
- Timestamp:
- 08/07/07 02:29:31 (1 year ago)
- Files:
-
- trunk/gdal/frmts/gtiff/geotiff.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/gdal/frmts/gtiff/geotiff.cpp
r11843 r11848 2044 2044 /* Do we have a palette? If so, create a TIFF compatible version. */ 2045 2045 /* -------------------------------------------------------------------- */ 2046 unsigned short anTRed[65536], anTGreen[65536], anTBlue[65536];2046 std::vector<unsigned short> anTRed, anTGreen, anTBlue; 2047 2047 unsigned short *panRed=NULL, *panGreen=NULL, *panBlue=NULL; 2048 2048 … … 2055 2055 else 2056 2056 nColors = 65536; 2057 2058 anTRed.resize(nColors,0); 2059 anTGreen.resize(nColors,0); 2060 anTBlue.resize(nColors,0); 2057 2061 2058 2062 for( int iColor = 0; iColor < nColors; iColor++ ) … … 2074 2078 } 2075 2079 2076 panRed = anTRed;2077 panGreen = anTGreen;2078 panBlue = anTBlue;2080 panRed = &(anTRed[0]); 2081 panGreen = &(anTGreen[0]); 2082 panBlue = &(anTBlue[0]); 2079 2083 } 2080 2084 … … 4104 4108 && eType == GDT_UInt16 ) 4105 4109 { 4106 unsigned short anTRed[65536], anTGreen[65536], anTBlue[65536];4110 unsigned short *panTRed, *panTGreen, *panTBlue; 4107 4111 GDALColorTable *poCT; 4112 4113 panTRed = (unsigned short *) CPLMalloc(65536*sizeof(unsigned short)); 4114 panTGreen = (unsigned short *) CPLMalloc(65536*sizeof(unsigned short)); 4115 panTBlue = (unsigned short *) CPLMalloc(65536*sizeof(unsigned short)); 4108 4116 4109 4117 poCT = poSrcDS->GetRasterBand(1)->GetColorTable(); … … 4117 4125 poCT->GetColorEntryAsRGB( iColor, &sRGB ); 4118 4126 4119 anTRed[iColor] = (unsigned short) (256 * sRGB.c1);4120 anTGreen[iColor] = (unsigned short) (256 * sRGB.c2);4121 anTBlue[iColor] = (unsigned short) (256 * sRGB.c3);4127 panTRed[iColor] = (unsigned short) (256 * sRGB.c1); 4128 panTGreen[iColor] = (unsigned short) (256 * sRGB.c2); 4129 panTBlue[iColor] = (unsigned short) (256 * sRGB.c3); 4122 4130 } 4123 4131 else 4124 4132 { 4125 anTRed[iColor] = anTGreen[iColor] =anTBlue[iColor] = 0;4133 panTRed[iColor] = panTGreen[iColor] = panTBlue[iColor] = 0; 4126 4134 } 4127 4135 } … … 4129 4137 if( !bForcePhotometric ) 4130 4138 TIFFSetField( hTIFF, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE ); 4131 TIFFSetField( hTIFF, TIFFTAG_COLORMAP, anTRed, anTGreen, anTBlue ); 4139 TIFFSetField( hTIFF, TIFFTAG_COLORMAP, panTRed, panTGreen, panTBlue ); 4140 4141 CPLFree( panTRed ); 4142 CPLFree( panTGreen ); 4143 CPLFree( panTBlue ); 4132 4144 } 4133 4145 else if( poSrcDS->GetRasterBand(1)->GetColorTable() != NULL )
