/**
* BaseProcesses是我自己封装的一个函数,大家使用正常GDAL API即可,功能都是一样的
**/
Gdal.AllRegister();
BaseProcesses.GdalRegister();
Dataset ds ;
Dataset dd;
int strict = 0;
int xsize;
int ysize;
int iBandNumRef;
string sBandDataType;
double[] dGeoTransform;
string sGeoProjectionRef;
string [] options=new string[]{"TILED=YES", "COMPRESS=LZW"};
string path = "D:\\hxl\\yasuotest\\cptest3.tif";
BaseProcesses.OpenImage(out ds,"D:\\hxl\\yasuotest\\610325201610190000006256250160001.tif");
BaseProcesses.GetBaseInforOfImage(ds, out xsize, out ysize, out iBandNumRef, out sBandDataType, out dGeoTransform, out sGeoProjectionRef);
Driver di = ds.GetDriver();
di.CreateCopy(path, ds, strict, options, null, null);
BaseProcesses.OpenImage(out dd, path);
for (int i = 1; i <= ds.RasterCount;i++)
{
int[] dataarry = new int[xsize*ysize];
ds.GetRasterBand(i).ReadRaster(0, 0, xsize, ysize, dataarry, xsize, ysize,0,0);
dd.GetRasterBand(i).WriteRaster(0, 0, xsize, ysize, dataarry, xsize, ysize, 0, 0);
}
dd.FlushCache();
dd.Dispose();