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

2016-06-06 Thread Pol Monsó Purtí
Hello Even, The CPLPrintPointer did the trick! Everything is working, excellent! You resolved the issue. And moreover I'm more comfortable with the Create function rather than the CPLOpen. I am very grateful for your help. ___ gdal-dev mailing list gd

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

2016-06-06 Thread Pol Monsó Purtí
Thanks Even, the previous message was prematurely sent by error and the corrected version held because it was to big (? probably a mishap with the mail headers) Yeah the numbands are 0. I stripped out irrellevant parts of code and I missed to add that. To be sure I checked with the debugger, the d

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

2016-06-06 Thread Even Rouault
See comments inline below > > The code: > > > GDALDriver *poDriver = > GetGDALDriverManager()->GetDriverByName(pszFormat); > > > if(!poDriver) > > { > > std::cerr << "Driver " << pszFormat << " couldn't be loaded." > << std::endl; > > return -4; > > } > >

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

2016-06-06 Thread Pol Monsó Purtí
Same result. The code: GDALDriver *poDriver = GetGDALDriverManager()->GetDriverByName(pszFormat); if(!poDriver) { std::cerr << "Driver " << pszFormat << " couldn't be loaded." << std::endl; return -4; } poDstDS = poDriver->Create( auxfilepath.string()

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

2016-06-06 Thread Even Rouault
On Monday 06 June 2016 14:53:46 Pol Monsó Purtí wrote: > Let's jump to particulars, at the end, the code. > > If I set the DATAPOINTER to NULL the program crashes at CreateCopy with > access violation. Same if I set it to the datapointer to &abyRaster[0] and > add the remaining two bands. Use the

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

2016-06-06 Thread Pol Monsó Purtí
Let's jump to particulars, at the end, the code. If I set the DATAPOINTER to NULL the program crashes at CreateCopy with access violation. Same if I set it to the datapointer to &abyRaster[0] and add the remaining two bands. The abyRasters are initialized to white color with memset. SO this piece

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

2016-06-06 Thread Pol Monsó Purtí
Just one more question, If i set the option BAND=0, what should the DATAPOINTER be? Does it become optional? Cheers On Mon, Jun 6, 2016 at 10:55 AM, Even Rouault wrote: > On Monday 06 June 2016 10:45:47 Pol Monsó Purtí wrote: > > THanks Mateusz, > > > > You're right. I'm trying it as we speak.

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

2016-06-06 Thread Mateusz Loskot
On 6 June 2016 at 10:57, Pol Monsó Purtí wrote: > On Mon, Jun 6, 2016 at 10:51 AM, Mateusz Loskot wrote: >> >> On 6 June 2016 at 10:45, Pol Monsó Purtí wrote: >> > >> > In my case I have a std::vector of the 3 bands, where the >> > GByte* are >> > allocated in the heap with new GByte[width*heig

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

2016-06-06 Thread Pol Monsó Purtí
> > The MEM format is one of the few that supports the AddBand() method. The > AddBand() method supports DATAPOINTER, PIXELOFFSET and LINEOFFSET options > to reference an existing memory array. > Thanks Even, you've cured me from my blindness. That's exactly what I need. Thanks to all of you, this

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

2016-06-06 Thread Pol Monsó Purtí
On Mon, Jun 6, 2016 at 10:51 AM, Mateusz Loskot wrote: > On 6 June 2016 at 10:45, Pol Monsó Purtí wrote: > > > > In my case I have a std::vector 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

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

2016-06-06 Thread Even Rouault
On Monday 06 June 2016 10:45:47 Pol Monsó Purtí wrote: > THanks Mateusz, > > You're right. I'm trying it as we speak. > > In my case I have a std::vector 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 ha

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

2016-06-06 Thread Mateusz Loskot
On 6 June 2016 at 10:45, Pol Monsó Purtí wrote: > > In my case I have a std::vector 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 s

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

2016-06-06 Thread Pol Monsó Purtí
THanks Mateusz, You're right. I'm trying it as we speak. In my case I have a std::vector 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? I guess the only soluti

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

2016-06-03 Thread Mateusz Loskot
On 3 June 2016 at 20:45, Pol Monsó Purtí wrote: > I've seen this mysterious article http://www.gdal.org/frmt_mem.html which > references the `DATAPOINTER` option. I've seen another reference > [here](https://lists.osgeo.org/pipermail/gdal-dev/2006-November/010583.html) > which does > > > sprintf(f

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

2016-06-03 Thread Pol Monsó Purtí
I've posted this question on gis stackexchange, but maybe here is more appropriate. I am doing the same as in http://gis.stackexchange.com/questions/134000/gdal-api-cant-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 `Creat