[Qgis-developer] QgsRasterLayer::drawMultiBandColor

Peter Ersts ersts at amnh.org
Thu Aug 16 14:23:16 EDT 2007


Marco,

Just to clarify are you saying that the no-data-value is different for 
each band/channel in your image?

If the bands use the same nodatavalue then technically checking just the 
red channel should be sufficient, though there is a question in the code 
regarding whether all channels should be checked. Additionally, with the 
QgsRasterLayer in trunk you can not manually set the no-data-value. This 
was updated in the raster transparency branch, so that you can manually 
set the nodatavalue.

If you want to make the change anyway, then I would suggest
if((myRedValueDouble == noDataValueDouble || myRedValueDouble != 
myRedValueDouble) && (myGreenValueDouble == noDataValueDouble || 
myGreenValueDouble != myGreenValueDouble) && (myBlueValueDouble == 
noDataValueDouble || myBlueValueDouble != myBlueValueDouble))

if the nodatavalue is NaN, I believe that NaN==Nan always returns false.

-pete

Marco Hugentobler wrote:
> Hi,
>
> In QgsRasterLayer::drawMultiBandColor there is a section of code (line 2463) 
> that is problematic for some files:
>
> if ( myRedValueDouble == noDataValueDouble || myRedValueDouble != 
> myRedValueDouble)
>       {
> #ifdef QGISDEBUG
>         //	QgsLogger::debug("myRedValueDouble", myRedValueDouble, __FILE__, 
> __FUNCTION__, __LINE__, 1);
>         //	QgsLogger::debug("noDataValueDouble", noDataValueDouble, __FILE__, 
> __FUNCTION__, __LINE__, 1);
> #endif
>         continue;
>       }
>
> I have a file where the noDataValueDouble for the first band is 0, so the 
> method does not set pixel colors where red component is 0. This results in an 
> image displayed in wrong colors. Is it ok if I replace the if-statement with:
>
> if(myRedValueDouble == noDataValueDouble && myGreenValueDouble == 
> noDataValueDouble && myBlueValueDouble == noDataValueDouble)
> ?
>
> My example image shows correctly like this.
>
> Regards,
> Marco
>
>   


-- 
====================================
Peter J. Ersts, Project Specialist
American Museum of Natural History
Center for Biodiversity and Conservation
Central Park West at 79th Street
New York, New York 10024
Tel: (212)-496-3488 or (212)-769-5742
Fax: (212)-313-7295 or (212)-769-5292
Web: http://cbc.amnh.org
Web: http://geospatial.amnh.org

Open Source, Open Mind.
...evolving through community cooperation to change the world bit by bit





More information about the Qgis-developer mailing list