mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
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:
parent
400277c537
commit
a9399d9aa3
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user