PDA

View Full Version : Factoring drawImage



Alundra
6th November 2013, 12:39
Hi all,
I have to do that to have my rendering correct :


// Build the circle.
QImage CircleImage( size(), QImage::Format_ARGB32 );
CircleImage.fill( Qt::transparent );
QPainter CirclePainter( &CircleImage );
CirclePainter.setRenderHint( QPainter::Antialiasing, true );
CirclePainter.setBrush( QBrush( ConicalGradient ) );
CirclePainter.setPen( Qt::black );
CirclePainter.drawEllipse( rect().adjusted( 1, 1, -1, -1 ) );

// Build the alpha channel.
QImage AlphaChannelImage( size(), QImage::Format_RGB32 );
AlphaChannelImage.fill( Qt::transparent );
QPainter AlphaChannelPainter( &AlphaChannelImage );
AlphaChannelPainter.setRenderHint( QPainter::Antialiasing, true );
AlphaChannelPainter.setBrush( QBrush( AlphaGradient ) );
AlphaChannelPainter.setPen( Qt::white );
AlphaChannelPainter.drawEllipse( rect().adjusted( 1, 1, -1, -1 ) );

// Draw the circle.
for( int x = 0; x < CircleImage.width(); ++x )
{
for( int y = 0; y < CircleImage.height(); ++y )
{
const QColor Color = CircleImage.pixel( x, y );
const QColor Alpha = AlphaChannelImage.pixel( x, y );
p.setPen( QColor( Color.red(), Color.green(), Color.blue(), Alpha.red() ) );
p.drawPoint( x, y );
}
}


Is it possible to factor that to only use p.drawImage ?
Thanks for the help