Skip to content

Commit

Permalink
Switch to RGB32 images for composition checker
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson authored and m-kuhn committed Nov 14, 2014
1 parent 2cfcca1 commit 31c3250
Show file tree
Hide file tree
Showing 111 changed files with 37 additions and 9 deletions.
7 changes: 7 additions & 0 deletions python/core/qgsrenderchecker.sip
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,11 @@ class QgsRenderChecker
bool isKnownAnomaly( QString theDiffImageFile );

QString expectedImageFile();

protected:

/**Draws a checkboard pattern for image backgrounds, so that transparency is visible
* without requiring a transparent background for the image
*/
void drawBackround( QImage* image );
};
21 changes: 21 additions & 0 deletions src/core/qgsrenderchecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,27 @@ void QgsRenderChecker::setMapSettings( const QgsMapSettings& mapSettings )
mMapSettings = mapSettings;
}

void QgsRenderChecker::drawBackround( QImage* image )
{
// create a 2x2 checker-board image
uchar pixDataRGB[] = { 255, 255, 255, 255,
127, 127, 127, 255,
127, 127, 127, 255,
255, 255, 255, 255
};

QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
QPixmap pix = QPixmap::fromImage( img.scaled( 20, 20 ) );

// fill image with texture
QBrush brush;
brush.setTexture( pix );
QPainter p( image );
p.setRenderHint( QPainter::Antialiasing, false );
p.fillRect( QRect( 0, 0, image->width(), image->height() ), brush );
p.end();
}

bool QgsRenderChecker::isKnownAnomaly( QString theDiffImageFile )
{
QString myControlImageDir = controlImagePath() + mControlName
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgsrenderchecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ class CORE_EXPORT QgsRenderChecker
QString mRenderedImageFile;
QString mExpectedImageFile;

/**Draws a checkboard pattern for image backgrounds, so that transparency is visible
* without requiring a transparent background for the image
*/
void drawBackround( QImage* image );

private:
QString mControlName;
unsigned int mMismatchCount;
Expand Down
4 changes: 2 additions & 2 deletions tests/src/core/qgscompositionchecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ bool QgsCompositionChecker::testComposition( QString &theReport, int page, int p
#if 0
//fake mode to generate expected image
//assume 96 dpi and size of the control image 1122 * 794
QImage newImage( QSize( 1122, 794 ), QImage::Format_ARGB32 );
QImage newImage( QSize( 1122, 794 ), QImage::Format_RGB32 );
mComposition->setPlotStyle( QgsComposition::Print );
newImage.setDotsPerMeterX( 96 / 25.4 * 1000 );
newImage.setDotsPerMeterY( 96 / 25.4 * 1000 );
Expand All @@ -87,7 +87,7 @@ bool QgsCompositionChecker::testComposition( QString &theReport, int page, int p
return true;
#endif //0

QImage outputImage( mSize, QImage::Format_ARGB32 );
QImage outputImage( mSize, QImage::Format_RGB32 );

mComposition->setPlotStyle( QgsComposition::Print );
outputImage.setDotsPerMeterX( mDotsPerMeter );
Expand Down
5 changes: 0 additions & 5 deletions tests/src/core/qgscompositionchecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ class QgsCompositionChecker : public QgsMultiRenderChecker
private:
QgsCompositionChecker(); //forbidden

/**Draws a checkboard pattern for image backgrounds, so that transparency is visible
* without requiring a transparent background for the image
*/
void drawBackround( QImage* image );

QString mTestName;
QgsComposition* mComposition;
QSize mSize;
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/qgscompositionchecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ def testComposition(self, page=0, pixelDiff=0 ):
#get width/height, create image and render the composition to it
width = expectedImage.width();
height = expectedImage.height();
outputImage = QImage( QSize( width, height ), QImage.Format_ARGB32 )
outputImage = QImage( QSize( width, height ), QImage.Format_RGB32 )

self.mComposition.setPlotStyle( QgsComposition.Print )
outputImage.setDotsPerMeterX( expectedImage.dotsPerMeterX() )
outputImage.setDotsPerMeterY( expectedImage.dotsPerMeterX() )
outputImage.fill( 0 )
self.drawBackround( outputImage )
p = QPainter( outputImage )
self.mComposition.renderPage( p, page )
p.end()
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.