[Gdal-dev] Reading Raster Data using GDAL

Ayman Kamal kamal_jo at yahoo.com
Tue Feb 18 14:21:58 EST 2003

Ok I managed finally using this piece of code to get
the raw data, but still there is one problem

but there is still one problem, the size of the file
should be
nXSize*nYSize*sizeof(unsigned char), but when I
checked the saved file it was greater than I expected.

of course I checked the size of the file and not size
on disk.

Any way and the bottom left of the image had a black

Can u help me solve this ASAP please?
      unsigned char *pafScanlines;
      int   nXSize = poVRTBand->GetXSize();
      int   nYSize = poVRTBand->GetYSize();
      GDALDataType p = poVRTBand->GetRasterDataType();
      pafScanlines = (unsigned char *)
CPLMalloc(sizeof(unsigned char )*nXSize*nYSize);
      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