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@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to