[Marble-commits] branches/KDE/4.5/kdeedu/marble/src/lib/blendings
Jens-Michael Hoffmann
jensmh at gmx.de
Mon Jun 21 21:39:20 CEST 2010
SVN commit 1140909 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.
Backport of commit 1134127 from trunk.
M +7 -1 BlendingAlgorithms.cpp
--- branches/KDE/4.5/kdeedu/marble/src/lib/blendings/BlendingAlgorithms.cpp #1140908:1140909
@@ -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