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