Skip to content
Permalink
Browse files
-Disabled renaming of the gray band name by getRasterBandStats()
-Added additional check to each ::draw function look ignore draw requests for bandno <= 0

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7966 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
ersts committed Jan 15, 2008
1 parent c87b753 commit ee2874e981828bb2e63e9c5496f78a67f483f73b
Showing with 59 additions and 9 deletions.
  1. +59 −9 src/core/raster/qgsrasterlayer.cpp
@@ -1420,6 +1420,12 @@ void QgsRasterLayer::draw (QPainter * theQPainter,
void QgsRasterLayer::drawSingleBandGray(QPainter * theQPainter, QgsRasterViewPort * theRasterViewPort, QgsMapToPixel * theQgsMapToPixel, int theBandNo)
{
QgsDebugMsg("QgsRasterLayer::drawSingleBandGray called for layer " + QString::number(theBandNo));
//Invalid band number, segfault prevention
if(0 >= theBandNo)
{
return;
}

GDALRasterBand *myGdalBand = mGdalDataset->GetRasterBand(theBandNo);
GDALDataType myDataType = myGdalBand->GetRasterDataType();
void *myGdalScanData = readData ( myGdalBand, theRasterViewPort );
@@ -1514,12 +1520,17 @@ void QgsRasterLayer::drawSingleBandGray(QPainter * theQPainter, QgsRasterViewPor
void QgsRasterLayer::drawSingleBandPseudoColor(QPainter * theQPainter,
QgsRasterViewPort * theRasterViewPort,
QgsMapToPixel * theQgsMapToPixel,
int theBandNoInt)
int theBandNo)
{
QgsDebugMsg("QgsRasterLayer::drawSingleBandPseudoColor called");

QgsRasterBandStats myRasterBandStats = getRasterBandStats(theBandNoInt);
GDALRasterBand *myGdalBand = mGdalDataset->GetRasterBand(theBandNoInt);
//Invalid band number, segfault prevention
if(0 >= theBandNo)
{
return;
}

QgsRasterBandStats myRasterBandStats = getRasterBandStats(theBandNo);
GDALRasterBand *myGdalBand = mGdalDataset->GetRasterBand(theBandNo);
GDALDataType myDataType = myGdalBand->GetRasterDataType();
void *myGdalScanData = readData ( myGdalBand, theRasterViewPort );

@@ -1616,7 +1627,12 @@ void QgsRasterLayer::drawPalettedSingleBandColor(QPainter * theQPainter, QgsRast
QgsMapToPixel * theQgsMapToPixel, int theBandNo)
{
QgsDebugMsg("QgsRasterLayer::drawPalettedSingleBandColor called");

//Invalid band number, segfault prevention
if(0 >= theBandNo)
{
return;
}

GDALRasterBand *myGdalBand = mGdalDataset->GetRasterBand(theBandNo);
GDALDataType myDataType = myGdalBand->GetRasterDataType();
void *myGdalScanData = readData ( myGdalBand, theRasterViewPort );
@@ -1696,7 +1712,12 @@ void QgsRasterLayer::drawPalettedSingleBandGray(QPainter * theQPainter, QgsRaste
QString const & theColorQString)
{
QgsDebugMsg("QgsRasterLayer::drawPalettedSingleBandGray called");

//Invalid band number, segfault prevention
if(0 >= theBandNo)
{
return;
}

QgsRasterBandStats myRasterBandStats = getRasterBandStats(theBandNo);
GDALRasterBand *myGdalBand = mGdalDataset->GetRasterBand(theBandNo);
GDALDataType myDataType = myGdalBand->GetRasterDataType();
@@ -1790,6 +1811,12 @@ void QgsRasterLayer::drawPalettedSingleBandPseudoColor(QPainter * theQPainter, Q
QString const & theColorQString)
{
QgsDebugMsg("QgsRasterLayer::drawPalettedSingleBandPseudoColor called");
//Invalid band number, segfault prevention
if(0 >= theBandNo)
{
return;
}

QgsRasterBandStats myRasterBandStats = getRasterBandStats(theBandNo);
GDALRasterBand *myGdalBand = mGdalDataset->GetRasterBand(theBandNo);
GDALDataType myDataType = myGdalBand->GetRasterDataType();
@@ -1913,7 +1940,12 @@ void QgsRasterLayer::drawPalettedMultiBandColor(QPainter * theQPainter, QgsRaste
QgsMapToPixel * theQgsMapToPixel, int theBandNo)
{
QgsDebugMsg("QgsRasterLayer::drawPalettedMultiBandColor called");

//Invalid band number, segfault prevention
if(0 >= theBandNo)
{
return;
}

GDALRasterBand *myGdalBand = mGdalDataset->GetRasterBand(theBandNo);
GDALDataType myDataType = myGdalBand->GetRasterDataType();
void *myGdalScanData = readData ( myGdalBand, theRasterViewPort );
@@ -2031,10 +2063,26 @@ void QgsRasterLayer::drawMultiBandColor(QPainter * theQPainter, QgsRasterViewPor
QgsMapToPixel * theQgsMapToPixel)
{
QgsDebugMsg("QgsRasterLayer::drawMultiBandColor called");

int myRedBandNo = getRasterBandNumber(mRedBandName);
//Invalid band number, segfault prevention
if(0 >= myRedBandNo)
{
return;
}

int myGreenBandNo = getRasterBandNumber(mGreenBandName);
//Invalid band number, segfault prevention
if(0 >= myGreenBandNo)
{
return;
}

int myBlueBandNo = getRasterBandNumber(mBlueBandName);
//Invalid band number, segfault prevention
if(0 >= myBlueBandNo)
{
return;
}
GDALRasterBand *myGdalRedBand = mGdalDataset->GetRasterBand(myRedBandNo);
GDALRasterBand *myGdalGreenBand = mGdalDataset->GetRasterBand(myGreenBandNo);
GDALRasterBand *myGdalBlueBand = mGdalDataset->GetRasterBand(myBlueBandNo);
@@ -2396,7 +2444,9 @@ const QgsRasterBandStats QgsRasterLayer::getRasterBandStats(int theBandNo)
}
else if (rasterLayerType==GRAY_OR_UNDEFINED)
{
myRasterBandStats.bandName = myColorerpretation;
//PJE 2008-01-14 This function should not be changing the band name,
//The format below is not the same as the constructor
//myRasterBandStats.bandName = myColorerpretation;
}
else //rasterLayerType is MULTIBAND
{

0 comments on commit ee2874e

Please sign in to comment.