Skip to content

Commit 32ec65c

Browse files
committed
Fix printing with composition effects
1 parent b7064db commit 32ec65c

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/core/composer/qgscomposereffect.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,28 @@ void QgsComposerEffect::draw( QPainter *painter )
3535

3636
// Set desired composition mode then draw source
3737
painter->setCompositionMode( mCompositionMode );
38-
drawSource( painter );
38+
39+
if ( mCompositionMode == QPainter::CompositionMode_SourceOver )
40+
{
41+
// Normal (sourceover) blending, do faster drawSource operation
42+
drawSource( painter );
43+
return;
44+
}
45+
46+
// Otherwise, draw using pixmap so QPrinter output works as expected
47+
if ( sourceIsPixmap() )
48+
{
49+
// No point in drawing in device coordinates (pixmap will be scaled anyways).
50+
pixmap = sourcePixmap( Qt::LogicalCoordinates, &offset );
51+
}
52+
else
53+
{
54+
// Draw pixmap in device coordinates to avoid pixmap scaling;
55+
pixmap = sourcePixmap( Qt::DeviceCoordinates, &offset );
56+
painter->setWorldTransform( QTransform() );
57+
}
58+
59+
painter->drawPixmap( offset, pixmap );
3960

4061
}
4162

src/core/composer/qgscomposeritem.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ void QgsComposerItem::init( bool manageZValue )
103103
// Setup composer effect
104104
mEffect = new QgsComposerEffect();
105105
setGraphicsEffect( mEffect );
106+
106107
}
107108

108109
QgsComposerItem::~QgsComposerItem()

0 commit comments

Comments
 (0)