[FWTools] Error when reading data from an image

Frank Warmerdam warmerdam at pobox.com
Sun Jun 14 21:41:00 EST 2009


Aurora Sánchez Fernández wrote:
> 
> Hi,
> 
> First of all, thanks to everyone who is there helping solving the 
> problems we have..
> 
> I'm quite new using GDAL and just realized that when I'm reading the 
> data of an image, all I get are nulls.. This is the code I'm using:
> 
>     float* rasterData;
>     nXSize = GDALGetRasterBandXSize( hBand );
> 
>     rasterData = (float *) CPLMalloc(sizeof(float)*nXSize/2);
>     GDALRasterIO(hBand, GF_Read, 
> 0,0,nXSize,1,rasterData,nXSize,1,GDT_Float32, 0, 0 );
> 
> I got it from an example and thought that everything was working on 
> well.. I have tried with different data types, not only float, but I 
> always get zeros in all positions of rasterData. The image I'm reading 
> is a TIFF image. Any one has an idea of what is happening??

Aurora,

I'm not sure why you divide the size by two in the CPLMalloc().  I would
expect this to result in the buffer being too small, and thus heap
corruption in the GDALRasterIO() call.  Otherwise everything looks reasonable
for reading the first scanline of this band.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the FWTools mailing list