[gdal-dev] GDALCopyWords question

Jo Meder jomeder at ihug.co.nz
Thu Apr 3 11:42:14 PDT 2014


Hi Even,

On 3/04/2014, at 7:24 AM, Even Rouault wrote:

> you could use GDALRasterIO() that would do the conversion for you.

I was using that but changed to ReadBlock() to read files by blocks. It looks like I could use GDALRasterIO() for that but it seems a bit less straightforward.

> I think the error in your call to GDALCopyWords() is srcPixelIndex. This 
> parameter is supposed to be the number of bytes between 2 values of the source 
> buffer, but not the offset of the first value. So you should likely use :
> 
> GDALCopyWords( srcBuffer + srcPixelIndex, srcDataType, 0, &srcValue, GDT_Byte, 
> 0, 1 );

I did think to try that not long after posting my message, and it's working nicely now. The pixel offset values are more like stride values than offsets, to my mind anyway. Thanks for confirming the behaviour.

Regards,

Jo Meder


More information about the gdal-dev mailing list