[gdal-dev] Proper parameters for GDALBeginAsyncReader() for RGB images

Zermeno, Robert J CIV NAVAIR, 472100D robert.zermeno at navy.mil
Thu Jun 17 11:03:18 EDT 2010


Thanks Frank!

It made a lot of sense.  My last comment concerning this function is how would you be able to 
Acquire a smaller image size of a larger image using GDALBeginAsyncReader() for RGB images?

I can get it to work for Grayscale, but using the same parameters for RGB gives me an AccessViolation
Error.

Example:
Example not exact: 
Assume:
ImageWidth = 800
ImageHeight = 400
BufferXSize = 150
BufferYSize = 150
colorScheme = 3 (For RGB)
Bandmap[0] = 1, Bandmap[1] = 2, Bandmap[2] = 3
BYTE* JPIP_Buffer = (BYTE*)CLPMalloc(BufferXSize * BufferYSize * colorScheme) 


Call to function:

GDALBeginAsyncReader(fileDataset,
	0, 0, 				//Start at top-left position
	ImageWidth, ImageHeight,	//Note, I am requesting whole image.
	JPIP_Buffer,
	BufferXSize,
	BufferYSize,
	GDT_Byte,
	colorScheme,
	Bandmap,
	0,
	0,
	0,
	0);


Under the hood, how does the function take the original image size and scale it down to fit
Into the a size much smaller than original? For some reason, when I do this for RGB color 
Images, it gives a AccessViolation error when it calls GDALARGetNextUpdatedRegion().  However,
For Grayscale images, it works fine.  What would you think might be the problem?

Thanks,

Robert

-----Original Message-----
From: fwarmerdam at gmail.com [mailto:fwarmerdam at gmail.com] On Behalf Of Frank Warmerdam
Sent: Wednesday, June 16, 2010 10:05
To: Zermeno, Robert J CIV NAVAIR, 472100D
Cc: gdal-dev at lists.osgeo.org
Subject: Re: [gdal-dev] Proper parameters for GDALBeginAsyncReader() for RGB images

On Wed, Jun 16, 2010 at 12:51 PM, Zermeno, Robert J CIV NAVAIR, 472100D <robert.zermeno at navy.mil> wrote:

> Do I call GDALBeginAsyncReader() three times like RasterIO?  One call 
> for Red, one for Blue, and Green?

Robert,

The AsyncReader API allows reading multiple bands in one pass, much like the RasterIO call on the GDALDataset.

> Am I correct so far?  For the Length of Buffer where I want to place 
> the bytes, Should I have the parameter as  (xSize * 
> GDALGetRasterCount(fileDataset) )

This is correct,

> On to
> GDALBeginAsyncReader(fileDataset,
>        0, 0,                           //Start at top-left position
>        BufferXSize, BufferYSize,
>        JPIP_Buffer,
>        BufferXSize * colorScheme,
>        BufferYSize,
>        GDT_Byte,
>        colorScheme,
>        Bandmap,
>        0,
>        0,
>        0,
>        0);

I think the problem is your passing of BufferXSize * colorScheme.
That arguments should be the number of pixels in X, but not taking in account the number of bands.

> How is the image data stored in JPIP_Buffer. Whould it be:
> 1.rgbrgbrgbrgb
> 2.rrrrggggbbbb
> 3.bgrbgrbgrbgr

By default (if all zero for the interleaving options) the image will be returned in band sequential form.  So option '2' above.

Best regards,
-- 
---------------------------------------+--------------------------------
---------------------------------------+------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4926 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/gdal-dev/attachments/20100617/d425c4e4/smime.bin


More information about the gdal-dev mailing list