Skip to content
Permalink
Browse files

Use ARGB premultiplied format for simple marker, fixed multiplication…

… of alpha channel for images with premultiplied format.

git-svn-id: http://svn.osgeo.org/qgis/trunk@12818 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Jan 22, 2010
1 parent 788da55 commit cec0413b8448fde568e2036bc0e0608b3a6b9ee0
Showing with 16 additions and 11 deletions.
  1. +1 −1 src/core/symbology-ng/qgsmarkersymbollayerv2.cpp
  2. +15 −10 src/core/symbology-ng/qgssymbollayerv2utils.cpp
@@ -164,7 +164,7 @@ void QgsSimpleMarkerSymbolLayerV2::startRender( QgsSymbolV2RenderContext& contex

double center = (( double ) imageSize / 2 ) + 0.5; // add 1/2 pixel for proper rounding when the figure's coordinates are added

mCache = QImage( QSize( imageSize, imageSize ), QImage::Format_ARGB32 );
mCache = QImage( QSize( imageSize, imageSize ), QImage::Format_ARGB32_Premultiplied );
mCache.fill( 0 );

QPainter p;
@@ -722,20 +722,25 @@ void QgsSymbolLayerV2Utils::multiplyImageOpacity( QImage* image, qreal alpha )
return;
}

//change the alpha component of every pixel
int widthIndex = 0;
int heightIndex = 0;
QRgb* scanLine = 0;
QRgb myRgb;
QImage::Format format = image->format();
if ( format != QImage::Format_ARGB32_Premultiplied && format != QImage::Format_ARGB32 )
{
QgsDebugMsg( "no alpha channel." );
return;
}

for ( ; heightIndex < image->height(); ++heightIndex )
//change the alpha component of every pixel
for ( int heightIndex = 0; heightIndex < image->height(); ++heightIndex )
{
scanLine = ( QRgb* )image->scanLine( heightIndex );
widthIndex = 0;
for ( ; widthIndex < image->width(); ++widthIndex )
QRgb* scanLine = ( QRgb* )image->scanLine( heightIndex );
for ( int widthIndex = 0; widthIndex < image->width(); ++widthIndex )
{
myRgb = image->pixel( widthIndex, heightIndex );
scanLine[widthIndex] = qRgba( qRed( myRgb ), qGreen( myRgb ), qBlue( myRgb ), qAlpha( myRgb ) * alpha );
myRgb = scanLine[widthIndex];
if ( format == QImage::Format_ARGB32_Premultiplied )
scanLine[widthIndex] = qRgba( alpha * qRed( myRgb ), alpha * qGreen( myRgb ), alpha * qBlue( myRgb ), alpha * qAlpha( myRgb ) );
else
scanLine[widthIndex] = qRgba( qRed( myRgb ), qGreen( myRgb ), qBlue( myRgb ), alpha * qAlpha( myRgb ) );
}
}
}

0 comments on commit cec0413

Please sign in to comment.
You can’t perform that action at this time.