I am doing the same as in [GDAL API]: can't save image in some formats
That is, saving a JPEG
image with GDAL
. I know I'd have to create a MEM
buffer and then CreateCopy
to JPEG
. However, I'd like to avoid the allocation of two buffers since my image might be big and I use my own memory buffer.
Is there a way to pass the data memory address that I'd like to use to the MEM driver?
I've seen this mysterious article http://www.gdal.org/frmt_mem.html which references the DATAPOINTER
option. I've seen another reference here
which does
sprintf(filename,"MEM:::DATAPOINTER=%d,PIXELS=%d,LINES=%d,BANDS=1,DATATYPE=%d,PIXELOFFSET=0,LINEOFFSET=0,BANDOFFSET=0",datpt,pixels,lines,datatype);
dataset = GDALOpen(filename,GA_Update);
How would this translate to c++? Maybe
papszOptions = CSLSetNameValue( papszOptions, "DATAPOINTER", datapointer );
and so on?