<DIV>Thk u for your answer.</DIV>
<DIV>1.I have change the following code:</DIV>
<DIV>for(int i=1;i<=nY;i++)</DIV>
<DIV>to</DIV>
<DIV>for(int i=0;i<nY;i++)</DIV>
<DIV>but the problem still exists(CPU is very busy).</DIV>
<DIV>2.the function GDALDatasetCopyWholeRaster can not satisfy me,for I want to do the follow things:</DIV>
<DIV>read Srcband1,Srcband2,</DIV>
<DIV>Dstband1=Srcband1 +Srcband2;</DIV>
<DIV>that is,I want to do some computing after readding data.</DIV>
<DIV>Kind regards.<BR></DIV>
<DIV></DIV><BR><PRE><BR>>The RasterIO parameters are not correct.
>
>Try instead :
> poSrcBand->RasterIO(GF_Read,0,i,nX,1,pafScanline,nX,1,GDT_Float32,0,0);
> poDstBand->RasterIO(GF_Write,0,i,nX,1,pafScanline,nX,1,GDT_Float32,0,0);
>
>The 'for(int i=1;i<nY;i++)' loop is not correct. The starting value of i
>should be 0.
>
>Ther's also a leak of the *pafScanline buffer.
>
>But if I were you, I'd use the following function to do the copy of the
>imagery :
>
>CPLErr CPL_DLL CPL_STDCALL GDALDatasetCopyWholeRaster(
> GDALDatasetH hSrcDS, GDALDatasetH hDstDS, char **papszOptions,
> GDALProgressFunc pfnProgress, void *pProgressData );
>
>Le Sunday 11 April 2010 08:32:51 weixj2003ld, vous avez ¨¦crit :
>> I use the following code to read data from a geotiff file and write it into
>> a new one.the bands number is 6; ...
>> GDALDataset *poSrcDS,*poDstDS;//poSrcDs:the source file,poDstDS:the goal
>> source GDALRasterBand *poSrcBand,*poDstBand;//poSrcBand:the source
>> band,poDstBand:the goal band GDALDriver *poDstDriver;
>> double *m_AdGeoTransform=new double[6];
>>
>> ...
>> poDstDriver=GetGDALDriverManager()->GetDriverByName(poSrcDS->GetDriver()->G
>>etDescrition());
>> poDstDS=poDstDriver->create(DstFilename,nX,nY,6,GDT_Float32,NULL);
>> poSrcDS->GetGeoTransform(m_AdGeoTransform)
>> poDstDS->SetGeoTransform(m_AdGeoTransform);
>> poDstDS->SetProjection(poSrcDS->GetProjectionRef());
>>
>> for(int iBand=0;iBand<6;iBand++)
>> {
>> poSrcBand=poSrcDS->GetRaserBand(iBand+1);
>> poDstBand=poDstDS->GetRaserBand(iBand+1);
>> float *pafScanline;
>> pafScanline=(float *)CPLMalloc(sizeof(float)*nX;
>> for(int i=1;i<nY;i++)
>> {
>>
>> poSrcBand->RasterIO(GF_Read,0,0,nX,i,pafScanline,nX,1,GDT_Float32,0,0);
>> poDstBand->RasterIO(GF_Write,0,0,nX,i,pafScanline,nX,1,GDT_Float32,0,0);//I
>>f I comment this code,the program will be ok. }
>> }
>> GDALClose((GDALDatasetH)poDstDS);
>>
>> When I run my program,CPU is very alway busy,and the program is
>> blocked,why?
>
>
</PRE><br><br><span title="neteasefooter"/></span>