[Qgis-developer] QgsRasterLayer::drawMultiBandColor
Marco Hugentobler
marco.hugentobler at karto.baug.ethz.ch
Thu Aug 16 14:44:05 EDT 2007
On Thursday 16 August 2007 20:23:16 Peter Ersts wrote:
> Marco,
>
> Just to clarify are you saying that the no-data-value is different for
> each band/channel in your image?
No, all the bands have 0 as nodata value.
>
> 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.
In the case of my example, checking all the bands seems reasonable to me.
It may however be a problem for other cases, if e.g. nodata value is -9999 and
only red band has nodata value. Though that case may not be very likely.
> 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.
That's a good suggestion, I didn't consider NaN.
Regards,
Marco
> -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
--
Dr. Marco Hugentobler
Institute of Cartography
ETH Zurich
Technical Advisor QGIS Project Steering Committee
marco.hugentobler at karto.baug.ethz.ch
More information about the Qgis-developer
mailing list