[Gdal-dev] Windows CE - GDALDatasetRasterIO error

jetelus at centrum.cz jetelus at centrum.cz
Mon Nov 5 03:57:43 EST 2007


>jetelus at centrum.cz wrote:
>>>> Hi, I open and display raster without problems but when I
>>>> try zooming I get CE_Failure from GDALDatasetRasterIO with
>>>> this error message using GDAL 1.4.2:
>>>>
>>>> "Assertion `nLockCount == 0' failed in file `..\..\..\gcore
>>>> \gdalrasterblock.cpp', line 219"
>>>> (and app crashs)
>>>>
>>>> and this error message using GDAL 1.4.3:
>>>>
>>>> "Out of memory allocating 59765 byte raster cache block."
>>>> (its little better becasuse app doesnt crash)
>>>>
>>>> RASTER INFO:
>>>> bpp: 1
>>>> compression: LZW
>>>> resolution: 11953 x 10268.
>>>> file size: 658kB
>>>>
>>>> When I convert this raster to 4 bits per pixel everything
>>>> is ok and I get no errors but raster file size grows to
>>>> 1.7MB. Any ideas? Thx.
>>>
>>>I don't know what device you have but you're trying to open ~120 MB
>>>raster in one shot, on mobile device.
>>>The error message is clear to me, you're dealing without of memory issue.
>>>
>>>IMHO, it's not a good idea to feed mobile device with images of that
>>>big. Better tile them into smaller pieces, use zoom levels, etc.
>>>GDAL for Windows CE gives you with tools to solve this problem.
>>>
>>>Keep in mind that "GDAL for Windows CE" does not mean you can use all
>>>GDAL features on a mobile device the same way as on normal workstation.
>>>There are obvious hardware limitations you can not overcome.
>>>
>>>Cheers
>>>--
>>>Mateusz Loskot
>>>http://mateusz.loskot.net
>>>
>>
>> Thank you, I understand but why it works with 4 bpp version of same raster
>> which is even bigger?
>
>You wrote that you don't get any errors, but does it mean you can load it
>and display?
>
>Perhaps there is a bug, we can not exclude this option :-)
>If you want, you can send me your image file and piece of code presenting
>what are you doing exactly, then I will be able to investigate the problem.
>
>Cheers
>-- 
>Mateusz Loskot
>http://mateusz.loskot.net
>

Yes, I can load and display image. I get this error only when zooming.
(and no errors at all for 4bpp version)

I have this code:
(Windows Mobile 2003 Second Edition)

 --------------------------------------------------------------------------------
 ...
 int panBandMap[1];
 panBandMap[0] = 1;

 unsigned char* pData = (unsigned char*) malloc(nBufXSize * nBufYSize);

 if (!pData)
 {
	CString msg("Not enough memory.");
	TRACE(msg);
	MessageBox(NULL,msg,NULL,0);
	return false;
 }

 CPLErr e=GDALDatasetRasterIO(HDataset, GF_Read, nXOff, nYOff, nXSize, nYSize,
        pData, nBufXSize, nBufYSize, GDT_Byte, 1, panBandMap, 1, nBufXSize, 1);

 if (e != CE_None)
 {
        free(pData);
	CString msg(CPLGetLastErrorMsg());
	TRACE(msg);
	MessageBox(NULL,msg,NULL,0);
        return false;
 }
 ...
 show loaded raster
 ...
 free(pData);
 --------------------------------------------------------------------------------

works for whole image:

nXOff = 0
nYOff = 0
nXSize = 11953
nYSize = 10268
nBufXSize = 224
nBufYSize = 192

gives "Out of memory allocating 59765 byte raster cache block." for
raster part (same for similar areas when zooming):

nXOff = 3011
nYOff = 1571
nXSize = 7115
nYSize = 6561
nBufXSize = 248
nBufYSize = 228

Image is here (450kB):

http://rapidshare.com/files/67552472/tif_lzw.rar.html

Thx for your time.




More information about the Gdal-dev mailing list