[gdal-dev] Problem using image bands

Even Rouault even.rouault at mines-paris.org
Fri Oct 19 05:41:59 PDT 2012


Selon jcurru <jcurru at yahoo.es>:

> Hello!
>
> I have a problem reading an ECW image. I want to read the image using only
> the first band. So I use:
> int bmap[3] = {1,1,1};
> 		GDALImage->RasterIO(
> 			GF_Read,
> 			x,       		// int nXOff,
> 			y,       		// int nYOff,
> 			dx, 	     	// int nXSize,
> 			dy, 	     	// int nXSize,
> 			buffer,		 	// void* pData,
> 			xBufSize,       // int nBufXSize,
> 			yBufSize,       // int nBufYSize,
> 			GDT_Byte,	 	// GDALDataType eBufType,
> 			3,			 	// int nBandCount,
> 			bmap,		 	// int* panBandMap,
> 			3,			 	// int nPixelSpace,
> 			xBufSize * 3,   // int nLineSpace,
> 			1			 	// int nBandSpace
> 			);
> This is working well with some ECW images (they show as grayscale) but it
> does not with another, big ECW. It shows in full RGB color, exactly the same
> as if I had written int bmap[3] = {1,2,3};

I suppose you are using the 3.3 version of the ECW SDK ? Then, it is a known
issue in the SDK itself. See http://trac.osgeo.org/gdal/ticket/4234 . A work
around has been committed in the GDAL 2.0dev version just a few days ago.

For currently released GDAL versions, if you only want to read one band, you
could just use RasterIO() on the band object, instead of the whole dataset. If
you need to read it into a RGB buffer, you just need to keep the pixel space and
line space you've used in the above call, and after calling RasterIO() on the
band, do a loop to copy each buffer[3*i] value into buffer[3*i+1] and
buffer[3*i+2]

>
> Any idea?
> Thanks in advance!
>
>
>
> --
> View this message in context:
> http://osgeo-org.1560.n6.nabble.com/Problem-using-image-bands-tp5009873.html
> Sent from the GDAL - Dev mailing list archive at Nabble.com.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>




More information about the gdal-dev mailing list