[Marble-commits] KDE/kdeedu/marble/src/lib/blendings
Jens-Michael Hoffmann
jensmh at gmx.de
Thu Jun 3 15:15:53 CEST 2010
SVN commit 1134127 by jmhoffmann:
Fix for blending: the current implementation of blendings assumes all images
are in ARGB32_Premultiplied format. Make sure this is really the case.
This issue should be fixed in 4.5 also, let's see how this fix works as
there are also other possible solutions.
M +7 -1 BlendingAlgorithms.cpp
--- trunk/KDE/kdeedu/marble/src/lib/blendings/BlendingAlgorithms.cpp #1134126:1134127
@@ -24,18 +24,24 @@
namespace Marble
{
+// pre-conditions:
+// - bottom and top image have the same size
+// - bottom image format is ARGB32_Premultiplied
void IndependentChannelBlending::blend( QImage * const bottom,
QSharedPointer<TextureTile> const & top ) const
{
QImage const * const topImage = top->image();
Q_ASSERT( topImage );
Q_ASSERT( bottom->size() == topImage->size() );
+ Q_ASSERT( bottom->format() == QImage::Format_ARGB32_Premultiplied );
+
int const width = bottom->width();
int const height = bottom->height();
+ QImage const topImagePremult = topImage->convertToFormat( QImage::Format_ARGB32_Premultiplied );
for ( int y = 0; y < height; ++y ) {
for ( int x = 0; x < width; ++x ) {
QRgb const bottomPixel = bottom->pixel( x, y );
- QRgb const topPixel = topImage->pixel( x, y );
+ QRgb const topPixel = topImagePremult.pixel( x, y );
qreal const resultRed = blendChannel( qRed( bottomPixel ) / 255.0,
qRed( topPixel ) / 255.0 );
qreal const resultGreen = blendChannel( qGreen( bottomPixel ) / 255.0,
More information about the Marble-commits
mailing list