GDALDriver * poDriver; char *pszFormat=GetOutimgInfo(m_strInput); poDriver = GetGDALDriverManager()->GetDriverByName(pszFormat); char* GetOutimgInfo(CString& Outimg) { // GDAL 内部对各种格式自定义的表示符 char *pszFileSName[]={ "VRT",//: Virtual Raster "GTiff",//: GeoTIFF "NITF",//: National Imagery Transmission Format "HFA",//: Erdas Imagine Images (.img) "ELAS",//: ELAS "AAIGrid",//: Arc/Info ASCII Grid "DTED",//: DTED Elevation Raster "PNG",//: Portable Network Graphics "JPEG",//: JPEG JFIF "MEM",//: In Memory Raster "GIF",//: Graphics Interchange Format (.gif) "BSB",//: Maptech BSB Nautical Charts "XPM",//: X11 PixMap Format "BMP",//: MS Windows Device Independent Bitmap "PCIDSK",//: PCIDSK Database File "HDF4Image",//: HDF4 Dataset "PNM",//: Portable Pixmap Format (netpbm) "ENVI",//: ENVI .hdr Labelled "EHdr",//: ESRI .hdr Labelled "PAux",//: PCI .aux Labelled "MFF",//: Atlantis MFF Raster "MFF2",//: Atlantis MFF2 (HKV) Raster "BT",//: VTP .bt (Binary Terrain) 1.3 Format "FIT",//: FIT Image "OTHER"}; / 各种文件格式的后缀 char * pszFileExt[]={ ".vrt",//: Virtual Raster ".tif",//: GeoTIFF "????",//: National Imagery Transmission Format ".img",//: Erdas Imagine Images (.img) "????",//: ELAS "????",//: Arc/Info ASCII Grid "????",//: DTED Elevation Raster ".png",//: Portable Network Graphics ".jpg",//: JPEG JFIF "????",//: In Memory Raster ".gif",//: Graphics Interchange Format (.gif) "????",//: Maptech BSB Nautical Charts "????",//: X11 PixMap Format ".bmp",//: MS Windows Device Independent Bitmap "????",//: PCIDSK Database File ".hdf",//: HDF4 Dataset "????",//: Portable Pixmap Format (netpbm) ".hdr",//: ENVI .hdr Labelled "????",//: ESRI .hdr Labelled "????",//: PCI .aux Labelled "????",//: Atlantis MFF Raster "????",//: Atlantis MFF2 (HKV) Raster "????",//: VTP .bt (Binary Terrain) 1.3 Format "????",//: FIT Image ".other"}; /// 得到字符串的最后四个字符 CString OutFilename = Outimg; OutFilename.TrimRight(); CString pszExt = OutFilename.Right(4); char *pszFormat = "GTiff"; int loop=0; while(strcmp(pszFileSName[loop],"OTHER") != 0) { if(pszExt.CompareNoCase(pszFileExt[loop]) == 0) { pszFormat = pszFileSName[loop]; break;// } loop++; } return pszFormat; }