[gdal-dev] IReadBlock fails on alpha band, GDAL 2

Matt Perry perrygeo at gmail.com
Fri Apr 29 05:54:58 PDT 2016


I'm seeing some errors reading reduced-resolution buffers from the
alpha band of an RGBA image.

Code and link to raster to reproduce:
https://gist.github.com/perrygeo/07ce04fe886d1c8090ab1b22d7579396


The original raster is 4 bands, 1223x1223. If I attempt to read a
734x734 buffer (or any smaller resolution) from the alpha band

    hBand = GDALGetRasterBand( hDataset, 4 );
    pafScanline = (int *) CPLMalloc(sizeof(int) * 734 * 734);
    GDALRasterIO( hBand, GF_Read, 0, 0, 1223, 1223,
                    pafScanline, 734, 734, GDT_Byte, 0, 0 );

I get

    ERROR 1: IReadBlock failed at X offset 0, Y offset 0

This DOES NOT occur if
* the buffer is 735x735 or greater
* reading bands 1, 2 or 3 to buffer of any size
* using GDAL < 2.0, seems unaffected

So far I've only reproduced on OSX but would be interested to see if
Linux exhibits the same behavior.

I'm curious why it there appears to be a buffer size threshold, why it
only affects alpha bands and why only GDAL 2.x is affected.  Before I
dig in, does anyone have any theories about what's going on here?


Thanks,
Matt Perry


More information about the gdal-dev mailing list