[gdal-dev] Incorrect use of MEM driver?
Gregory, Matthew
matt.gregory at oregonstate.edu
Fri Jun 5 15:51:20 EDT 2009
Hi all,
I'm a newbie to the MEM driver using Windows and trying to get it to
work using a very simple test:
///////////////
int main()
{
GDALAllRegister();
// Create space and populate with pattern
GInt32 buf[10000];
for (int i=0; i<10000; i++)
*(buf+i) = i%32;
// Create the MEM GDALDataset
char* filename = new char[1024];
sprintf(filename,
"MEM:::DATAPOINTER=%p,PIXELS=100,LINES=100,DATATYPE=Int32", buf);
GDALDataset* srcDS = (GDALDataset*) GDALOpen(filename,
GA_ReadOnly);
// Grab a chunk of data from the dataset
GDALRasterBand* rb = srcDS->GetRasterBand(1);
GInt32 buf2[100];
rb->RasterIO( GF_Read, 0, 0, 10, 10, buf2, 10, 10, GDT_Int32, 0,
0);
}
///////////////
The RasterIO call fails, but through debugging I'm seeing that pabyData
in MEMDataset::Open is never receiving the correct pointer to the data
from the CPLScanPointer call (line 702 in memdataset.cpp). I'm likely
doing something very stupid in my initial setup, so please let me know
if this is the case ...
My pointer address is something like 0x00126324. When formatted into
the filename string, it becomes 00126324 (without the '0x'). Then, in
CPLScanPointer, it skips the MS specific code (lines 877-886) and calls
CPLScanULong which returns 126324, which I think is causing the bad
pointer.
Thanks for help, matt
More information about the gdal-dev
mailing list