[gdal-dev] Interleave Bands with RasterIO?
Adam Nowacki
nowak at xpam.de
Sun Oct 19 01:28:30 EDT 2008
int bands[4] = { 3, 2, 1, 4 };
GDALDataset::RasterIO(..., 4, bands, 32, 32 * xSize, 1);
but then you probably mixed bits with bytes so:
int bands[4] = { 3, 2, 1, 4 };
GDALDataset::RasterIO(..., 4, bands, 4, 4 * xSize, 1);
craig.miller at spatialminds.com wrote:
> I have a BGRA buffer in memory, and a multi-band RGBA TIF image. Is it
> possible to use RasterIO to read in values from each band and neatly
> interleave them in my buffer.
>
> For example if I was loading an RGBA image I am hoping to be able to
> make 4 separate RasterIO calls.
>
> Assuming a BGRA image looks like:
>
> 0 - blue byte
> 8 - green byte
> 16 - red byte
> 24 - alpha byte
> 32 - blue byte
> 40 - green byte
> 48 - red byte
> 56 - alpha byte
> 64 - ....
>
> The first RasterIO call would read in the blue values and insert them at
> 0, 32, 64, etc making it look like:
>
> 0 - blue byte
> 8 -
> 16 -
> 24 -
> 32 - blue byte
> 40 -
> 48 -
> 56 -
> 64 - ....
>
> The second RasterIO call would read the green values and insert them at
> 8, 40, etc making it look like:
>
> 0 - blue byte
> 8 - green byte
> 16 -
> 24 -
> 32 - blue byte
> 40 - green byte
> 48 -
> 56 -
> 64 - ....
>
> Rinse and repeat for red and alpha.
>
> Is this possible, or is there a much much simpler way that I'm
> overlooking? I've been looking at the paramaters for RasterIO but can't
> seem to get it to work. I do understand that I can just read the values
> into a separate buffer and memcpy them over to my image buffer. I was
> trying to minimize the total number of times the same data has to be copied.
>
> Thanks for the help.
>
> Craig
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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