-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
105 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/*************************************************************************** | ||
qgssinglebandcolordatarenderer.cpp | ||
---------------------------------- | ||
begin : January 2012 | ||
copyright : (C) 2012 by Marco Hugentobler | ||
email : marco at sourcepole dot ch | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgssinglebandcolordatarenderer.h" | ||
#include <QImage> | ||
|
||
QgsSingleBandColorDataRenderer::QgsSingleBandColorDataRenderer( QgsRasterDataProvider* provider, int band, QgsRasterResampler* resampler ): | ||
QgsRasterRenderer( provider, resampler ), mBand( band ) | ||
{ | ||
|
||
} | ||
|
||
QgsSingleBandColorDataRenderer::~QgsSingleBandColorDataRenderer() | ||
{ | ||
} | ||
|
||
void QgsSingleBandColorDataRenderer::draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel ) | ||
{ | ||
if ( !p || !mProvider || !viewPort || !theQgsMapToPixel ) | ||
{ | ||
return; | ||
} | ||
|
||
double oversamplingX, oversamplingY; | ||
startRasterRead( mBand, viewPort, theQgsMapToPixel, oversamplingX, oversamplingY ); | ||
|
||
int topLeftCol, topLeftRow, nCols, nRows, currentRasterPos; | ||
void* rasterData; | ||
|
||
while ( readNextRasterPart( mBand, viewPort, nCols, nRows, &rasterData, topLeftCol, topLeftRow ) ) | ||
{ | ||
currentRasterPos = 0; | ||
QImage img( nCols, nRows, QImage::Format_ARGB32_Premultiplied ); | ||
for ( int i = 0; i < nRows; ++i ) | ||
{ | ||
memcpy( img.scanLine( i ), &((( uint* )rasterData )[currentRasterPos] ), nCols * 4 ); | ||
for ( int j = 0; j < nCols; ++j ) | ||
{ | ||
++currentRasterPos; | ||
} | ||
} | ||
|
||
drawImage( p, viewPort, img, topLeftCol, topLeftRow, nCols, nRows, oversamplingX, oversamplingY ); | ||
} | ||
|
||
stopRasterRead( mBand ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/*************************************************************************** | ||
qgssinglebandcolordatarenderer.h | ||
-------------------------------- | ||
begin : January 2012 | ||
copyright : (C) 2012 by Marco Hugentobler | ||
email : marco at sourcepole dot ch | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSSINGLEBANDCOLORDATARENDERER_H | ||
#define QGSSINGLEBANDCOLORDATARENDERER_H | ||
|
||
#include "qgsrasterrenderer.h" | ||
|
||
class QgsSingleBandColorDataRenderer: public QgsRasterRenderer | ||
{ | ||
public: | ||
QgsSingleBandColorDataRenderer( QgsRasterDataProvider* provider, int band, QgsRasterResampler* resampler = 0 ); | ||
~QgsSingleBandColorDataRenderer(); | ||
|
||
virtual void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel ); | ||
|
||
private: | ||
int mBand; | ||
}; | ||
|
||
#endif // QGSSINGLEBANDCOLORDATARENDERER_H |