Skip to content
Browse files

Tweak logic regarding page item margins following forced re-render

of layout items when exporting (i.e. disabling of cached item render)

The old issue of semi-transparent pixels around the edge of the page
had reared again. This is caused by the antialiasing while rendering
the page symbol. In order to avoid this, we cater to the most common
use case of having pages with a solid, borderless fill and slightly
extend the fill symbol polygon outside the page by 2 pixels
(determined by trial-and-error). The less common use case of having
a page symbol containing a border suffers by this border being
clipped by a couple of pixels, but we must address the much more
common use case over this.
  • Loading branch information
nyalldawson committed Dec 12, 2017
1 parent d3aee95 commit 2b0ed508bddffcccf5d553cd854988cc52018749
@@ -216,10 +216,11 @@ void QgsLayoutItemPage::draw( QgsRenderContext &context, const QStyleOptionGraph
//Now subtract 1 pixel to prevent semi-transparent borders at edge of solid page caused by
//anti-aliased painting. This may cause a pixel to be cropped from certain edge lines/symbols,
//but that can be counteracted by adding a dummy transparent line symbol layer with a wider line width
maxBleedPixels = std::floor( maxBleedPixels - 2 );

// round up
QPolygonF pagePolygon = QPolygonF( QRectF( maxBleedPixels, maxBleedPixels,
( rect().width() * scale - 2 * maxBleedPixels ), ( rect().height() * scale - 2 * maxBleedPixels ) ) );
std::ceil( rect().width() * scale ) - 2 * maxBleedPixels, std::ceil( rect().height() * scale ) - 2 * maxBleedPixels ) );
QList<QPolygonF> rings; //empty list

symbol->renderPolygon( pagePolygon, &rings, nullptr, context );
Binary file not shown.

0 comments on commit 2b0ed50

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