Added null pointer check for color map entries on paletted layers - this was causing segfaults on some grass data. There is no guarantee that a paletted image has a color map entry for every cell! We now support grass rasters with the associated commit for qgisapp.cpp coming straight after this commit.

git-svn-id: http://svn.osgeo.org/qgis/trunk@441 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
timlinux 2004-01-07 17:50:44 +00:00
parent 400277c537
commit a9399d9aa3

View File

@ -179,16 +179,25 @@ void QgsRasterLayer::draw(QPainter * theQPainter, QgsRect * theViewExtent, QgsCo
int myRedValueInt=0; //color 1 int
int myGreenValueInt=0; //color 2 int
int myBlueValueInt=0; //color 3 int
//check for alternate color mappings
if (redBandNameQString=="Red") myRedValueInt=colorEntry->c1;
if (redBandNameQString=="Green") myRedValueInt=colorEntry->c2;
if (redBandNameQString=="Blue") myRedValueInt=colorEntry->c3;
if (greenBandNameQString=="Red") myGreenValueInt=colorEntry->c1;
if (greenBandNameQString=="Green") myGreenValueInt=colorEntry->c2;
if (greenBandNameQString=="Blue") myGreenValueInt=colorEntry->c3;
if (blueBandNameQString=="Red") myBlueValueInt=colorEntry->c1;
if (blueBandNameQString=="Green") myBlueValueInt=colorEntry->c2;
if (blueBandNameQString=="Blue") myBlueValueInt=colorEntry->c3;
//check colorEntry is valid
if (colorEntry!=NULL)
{
//check for alternate color mappings
if (redBandNameQString=="Red") myRedValueInt=colorEntry->c1;
if (redBandNameQString=="Green") myRedValueInt=colorEntry->c2;
if (redBandNameQString=="Blue") myRedValueInt=colorEntry->c3;
if (greenBandNameQString=="Red") myGreenValueInt=colorEntry->c1;
if (greenBandNameQString=="Green") myGreenValueInt=colorEntry->c2;
if (greenBandNameQString=="Blue") myGreenValueInt=colorEntry->c3;
if (blueBandNameQString=="Red") myBlueValueInt=colorEntry->c1;
if (blueBandNameQString=="Green") myBlueValueInt=colorEntry->c2;
if (blueBandNameQString=="Blue") myBlueValueInt=colorEntry->c3;
}
else
{
//there is no guarantee that there will be a matching palette entry for
//every cell in the raster. If there is no match, do nothing.
}
if (invertHistogramFlag)
{
myRedValueInt=255-myRedValueInt;