[gdal-dev] GDALCreateCopy from MEM Driver

Even Rouault even.rouault at mines-paris.org
Wed Nov 21 11:56:01 PST 2012


Le mercredi 21 novembre 2012 20:49:28, Robert Zermeno a écrit :
> GDAL community,
>  
> Is is plausible to contain a RGB image array (as pixel interleaved,
> rgbrgbrgbrgb) in a single MEMRasterBand to generate a color file via
> GDALCreateCopy()? My application performs the following sequence:
>  
> 1. Read a color image into an image buffer in pixel interleaved (rgbrgbrgb)
> format. 2. Setup MEM Driver to contain the recently read in image from
> step 1 above via AddBand(). 3. Call GDALCreateCopy() on the specific
> output of my desire.
>  
> I have a question on Step 2 above (AddBand()).  Do I have to create 3
> seperate bands to contain individual color component?  That would mean I
> have to take my RGB image buffer and seperate it into three new arrays of
> size (imageWidth * imageHeight) and call AddBands() on each one. 

You need to call AddBand() 3 times for a RGB image, but you can use a single 
RGB image array. You just have to set PIXELOFFSET=3. See 
http://gdal.org/frmt_mem.html.


More information about the gdal-dev mailing list