mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Use white bg color for test images to avoid black background
This commit is contained in:
parent
60c3dcf96b
commit
59ca985928
@ -149,7 +149,7 @@ Generates legend symbol items according to the configuration
|
||||
Does nothing if legend is not configured as collapsed.
|
||||
%End
|
||||
|
||||
QImage collapsedLegendImage( QgsRenderContext &context, double paddingMM = 1 ) const;
|
||||
QImage collapsedLegendImage( QgsRenderContext &context, const QColor &backgroundColor = Qt::transparent, double paddingMM = 1 ) const;
|
||||
%Docstring
|
||||
Returns output image that would be shown in the legend. Returns invalid image if legend is not configured as collapsed.
|
||||
:rtype: QImage
|
||||
|
@ -261,7 +261,7 @@ void QgsDataDefinedSizeLegend::drawCollapsedLegend( QgsRenderContext &context, Q
|
||||
}
|
||||
|
||||
|
||||
QImage QgsDataDefinedSizeLegend::collapsedLegendImage( QgsRenderContext &context, double paddingMM ) const
|
||||
QImage QgsDataDefinedSizeLegend::collapsedLegendImage( QgsRenderContext &context, const QColor &backgroundColor, double paddingMM ) const
|
||||
{
|
||||
if ( mType != LegendCollapsed || mSizeClasses.isEmpty() || !mSymbol )
|
||||
return QImage();
|
||||
@ -276,7 +276,7 @@ QImage QgsDataDefinedSizeLegend::collapsedLegendImage( QgsRenderContext &context
|
||||
QImage img( contentSize.width() + padding * 2, contentSize.height() + padding * 2, QImage::Format_ARGB32_Premultiplied );
|
||||
img.setDotsPerMeterX( dpm );
|
||||
img.setDotsPerMeterY( dpm );
|
||||
img.fill( Qt::transparent );
|
||||
img.fill( backgroundColor );
|
||||
|
||||
QPainter painter( &img );
|
||||
painter.setRenderHint( QPainter::Antialiasing, true );
|
||||
|
@ -121,7 +121,7 @@ class CORE_EXPORT QgsDataDefinedSizeLegend
|
||||
void drawCollapsedLegend( QgsRenderContext &context, QSize *outputSize SIP_OUT = nullptr, int *labelXOffset SIP_OUT = nullptr ) const;
|
||||
|
||||
//! Returns output image that would be shown in the legend. Returns invalid image if legend is not configured as collapsed.
|
||||
QImage collapsedLegendImage( QgsRenderContext &context, double paddingMM = 1 ) const;
|
||||
QImage collapsedLegendImage( QgsRenderContext &context, const QColor &backgroundColor = Qt::transparent, double paddingMM = 1 ) const;
|
||||
|
||||
//! Creates instance from given element and returns it (caller takes ownership). Returns null on error.
|
||||
static QgsDataDefinedSizeLegend *readXml( const QDomElement &elem, const QgsReadWriteContext &context ) SIP_FACTORY;
|
||||
|
@ -114,13 +114,13 @@ void TestQgsDataDefinedSizeLegend::testBasic()
|
||||
|
||||
QgsRenderContext context( _createRenderContext( 100, 96, 100 ) );
|
||||
|
||||
QImage imgBottom = settings.collapsedLegendImage( context, 1 );
|
||||
QImage imgBottom = settings.collapsedLegendImage( context, Qt::white, 1 );
|
||||
imgBottom.save( _fileNameForTest( "basic_bottom" ) );
|
||||
QVERIFY( _verifyImage( "basic_bottom", mReport ) );
|
||||
|
||||
settings.setVerticalAlignment( QgsDataDefinedSizeLegend::AlignCenter );
|
||||
|
||||
QImage imgCenter = settings.collapsedLegendImage( context, 1 );
|
||||
QImage imgCenter = settings.collapsedLegendImage( context, Qt::white, 1 );
|
||||
imgCenter.save( _fileNameForTest( "basic_center" ) );
|
||||
QVERIFY( _verifyImage( "basic_center", mReport ) );
|
||||
}
|
||||
@ -149,7 +149,7 @@ void TestQgsDataDefinedSizeLegend::testCrowded()
|
||||
|
||||
QgsRenderContext context( _createRenderContext( 100, 96, 100 ) );
|
||||
|
||||
QImage img = settings.collapsedLegendImage( context, 1 );
|
||||
QImage img = settings.collapsedLegendImage( context, Qt::white, 1 );
|
||||
img.save( _fileNameForTest( "crowded" ) );
|
||||
|
||||
QVERIFY( _verifyImage( "crowded", mReport ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user