Hi Even,

Thanks very much for your assistance.  I think I'm understanding this better 
now.  I've changed the relevant portion of the code to what I've copied in here 
and it seems to work now.  I do admit that I'm finding it hard to get my head 
around all this so I'd be grateful if somebody could let me know if I've done 
anything wrong (code below).  It appears to work correctly with all the images 
I've tried so far.

                psWarpOptions->nBandCount = GDALGetRasterCount(hSrcDS);
                psWarpOptions->panSrcBands = (int *) CPLMalloc(sizeof(int) * 
psWarpOptions->nBandCount );
                psWarpOptions->panDstBands = (int *) CPLMalloc(sizeof(int) * 
psWarpOptions->nBandCount );
                
                for ( int i = 0; i < psWarpOptions->nBandCount; i++ )
                {
                        psWarpOptions->panSrcBands[i] = i+1;
                        psWarpOptions->panDstBands[i] = i+1;
                }

In any case, I'm very grateful to the people who've developed GDAL and who are 
supporting it so well.  I'll certainly be donating using the button at 
http://www.osgeo.org/ as soon as I make anything from my new application.


On 24/09/2012, at 7:47 PM, Even Rouault <even.roua...@mines-paris.org> wrote:

> Selon Nik Sands <nix...@nixanz.com>:
> 
>> My application is doing a warp using GDAL which works fine for some source
>> images, but with others results in an image with the colours all wrong (eg,
>> water areas are red instead of blue).  I'm guessing that the RGB(A) (bands?)
>> are getting mixed up somehow, but I really don't know where to start looking
>> after my web searches produced nothing useful.
>> 
>> The problem only occurs for some images.  So far the only thing that the
>> problem source images have in common is that they were all converted from ECW
>> to GeoTIFF by 'gdal_translate' (with no options).  The source GeoTIFF files
>> have all the correct colours before the warp.
>> 
>> The code I'm using is based on the GDAL warp API tutorial and is included
>> below.
>> 
>> I'd be grateful if somebody could point me in the right direction.
> 
> The following snippet only works for single band images. If you have 
> presumably
> RGB images, you must set the nBandCount to 3 and initialize panSrcBands and
> panDstBands appropriately.
> 
>               psWarpOptions->nBandCount = 1;
>               psWarpOptions->panSrcBands =
>               (int *) CPLMalloc(sizeof(int) * psWarpOptions->nBandCount );
>               psWarpOptions->panSrcBands[0] = 1;
>               psWarpOptions->panDstBands =
>               (int *) CPLMalloc(sizeof(int) * psWarpOptions->nBandCount );
>               psWarpOptions->panDstBands[0] = 1;

_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to