[QGIS Commit] r9251 - in trunk/qgis: python/core src/app src/core/raster

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Sep 2 19:29:44 EDT 2008


Author: ersts
Date: 2008-09-02 19:29:44 -0400 (Tue, 02 Sep 2008)
New Revision: 9251

Modified:
   trunk/qgis/python/core/qgsrasterlayer.sip
   trunk/qgis/src/app/qgsrasterlayerproperties.cpp
   trunk/qgis/src/core/raster/qgscolorrampshader.cpp
   trunk/qgis/src/core/raster/qgscolorrampshader.h
   trunk/qgis/src/core/raster/qgsrasterbandstats.h
   trunk/qgis/src/core/raster/qgsrasterlayer.cpp
   trunk/qgis/src/core/raster/qgsrasterlayer.h
Log:
-Cleaning out references to obsolete class QgsColorTable
-Changed how Paletted bands are drawn as gray scale
-Added cache to QgsColorRampShader to speed up rendering time when using large color tables (still poor)
-Fixed small bug in rendering the palette as a pixmap

Modified: trunk/qgis/python/core/qgsrasterlayer.sip
===================================================================
--- trunk/qgis/python/core/qgsrasterlayer.sip	2008-09-02 21:55:15 UTC (rev 9250)
+++ trunk/qgis/python/core/qgsrasterlayer.sip	2008-09-02 23:29:44 UTC (rev 9251)
@@ -100,7 +100,7 @@
      void drawThumbnail(QPixmap * theQPixmap);
 
     /** \brief Get an 8x8 pixmap of the colour palette. If the layer has no palette a white pixmap will be returned. */
-     QPixmap getPaletteAsPixmap();
+     QPixmap getPaletteAsPixmap(int theBand=1);
      
     /** \brief This is called when the view on the rasterlayer needs to be refreshed (redrawn).   
      */
@@ -498,7 +498,7 @@
      *  \param band number
      *  \return pointer to color table
      */
-    QgsColorTable *colorTable ( int theBandNoInt );
+    QList<QgsColorRampShader::ColorRampItem>* getColorTable ( int theBandNoInt );
  protected:
 
     /** reads vector layer specific state from project file Dom node.

Modified: trunk/qgis/src/app/qgsrasterlayerproperties.cpp
===================================================================
--- trunk/qgis/src/app/qgsrasterlayerproperties.cpp	2008-09-02 21:55:15 UTC (rev 9250)
+++ trunk/qgis/src/app/qgsrasterlayerproperties.cpp	2008-09-02 23:29:44 UTC (rev 9251)
@@ -828,7 +828,7 @@
   pixmapLegend->repaint();
 
   //set the palette pixmap
-  pixmapPalette->setPixmap( mRasterLayer->getPaletteAsPixmap() );
+  pixmapPalette->setPixmap( mRasterLayer->getPaletteAsPixmap(mRasterLayer->getRasterBandNumber(mRasterLayer->getGrayBandName())));
   pixmapPalette->setScaledContents( true );
   pixmapPalette->repaint();
 
@@ -1971,7 +1971,7 @@
        == QgsRasterLayer::PALETTE ) //paletted layers have hard coded color entries
   {
     QPolygonF myPolygon;
-    QgsColorTable *myColorTable = mRasterLayer->colorTable( 1 );
+    QgsColorRampShader* myRasterShaderFunction = ( QgsColorRampShader* )mRasterLayer->getRasterShader()->getRasterShaderFunction();
     QgsDebugMsg( "Making paletted image histogram....computing band stats" );
     QgsDebugMsg( QString( "myLastBinWithData = %1" ).arg( myLastBinWithData ) );
 
@@ -2002,8 +2002,7 @@
 
         QgsDebugMsg( QString( "myMiddle = %1" ).arg( myMiddle ) );
 
-        bool found = myColorTable->color( myMiddle, &c1, &c2, &c3 );
-        if ( !found )
+        if ( myRasterShaderFunction->generateShadedValue(myMiddle, &c1, &c2, &c3))
         {
           QgsDebugMsg( "Color not found" );
           c1 = c2 = c3 = 180; // grey

Modified: trunk/qgis/src/core/raster/qgscolorrampshader.cpp
===================================================================
--- trunk/qgis/src/core/raster/qgscolorrampshader.cpp	2008-09-02 21:55:15 UTC (rev 9250)
+++ trunk/qgis/src/core/raster/qgscolorrampshader.cpp	2008-09-02 23:29:44 UTC (rev 9251)
@@ -25,10 +25,22 @@
 QgsColorRampShader::QgsColorRampShader( double theMinimumValue, double theMaximumValue ) : QgsRasterShaderFunction( theMinimumValue, theMaximumValue )
 {
   QgsDebugMsg( "called." );
+  mMaximumColorCacheSize = 256; //good starting value
 }
 
 bool QgsColorRampShader::generateShadedValue( double theValue, int* theReturnRedValue, int* theReturnGreenValue, int* theReturnBlueValue )
 {
+  //Get the shaded from the cache if it exists already
+  QColor myColor = mColorCache.value(theValue);
+  if(myColor.isValid())
+  {
+    *theReturnRedValue = myColor.red();
+    *theReturnGreenValue = myColor.green();
+    *theReturnBlueValue = myColor.blue();
+    return true;
+  }
+  
+  //Else we have to generate the shaded value
   if ( QgsColorRampShader::INTERPOLATED == mColorRampType )
   {
     return getInterpolatedColor( theValue, theReturnRedValue, theReturnGreenValue, theReturnBlueValue );
@@ -81,15 +93,16 @@
     myCurrentRampValue = it->value;
     if ( theValue <= myCurrentRampValue )
     {
-      if ( last_it != mColorRampItemList.end() )
+      *theReturnRedValue = it->color.red();
+      *theReturnGreenValue = it->color.green();
+      *theReturnBlueValue = it->color.blue();
+      //Cache the shaded value
+      if(mMaximumColorCacheSize <= mColorCache.size())
       {
-        *theReturnRedValue = last_it->color.red();
-        *theReturnGreenValue = last_it->color.green();
-        *theReturnBlueValue = last_it->color.blue();
-        return true;
+        mColorCache.insert(theValue, it->color);
       }
+      return true;
     }
-    last_it = it;
   }
 
   return false; // value not found
@@ -109,6 +122,11 @@
       *theReturnRedValue = it->color.red();
       *theReturnGreenValue = it->color.green();
       *theReturnBlueValue = it->color.blue();
+      //Cache the shaded value
+      if(mMaximumColorCacheSize <= mColorCache.size())
+      {
+        mColorCache.insert(theValue, it->color);
+      }
       return true;
     }
   }
@@ -143,6 +161,11 @@
         *theReturnRedValue = ( int )(( it->color.red() * myDiffTheValueLastRampValue + last_it->color.red() * myDiffCurrentRampValueTheValue ) / myCurrentRampRange );
         *theReturnGreenValue = ( int )(( it->color.green() * myDiffTheValueLastRampValue + last_it->color.green() * myDiffCurrentRampValueTheValue ) / myCurrentRampRange );
         *theReturnBlueValue = ( int )(( it->color.blue() * myDiffTheValueLastRampValue + last_it->color.blue() * myDiffCurrentRampValueTheValue ) / myCurrentRampRange );
+        //Cache the shaded value
+        if(mMaximumColorCacheSize <= mColorCache.size())
+        {
+          mColorCache.insert(theValue, it->color);
+        }
         return true;
       }
     }

Modified: trunk/qgis/src/core/raster/qgscolorrampshader.h
===================================================================
--- trunk/qgis/src/core/raster/qgscolorrampshader.h	2008-09-02 21:55:15 UTC (rev 9250)
+++ trunk/qgis/src/core/raster/qgscolorrampshader.h	2008-09-02 23:29:44 UTC (rev 9251)
@@ -22,6 +22,7 @@
 #define QGSCOLORRAMPSHADER_H
 
 #include <QColor>
+#include <QMap>
 
 #include "qgsrastershaderfunction.h"
 
@@ -62,6 +63,9 @@
     QgsColorRampShader::COLOR_RAMP_TYPE getColorRampType() {return mColorRampType;}
     QString getColorRampTypeAsQString();
 
+    /**Get the maximum size the color cache can be*/
+    int getMaximumColorCacheSize() { return mMaximumColorCacheSize; }
+
     /**Set custom colormap */
     void setColorRampItemList( const QList<QgsColorRampShader::ColorRampItem>& theList ) { mColorRampItemList = theList; }
 
@@ -70,6 +74,9 @@
 
     /**Set the color ramp type*/
     void setColorRampType( QString );
+    
+    /**Set the maximum size the color cache can be */
+    void setMaximumColorCacheSize(int theSize) { mMaximumColorCacheSize = theSize; }
 
 
 
@@ -85,6 +92,8 @@
     QList<QgsColorRampShader::ColorRampItem> mColorRampItemList;
 
     QgsColorRampShader::COLOR_RAMP_TYPE mColorRampType;
+    QMap<double, QColor> mColorCache;
+    int mMaximumColorCacheSize; //The color cache could eat a ton of memory if you have 32-bit data
 };
 
 #endif

Modified: trunk/qgis/src/core/raster/qgsrasterbandstats.h
===================================================================
--- trunk/qgis/src/core/raster/qgsrasterbandstats.h	2008-09-02 21:55:15 UTC (rev 9250)
+++ trunk/qgis/src/core/raster/qgsrasterbandstats.h	2008-09-02 23:29:44 UTC (rev 9251)
@@ -24,7 +24,7 @@
 
 #include <limits>
 
-#include "qgscolortable.h"
+#include "qgscolorrampshader.h"
 /** \ingroup core
  * The RasterBandStats struct is a container for statistics about a single
  * raster band.
@@ -82,6 +82,6 @@
     /** whehter histogram compuation should include out of range values */
     bool histogramOutOfRangeFlag;
     /** Color table */
-    QgsColorTable colorTable;
+    QList<QgsColorRampShader::ColorRampItem> colorTable;
 };
 #endif

Modified: trunk/qgis/src/core/raster/qgsrasterlayer.cpp
===================================================================
--- trunk/qgis/src/core/raster/qgsrasterlayer.cpp	2008-09-02 21:55:15 UTC (rev 9250)
+++ trunk/qgis/src/core/raster/qgsrasterlayer.cpp	2008-09-02 23:29:44 UTC (rev 9251)
@@ -521,9 +521,9 @@
     myRasterBandStats.bandNo = i;
     myRasterBandStats.statsGatheredFlag = false;
     myRasterBandStats.histogramVector = new QgsRasterBandStats::HistogramVector();
-    // Read color table
-    readColorTable( myGdalBand, &( myRasterBandStats.colorTable ) );
-
+    //Store the default color table
+    readColorTable(i, &myRasterBandStats.colorTable);
+    
     mRasterStatsList.push_back( myRasterBandStats );
 
     //Build a new contrast enhancement for the band and store in list
@@ -562,14 +562,11 @@
 
     drawingStyle = PALETTED_COLOR; //sensible default
 
-    //Load the color table from the band
-    QList<QgsColorRampShader::ColorRampItem> myColorRampList;
-    readColorTable( 1, &myColorRampList );
     //Set up a new color ramp shader
     setColorShadingAlgorithm( COLOR_RAMP );
     QgsColorRampShader* myColorRampShader = ( QgsColorRampShader* ) mRasterShader->getRasterShaderFunction();
     myColorRampShader->setColorRampType( QgsColorRampShader::EXACT );
-    myColorRampShader->setColorRampItemList( myColorRampList );
+    myColorRampShader->setColorRampItemList( *getColorTable(1) );
   }
   else if ( rasterLayerType == MULTIBAND )
   {
@@ -886,27 +883,23 @@
 
 
 
-QPixmap QgsRasterLayer::getPaletteAsPixmap()
+QPixmap QgsRasterLayer::getPaletteAsPixmap(int theBandNumber)
 {
   QgsDebugMsg( "entered." );
 
   // Only do this for the non-provider (hard-coded GDAL) scenario...
   // Maybe WMS can do this differently using QImage::numColors and QImage::color()
-  if (
-    ( mProviderKey.isEmpty() ) &&
-    ( hasBand( "Palette" ) ) //dont tr() this its a gdal word!
-  )
+  if (mProviderKey.isEmpty() && hasBand( "Palette" ) && theBandNumber > 0) //dont tr() this its a gdal word!
   {
     QgsDebugMsg( "....found paletted image" );
-    QgsColorTable *myColorTable = colorTable( 1 );
-    GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, 1 );
-    if ( GDALGetRasterColorInterpretation( myGdalBand ) == GCI_PaletteIndex && myColorTable->defined() )
+    QgsColorRampShader myShader;
+    QList<QgsColorRampShader::ColorRampItem> myColorRampItemList = myShader.getColorRampItemList();
+    
+    if(readColorTable(1, &myColorRampItemList))
     {
-      QgsDebugMsg( "....found GCI_PaletteIndex" );
-      double myMin = myColorTable->rmin();
-      double myMax = myColorTable->rmax();
-      QgsDebugMsg( "myMin = " + QString::number( myMin ) + " myMax = " + QString::number( myMax ) );
-
+      QgsDebugMsg( "....got color ramp item list" );
+      myShader.setColorRampItemList(myColorRampItemList);
+      myShader.setColorRampType(QgsColorRampShader::DISCRETE);
       // Draw image
       int mySize = 100;
       QPixmap myPalettePixmap( mySize, mySize );
@@ -916,20 +909,17 @@
       myQImage.fill( 0 );
       myPalettePixmap.fill();
 
-      double myStep = ( myMax - myMin ) / ( mySize * mySize );
-
+      double myStep = ( (double)myColorRampItemList.size() - 1 ) / (double)( mySize * mySize );
+      double myValue = 0.0;
       for ( int myRow = 0; myRow < mySize; myRow++ )
       {
         for ( int myCol = 0; myCol < mySize; myCol++ )
         {
 
-          double myValue = myMin + myStep * ( myCol + myRow * mySize );
-
+          myValue = myStep * (double)( myCol + myRow * mySize );
           int c1, c2, c3;
-          bool found = myColorTable->color( myValue, &c1, &c2, &c3 );
-
-          if ( found )
-            myQImage.setPixel( myCol, myRow, qRgb( c1, c2, c3 ) );
+          myShader.generateShadedValue( myValue, &c1, &c2, &c3 );
+          myQImage.setPixel( myCol, myRow, qRgb( c1, c2, c3 ) );
         }
       }
 
@@ -1257,7 +1247,7 @@
 
         int myBandNo = 1;
         drawPalettedSingleBandGray( theQPainter, theRasterViewPort,
-                                    theQgsMapToPixel, myBandNo, mGrayBandName );
+                                    theQgsMapToPixel, myBandNo);
 
         break;
       }
@@ -1498,6 +1488,7 @@
 
   double myPixelValue = 0.0;
   int myAlphaValue = 0;
+  QgsDebugMsg( "Starting main render loop" );
   for ( int myColumn = 0; myColumn < theRasterViewPort->drawableAreaYDim; ++myColumn )
   {
     for ( int myRow = 0; myRow < theRasterViewPort->drawableAreaXDim; ++myRow )
@@ -1581,7 +1572,8 @@
   int myGreenValue = 0;
   int myBlueValue = 0;
   int myAlphaValue = 0;
-
+  
+  QgsDebugMsg( "Starting main render loop" );
   for ( int myColumn = 0; myColumn < theRasterViewPort->drawableAreaYDim; ++myColumn )
   {
     for ( int myRow = 0; myRow < theRasterViewPort->drawableAreaXDim; ++myRow )
@@ -1637,8 +1629,7 @@
  * @param theColorQString - QString containing either 'Red' 'Green' or 'Blue' indicating which part of the rgb triplet will be used to render gray.
  */
 void QgsRasterLayer::drawPalettedSingleBandGray( QPainter * theQPainter, QgsRasterViewPort * theRasterViewPort,
-    const QgsMapToPixel* theQgsMapToPixel, int theBandNo,
-    QString const & theColorQString )
+    const QgsMapToPixel* theQgsMapToPixel, int theBandNo)
 {
   QgsDebugMsg( "entered." );
   //Invalid band number, segfault prevention
@@ -1647,7 +1638,11 @@
     return;
   }
 
-  QgsRasterBandStats myRasterBandStats = getRasterBandStats( theBandNo );
+  if ( NULL == mRasterShader )
+  {
+    return;
+  }
+
   GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, theBandNo );
   GDALDataType myDataType = GDALGetRasterDataType( myGdalBand );
   void *myGdalScanData = readData( myGdalBand, theRasterViewPort );
@@ -1658,41 +1653,23 @@
     return;
   }
 
-  QgsColorTable *myColorTable = &( myRasterBandStats.colorTable );
-
   QImage myQImage = QImage( theRasterViewPort->drawableAreaXDim, theRasterViewPort->drawableAreaYDim, QImage::Format_ARGB32 );
   myQImage.fill( qRgba( 255, 255, 255, 0 ) ); // fill transparent
 
-  bool found = false;
   double myPixelValue = 0.0;
-  int myRedLUTValue = 0;
-  int myGreenLUTValue = 0;
-  int myBlueLUTValue = 0;
+  int myRedValue = 0;
+  int myGreenValue = 0;
+  int myBlueValue = 0;
   int myAlphaValue = 0;
 
-  //Set a pointer to the LUT color channel
-  int* myGrayValue;
-  if ( theColorQString == mRedBandName )
-  {
-    myGrayValue = &myRedLUTValue;
-  }
-  else if ( theColorQString == mGreenBandName )
-  {
-    myGrayValue = &myGreenLUTValue;
-  }
-  else
-  {
-    myGrayValue = &myBlueLUTValue;
-  }
-
+  QgsDebugMsg( "Starting main render loop" );
   for ( int myColumn = 0; myColumn < theRasterViewPort->drawableAreaYDim; ++myColumn )
   {
     for ( int myRow = 0; myRow < theRasterViewPort->drawableAreaXDim; ++myRow )
     {
-      myRedLUTValue = 0;
-      myGreenLUTValue = 0;
-      myBlueLUTValue = 0;
-      found = false;
+      myRedValue = 0;
+      myGreenValue = 0;
+      myBlueValue = 0;
       myPixelValue = readValue( myGdalScanData, ( GDALDataType )myDataType,
                                 myColumn * theRasterViewPort->drawableAreaXDim + myRow );
 
@@ -1707,15 +1684,23 @@
         continue;
       }
 
-      found = myColorTable->color( myPixelValue, &myRedLUTValue, &myGreenLUTValue, &myBlueLUTValue );
-      if ( !found ) continue;
+      if ( !mRasterShader->generateShadedValue( myPixelValue, &myRedValue, &myGreenValue, &myBlueValue ) )
+      {
+        continue;
+      }
 
       if ( mInvertPixelsFlag )
       {
-        *myGrayValue = 255 - *myGrayValue;
+        //Invert flag, flip blue and read
+        double myGrayValue = (0.3 * (double)myRedValue) + (0.59 * (double)myGreenValue) + (0.11 * (double)myBlueValue);
+        myQImage.setPixel( myRow, myColumn, qRgba( (int)myGrayValue, (int)myGrayValue, (int)myGrayValue, myAlphaValue ) );
       }
-
-      myQImage.setPixel( myRow, myColumn, qRgba( *myGrayValue, *myGrayValue, *myGrayValue, myAlphaValue ) );
+      else
+      {
+        //Normal
+        double myGrayValue = (0.3 * (double)myBlueValue) + (0.59 * (double)myGreenValue) + (0.11 * (double)myRedValue);
+        myQImage.setPixel( myRow, myColumn, qRgba( (int)myGrayValue, (int)myGrayValue, (int)myGrayValue, myAlphaValue ) );
+      }
     }
   }
   CPLFree( myGdalScanData );
@@ -1787,6 +1772,7 @@
   int myBlueValue = 0;
   int myAlphaValue = 0;
 
+  QgsDebugMsg( "Starting main render loop" );
   for ( int myColumn = 0; myColumn < theRasterViewPort->drawableAreaYDim; ++myColumn )
   {
     for ( int myRow = 0; myRow < theRasterViewPort->drawableAreaXDim; ++myRow )
@@ -1964,6 +1950,8 @@
   QgsContrastEnhancement* myRedContrastEnhancement = getContrastEnhancement( myRedBandNo );
   QgsContrastEnhancement* myGreenContrastEnhancement = getContrastEnhancement( myGreenBandNo );
   QgsContrastEnhancement* myBlueContrastEnhancement = getContrastEnhancement( myBlueBandNo );
+  
+  QgsDebugMsg( "Starting main render loop" );
   for ( int myColumn = 0; myColumn < theRasterViewPort->drawableAreaYDim; ++myColumn )
   {
     for ( int myRow = 0; myRow < theRasterViewPort->drawableAreaXDim; ++myRow )
@@ -2209,10 +2197,6 @@
 
   QString myColorerpretation = GDALGetColorInterpretationName( GDALGetRasterColorInterpretation( myGdalBand ) );
 
-  //declare a colorTable to hold a palette - will only be used if the layer color interp is palette ???
-  //get the palette colour table
-  QgsColorTable *myColorTable = &( myRasterBandStats.colorTable );
-
   // XXX this sets the element count to a sensible value; but then you ADD to
   // XXX it later while iterating through all the pixels?
   //myRasterBandStats.elementCount = mRasterXDim * mRasterYDim;
@@ -2395,32 +2379,6 @@
             continue; // NULL
           }
 
-          //get the nth element from the current row
-          if ( myColorerpretation == "Palette" ) // dont translate this its a gdal string
-          {
-            //this is a palette layer so red / green / blue 'layers are 'virtual'
-            //in that we need to obtain the palette entry and then get the r,g or g
-            //component from that palette entry
-
-            int c1, c2, c3;
-            bool found = myColorTable->color( my, &c1, &c2, &c3 );
-            if ( !found ) continue;
-
-            //check for alternate color mappings
-            switch ( theBandNo )
-            {
-              case 1:
-                my = c1;
-                break;
-              case 2:
-                my = c2;
-                break;
-              case 3:
-                my = c3;
-                break;
-            }
-          }
-
           myRasterBandStats.sumSqrDev += static_cast < double >
                                          ( pow( my - myRasterBandStats.mean, 2 ) );
         }
@@ -3770,68 +3728,8 @@
   return true;
 }
 
-void QgsRasterLayer::readColorTable( GDALRasterBandH gdalBand, QgsColorTable *theColorTable )
+QList<QgsColorRampShader::ColorRampItem>* QgsRasterLayer::getColorTable( int theBandNo )
 {
-  QgsDebugMsg( "entered." );
-
-  // First try to read color table from metadata
-  char **metadata = GDALGetMetadata( gdalBand, NULL );
-  theColorTable->clear();
-  bool found = false;
-  while ( metadata && metadata[0] )
-  {
-    QStringList metadataTokens = QString( *metadata ).split( "=", QString::SkipEmptyParts );
-
-    if ( metadataTokens.count() < 2 ) continue;
-
-    if ( metadataTokens[0].contains( "COLOR_TABLE_RULE_RGB_" ) )
-    {
-      double min, max;
-      int min_c1, min_c2, min_c3, max_c1, max_c2, max_c3;
-
-      if ( sscanf( metadataTokens[1].toLocal8Bit().data(), "%lf %lf %d %d %d %d %d %d",
-                   &min, &max, &min_c1, &min_c2, &min_c3, &max_c1, &max_c2, &max_c3 ) != 8 )
-      {
-        continue;
-      }
-      theColorTable->add( min, max,
-                          ( unsigned char )min_c1, ( unsigned char )min_c2, ( unsigned char )min_c3, 0,
-                          ( unsigned char )max_c1, ( unsigned char )max_c2, ( unsigned char )max_c3, 0 );
-      found = true;
-    }
-    ++metadata;
-  }
-  theColorTable->sort();
-
-  // If no color table was found, try to read it from GDALColorTable
-  if ( !found )
-  {
-    GDALColorTableH gdalColorTable = GDALGetRasterColorTable( gdalBand );
-
-    if ( gdalColorTable )
-    {
-      int count = GDALGetColorEntryCount( gdalColorTable );
-
-      for ( int i = 0; i < count; i++ )
-      {
-        const GDALColorEntry *colorEntry = GDALGetColorEntry( gdalColorTable, i );
-
-        if ( !colorEntry ) continue;
-
-        theColorTable->add( i, ( unsigned char ) colorEntry->c1, ( unsigned char ) colorEntry->c2,
-                            ( unsigned char ) colorEntry->c3 );
-      }
-    }
-  }
-
-#ifdef QGISDEBUG
-  theColorTable->print();
-#endif
-}
-
-
-QgsColorTable *QgsRasterLayer::colorTable( int theBandNo )
-{
   return &( mRasterStatsList[theBandNo-1].colorTable );
 }
 

Modified: trunk/qgis/src/core/raster/qgsrasterlayer.h
===================================================================
--- trunk/qgis/src/core/raster/qgsrasterlayer.h	2008-09-02 21:55:15 UTC (rev 9250)
+++ trunk/qgis/src/core/raster/qgsrasterlayer.h	2008-09-02 23:29:44 UTC (rev 9251)
@@ -55,7 +55,6 @@
 //
 // Forward declarations
 //
-class QgsColorTable;
 class QgsMapToPixel;
 class QgsRect;
 class QgsRasterBandStats;
@@ -276,7 +275,7 @@
     void drawThumbnail( QPixmap * theQPixmap );
 
     /** \brief Get an 8x8 pixmap of the color palette. If the layer has no palette a white pixmap will be returned. */
-    QPixmap getPaletteAsPixmap();
+    QPixmap getPaletteAsPixmap(int theBand=1);
 
     /** \brief This is called when the view on the raster layer needs to be refreshed (redrawn).
      */
@@ -885,7 +884,7 @@
      *  \param band number
      *  \return pointer to color table
      */
-    QgsColorTable *colorTable( int theBandNoInt );
+    QList<QgsColorRampShader::ColorRampItem>* getColorTable( int theBandNoInt );
   protected:
 
     /** reads vector layer specific state from project file Dom node.
@@ -947,8 +946,7 @@
     void drawPalettedSingleBandGray( QPainter * theQPainter,
                                      QgsRasterViewPort * theRasterViewPort,
                                      const QgsMapToPixel* theQgsMapToPixel,
-                                     int theBandNoInt,
-                                     const QString &  theColorQString );
+                                     int theBandNoInt);
 
     /** \brief Drawing routine for paletted image, rendered as a single band image in pseudocolor.  */
     void drawPalettedSingleBandPseudoColor( QPainter * theQPainter,
@@ -988,9 +986,6 @@
     void paintImageToCanvas( QPainter* theQPainter, QgsRasterViewPort * theRasterViewPort,
                              const QgsMapToPixel* theQgsMapToPixel, QImage* theImage );
 
-    /** \brief Read color table from GDAL raster band */
-    void readColorTable( GDALRasterBandH gdalBand, QgsColorTable *theColorTable );
-
     /** \brief Allocate memory and load data to that allocated memory, data type is the same
      *         as raster band. The memory must be released later!
      *  \return pointer to the memory



More information about the QGIS-commit mailing list