Skip to content

Commit

Permalink
Raster redesign: first prototype of paletted renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Dec 18, 2011
1 parent 20ffb06 commit 70865e5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -164,6 +164,9 @@ SET(QGIS_CORE_SRCS
raster/qgsrastershader.cpp
raster/qgsrastershaderfunction.cpp

raster/qgsrasterrenderer.cpp
raster/qgspalettedrasterrenderer.cpp

renderer/qgscontinuouscolorrenderer.cpp
renderer/qgsgraduatedsymbolrenderer.cpp
renderer/qgsrenderer.cpp
Expand Down
17 changes: 17 additions & 0 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -36,6 +36,9 @@ email : tim at linfiniti.com
#include "qgsfreakoutshader.h"
#include "qgscolorrampshader.h"

//renderers
#include "qgspalettedrasterrenderer.h"

#include <cstdio>
#include <cmath>
#include <limits>
Expand Down Expand Up @@ -833,8 +836,22 @@ void QgsRasterLayer::draw( QPainter * theQPainter,
{
QgsDebugMsg( "PalettedColor drawing type detected..." );

//test
int bNumber = bandNumber( mGrayBandName );
QList<QgsColorRampShader::ColorRampItem> itemList = mRasterStatsList[ bNumber - 1].colorTable;
QColor* colorArray = new QColor[itemList.size()];
QList<QgsColorRampShader::ColorRampItem>::const_iterator colorIt = itemList.constBegin();
for ( ; colorIt != itemList.constEnd(); ++colorIt )
{
colorArray[( int )colorIt->value] = colorIt->color;
}

QgsPalettedRasterRenderer renderer( mDataProvider, bNumber, colorArray, itemList.size() );
renderer.draw( theQPainter, theRasterViewPort, theQgsMapToPixel );
#if 0
drawPalettedSingleBandColor( theQPainter, theRasterViewPort,
theQgsMapToPixel, bandNumber( mGrayBandName ) );
#endif //0
break;
}
// a "Palette" layer drawn in gray scale (using only one of the color components)
Expand Down

0 comments on commit 70865e5

Please sign in to comment.