[gdal-dev] Reading the data 'backwards'

Even Rouault even.rouault at mines-paris.org
Fri Nov 20 13:29:30 EST 2009


tasmith3 at rockwellcollins.com a écrit :

Sometimes, it is desirable for GDAL not try to be too smart ;-)

However I think you can achieve what you want if you provide the buffer 
with the right offset and a negative nLineSpace parameter. Something 
like that (untested !) :

void* pBuffer = malloc(width * height);
poBand->RasterIO(GF_Read, 0, 0, width, height, pBuffer + width * (height 
- 1), width, height, GDT_Byte, 1, -width)

>
> I work with code that handles data in a particular way.  Instead of 
> using the top-left corner as the origin, it uses the bottom left.  It 
> treats the data as if it's sitting in quadrant 1 on an X-Y plane with 
> the bottom left corner sitting on the origin.  The code expects me to 
> read in the data from the file starting with the 'first' row (the 
> bottom row) to the top row (the 'last' row) from left to right.  If my 
> image has n rows and m columns, could I do something like this...?
>
> RasterIO( GF_Read, 0, n, m, n, ...)
>
> and would GDAL be smart enough to know that since I'm placing my 
> origin at the bottom left corner, it needs to read backwards or 'up' 
> the image?  If it can't, that's ok - I'll just have to do some post 
> processing on the output buffer after the read.  Changing the code 
> around so it treats the top left corner as the origin isn't an option. 
>  I don't have that kind of authority and it'd be a massive change.
>
> Thanks,
>
> Todd
> ------------------------------------------------------------------------
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev




More information about the gdal-dev mailing list