[gdal-dev] Fwd: How to reuse memory pointer of GDAL Memory driver

Pol Monsó Purtí lluna.nova at gmail.com
Mon Jun 6 01:57:30 PDT 2016


On Mon, Jun 6, 2016 at 10:51 AM, Mateusz Loskot <mateusz at loskot.net> wrote:

> On 6 June 2016 at 10:45, Pol Monsó Purtí <lluna.nova at gmail.com> wrote:
> >
> > In my case I have a std::vector<GByte*> of the 3 bands,  where the
> GByte* are
> > allocated in the heap with new GByte[width*height].
> > I guess that won't work
> > because the three bands have to be one single memory chunk, am I right?
>
> vector allocates is single continuous block of memory.
> ...or I don't understand the problem.
>

The std::vector has 3 GByte* elements. The three pointers will reside
contiguous, but the memory they are pointing to (containing the R,G and B
data) don't necessarily have to be.

I guess BANDS=3 makes the bands contiguous in memory


>
> > I guess the only solution is to switch to single band float and merge
> rgb to
> > float. I'd prefer not having to refactor the rest of the code. Is it
> > possible to have a different address for each band?
>
> I might not know all GDAL tricks, but I don't think it is possible.
>
> Best regards,
> --
> Mateusz Loskot, http://mateusz.loskot.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20160606/4155fa96/attachment.html>


More information about the gdal-dev mailing list