[Gdal-dev] Reading Raster Data using GDAL

Ayman Kamal kamal_jo at yahoo.com
Tue Feb 18 13:18:51 EST 2003


I added the following code at the end of the for loop
that loops through the bands,
The case that I have is a 1 band image (gray scale
bitmap)

There was data writeen to the file, but it seemed to
be rubish, can u help me?

//-----------------------------------------------------
      char *pafScanlines;
      int   nXSize = poVRTBand->GetXSize();
      int   nYSize = poVRTBand->GetYSize();
      
      pafScanlines = (char *)
CPLMalloc(sizeof(float)*nXSize*nYSize);
      poVRTBand->RasterIO(GF_Read, 0, 0, nXSize,
nYSize, 
         pafScanlines, nXSize, nYSize, GDT_Byte, 
         0, 0 );

      
      FILE* pStream;
      pStream = fopen("new.bmp","w");
      fwrite(pafScanlines,nXSize*nYSize,1 ,pStream);
      fclose(pStream);
      
      //-----------------------------------------------

__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com



More information about the Gdal-dev mailing list