[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

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 *)
      poVRTBand->RasterIO(GF_Read, 0, 0, nXSize,
         pafScanlines, nXSize, nYSize, GDT_Byte, 
         0, 0 );

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

Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day

More information about the Gdal-dev mailing list