[Marble-devel] [PATCH 04/13] Blending::blend(): change type of parameter top: QImage -> TextureTile.
Jens-Michael Hoffmann
jensmh at gmx.de
Tue Mar 30 20:30:12 CEST 2010
Blending::blend(): change type of parameter top: QImage -> TextureTile.
The SunLightBlending will need the tile coordinates and zoom level, the
easiest way to achieve this is to just pass the TextureTile here.
---
marble/src/lib/Blending.h | 5 ++++-
marble/src/lib/BlendingAlgorithms.cpp | 18 ++++++++++++------
marble/src/lib/BlendingAlgorithms.h | 4 ++--
marble/src/lib/StackedTile.cpp | 2 +-
4 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/marble/src/lib/Blending.h b/marble/src/lib/Blending.h
index 0dda3ec..e9e3b42 100644
--- a/marble/src/lib/Blending.h
+++ b/marble/src/lib/Blending.h
@@ -16,16 +16,19 @@
#ifndef MARBLE_BLENDING_H
#define MARBLE_BLENDING_H
+#include <QtCore/QSharedPointer>
+
class QImage;
namespace Marble
{
+class TextureTile;
class Blending
{
public:
virtual ~Blending();
- virtual void blend( QImage * const bottom, QImage const * const top ) const = 0;
+ virtual void blend( QImage * const bottom, QSharedPointer<TextureTile> const & top ) const = 0;
};
}
diff --git a/marble/src/lib/BlendingAlgorithms.cpp b/marble/src/lib/BlendingAlgorithms.cpp
index 33f5233..a11bd2e 100644
--- a/marble/src/lib/BlendingAlgorithms.cpp
+++ b/marble/src/lib/BlendingAlgorithms.cpp
@@ -15,6 +15,8 @@
#include "BlendingAlgorithms.h"
+#include "TextureTile.h"
+
#include <cmath>
#include <QtGui/QImage>
@@ -22,15 +24,17 @@
namespace Marble
{
-void IndependentChannelBlending::blend( QImage * const bottom, QImage const * const top ) const
+void IndependentChannelBlending::blend( QImage * const bottom, QSharedPointer<TextureTile> const & top ) const
{
- Q_ASSERT( bottom->size() == top->size() );
+ QImage const * const topImage = top->image();
+ Q_ASSERT( topImage );
+ Q_ASSERT( bottom->size() == topImage->size() );
int const width = bottom->width();
int const height = bottom->height();
for ( int y = 0; y < height; ++y ) {
for ( int x = 0; x < width; ++x ) {
QRgb const bottomPixel = bottom->pixel( x, y );
- QRgb const topPixel = top->pixel( x, y );
+ QRgb const topPixel = topImage->pixel( x, y );
qreal const resultRed = blendChannel( qRed( bottomPixel ) / 255.0,
qRed( topPixel ) / 255.0 );
qreal const resultGreen = blendChannel( qGreen( bottomPixel ) / 255.0,
@@ -257,14 +261,16 @@ qreal HalfDifferenceBlending::blendChannel( qreal const bottomColorIntensity,
// Special purpose blendings
-void CloudsBlending::blend( QImage * const bottom, QImage const * const top ) const
+void CloudsBlending::blend( QImage * const bottom, QSharedPointer<TextureTile> const & top ) const
{
- Q_ASSERT( bottom->size() == top->size() );
+ QImage const * const topImage = top->image();
+ Q_ASSERT( topImage );
+ Q_ASSERT( bottom->size() == topImage->size() );
int const width = bottom->width();
int const height = bottom->height();
for ( int y = 0; y < height; ++y ) {
for ( int x = 0; x < width; ++x ) {
- qreal const c = qRed( top->pixel( x, y )) / 255.0;
+ qreal const c = qRed( topImage->pixel( x, y )) / 255.0;
QRgb const bottomPixel = bottom->pixel( x, y );
int const bottomRed = qRed( bottomPixel );
int const bottomGreen = qGreen( bottomPixel );
diff --git a/marble/src/lib/BlendingAlgorithms.h b/marble/src/lib/BlendingAlgorithms.h
index 7887c38..a2987f3 100644
--- a/marble/src/lib/BlendingAlgorithms.h
+++ b/marble/src/lib/BlendingAlgorithms.h
@@ -26,7 +26,7 @@ namespace Marble
class IndependentChannelBlending: public Blending
{
public:
- virtual void blend( QImage * const bottom, QImage const * const top ) const;
+ virtual void blend( QImage * const bottom, QSharedPointer<TextureTile> const & top ) const;
private:
// bottomColorIntensity: intensity of one color channel (of one pixel) of the bottom image
// topColorIntensity: intensity of one color channel (of one pixel) of the top image
@@ -238,7 +238,7 @@ class HalfDifferenceBlending: public IndependentChannelBlending
class CloudsBlending: public Blending
{
public:
- virtual void blend( QImage * const bottom, QImage const * const top ) const;
+ virtual void blend( QImage * const bottom, QSharedPointer<TextureTile> const & top ) const;
};
}
diff --git a/marble/src/lib/StackedTile.cpp b/marble/src/lib/StackedTile.cpp
index d44ef55..c3cb0ef 100644
--- a/marble/src/lib/StackedTile.cpp
+++ b/marble/src/lib/StackedTile.cpp
@@ -371,7 +371,7 @@ void StackedTile::initResultTile()
Blending const * const blending = (*pos)->blending();
if ( blending ) {
mDebug() << "StackedTile::initResultTile: blending";
- blending->blend( &d->m_resultTile, (*pos)->image() );
+ blending->blend( &d->m_resultTile, *pos );
}
else {
mDebug() << "StackedTile::initResultTile: no blending defined => copying top over bottom image";
--
1.7.0.3
More information about the Marble-devel
mailing list