Skip to content
Permalink
Browse files

Switch to RGB32 images for composition checker

  • Loading branch information
nyalldawson authored and m-kuhn committed Nov 14, 2014
1 parent 2cfcca1 commit 31c32505bbcddd9da21aad91441c8507474a100b
Showing with 37 additions and 9 deletions.
  1. +7 −0 python/core/qgsrenderchecker.sip
  2. +21 −0 src/core/qgsrenderchecker.cpp
  3. +5 −0 src/core/qgsrenderchecker.h
  4. +2 −2 tests/src/core/qgscompositionchecker.cpp
  5. +0 −5 tests/src/core/qgscompositionchecker.h
  6. +2 −2 tests/src/python/qgscompositionchecker.py
  7. BIN tests/testdata/control_images/expected_atlas_autoscale1/expected_atlas_autoscale1.png
  8. BIN tests/testdata/control_images/expected_atlas_autoscale2/expected_atlas_autoscale2.png
  9. BIN ...s/testdata/control_images/expected_atlas_autoscale_old_api1/expected_atlas_autoscale_old_api1.png
  10. BIN ...s/testdata/control_images/expected_atlas_autoscale_old_api2/expected_atlas_autoscale_old_api2.png
  11. BIN tests/testdata/control_images/expected_atlas_filtering1/expected_atlas_filtering1.png
  12. BIN tests/testdata/control_images/expected_atlas_fixedscale1/expected_atlas_fixedscale1.png
  13. BIN tests/testdata/control_images/expected_atlas_fixedscale2/expected_atlas_fixedscale2.png
  14. BIN ...testdata/control_images/expected_atlas_fixedscale_old_api1/expected_atlas_fixedscale_old_api1.png
  15. BIN ...testdata/control_images/expected_atlas_fixedscale_old_api2/expected_atlas_fixedscale_old_api2.png
  16. BIN tests/testdata/control_images/expected_atlas_hiding1/expected_atlas_hiding1.png
  17. BIN tests/testdata/control_images/expected_atlas_hiding2/expected_atlas_hiding2.png
  18. BIN tests/testdata/control_images/expected_atlas_predefinedscales1/expected_atlas_predefinedscales1.png
  19. BIN tests/testdata/control_images/expected_atlas_predefinedscales2/expected_atlas_predefinedscales2.png
  20. BIN tests/testdata/control_images/expected_atlas_sorting1/expected_atlas_sorting1.png
  21. BIN tests/testdata/control_images/expected_atlas_sorting2/expected_atlas_sorting2.png
  22. BIN tests/testdata/control_images/expected_atlas_two_maps1/expected_atlas_two_maps1.png
  23. BIN tests/testdata/control_images/expected_atlas_two_maps2/expected_atlas_two_maps2.png
  24. BIN ...mages/expected_composerattributetable_columnwidth/expected_composerattributetable_columnwidth.png
  25. BIN ...ol_images/expected_composerattributetable_drawempty/expected_composerattributetable_drawempty.png
  26. BIN ...mages/expected_composerattributetable_headersonly/expected_composerattributetable_headersonly.png
  27. BIN ...ol_images/expected_composerattributetable_hidetable/expected_composerattributetable_hidetable.png
  28. BIN .../control_images/expected_composerattributetable_render/expected_composerattributetable_render.png
  29. BIN ...mages/expected_composerattributetable_showmessage/expected_composerattributetable_showmessage.png
  30. BIN tests/testdata/control_images/expected_composereffects_blend/expected_composereffects_blend.png
  31. BIN ...ta/control_images/expected_composereffects_transparency/expected_composereffects_transparency.png
  32. BIN ..._images/expected_composerhtml_expressions_disabled/expected_composerhtml_expressions_disabled.png
  33. BIN ...ol_images/expected_composerhtml_expressions_enabled/expected_composerhtml_expressions_enabled.png
  34. BIN tests/testdata/control_images/expected_composerhtml_manual/expected_composerhtml_manual.png
  35. BIN ...ta/control_images/expected_composerhtml_multiframe1/default/expected_composerhtml_multiframe1.png
  36. BIN ...ta/control_images/expected_composerhtml_multiframe2/default/expected_composerhtml_multiframe2.png
  37. BIN .../control_images/expected_composerhtml_smartbreaks1/default/expected_composerhtml_smartbreaks1.png
  38. BIN .../control_images/expected_composerhtml_smartbreaks2/default/expected_composerhtml_smartbreaks2.png
  39. BIN tests/testdata/control_images/expected_composerhtml_table/default/expected_composerhtml_table.png
  40. BIN ...data/control_images/expected_composerhtml_userstylesheet/expected_composerhtml_userstylesheet.png
  41. BIN tests/testdata/control_images/expected_composermap_crossgrid/expected_composermap_crossgrid.png
  42. BIN ...testdata/control_images/expected_composermap_exteriorticks/expected_composermap_exteriorticks.png
  43. BIN ...ges/expected_composermap_exteriorticks_annotated/expected_composermap_exteriorticks_annotated.png
  44. BIN ...s/expected_composermap_exteriorticks_annotated2/expected_composermap_exteriorticks_annotated2.png
  45. BIN ...trol_images/expected_composermap_filteredannotations/expected_composermap_filteredannotations.png
  46. BIN ...stdata/control_images/expected_composermap_framedivisions/expected_composermap_framedivisions.png
  47. BIN tests/testdata/control_images/expected_composermap_grid/expected_composermap_grid.png
  48. BIN ...testdata/control_images/expected_composermap_gridframeonly/expected_composermap_gridframeonly.png
  49. BIN ...data/control_images/expected_composermap_gridreprojected/expected_composermap_gridreprojected.png
  50. BIN ..._images/expected_composermap_interiorexteriorticks/expected_composermap_interiorexteriorticks.png
  51. BIN ...posermap_interiorexteriorticks_annotated/expected_composermap_interiorexteriorticks_annotated.png
  52. BIN ...sermap_interiorexteriorticks_annotated2/expected_composermap_interiorexteriorticks_annotated2.png
  53. BIN ...testdata/control_images/expected_composermap_interiorticks/expected_composermap_interiorticks.png
  54. BIN ...ges/expected_composermap_interiorticks_annotated/expected_composermap_interiorticks_annotated.png
  55. BIN ...s/expected_composermap_interiorticks_annotated2/expected_composermap_interiorticks_annotated2.png
  56. BIN tests/testdata/control_images/expected_composermap_lineborder/expected_composermap_lineborder.png
  57. BIN ...ol_images/expected_composermap_lineborder_annotated/expected_composermap_lineborder_annotated.png
  58. BIN ..._images/expected_composermap_lineborder_annotated2/expected_composermap_lineborder_annotated2.png
  59. BIN tests/testdata/control_images/expected_composermap_markergrid/expected_composermap_markergrid.png
  60. BIN tests/testdata/control_images/expected_composermap_overview/expected_composermap_overview.png
  61. BIN .../control_images/expected_composermap_overview_blending/expected_composermap_overview_blending.png
  62. BIN ...data/control_images/expected_composermap_overview_center/expected_composermap_overview_center.png
  63. BIN ...data/control_images/expected_composermap_overview_invert/expected_composermap_overview_invert.png
  64. BIN ...ta/control_images/expected_composermap_overview_rotated/expected_composermap_overview_rotated.png
  65. BIN .../control_images/expected_composermap_overview_rotated2/expected_composermap_overview_rotated2.png
  66. BIN tests/testdata/control_images/expected_composermap_render/expected_composermap_render.png
  67. BIN ...ontrol_images/expected_composermap_rotatedannotations/expected_composermap_rotatedannotations.png
  68. BIN ...s/testdata/control_images/expected_composermap_rotatedframe/expected_composermap_rotatedframe.png
  69. BIN ...expected_composermap_verticaldescending_inside/expected_composermap_verticaldescending_inside.png
  70. BIN ...pected_composermap_verticaldescending_outside/expected_composermap_verticaldescending_outside.png
  71. BIN tests/testdata/control_images/expected_composermap_zebrastyle/expected_composermap_zebrastyle.png
  72. BIN ...data/control_images/expected_composermap_zebrastyle_left/expected_composermap_zebrastyle_left.png
  73. BIN ...ontrol_images/expected_composermap_zebrastyle_lefttop/expected_composermap_zebrastyle_lefttop.png
  74. BIN ...ges/expected_composermap_zebrastyle_lefttopright/expected_composermap_zebrastyle_lefttopright.png
  75. BIN tests/testdata/control_images/expected_composerpaper_bordered/expected_composerpaper_bordered.png
  76. BIN tests/testdata/control_images/expected_composerpaper_default/expected_composerpaper_default.png
  77. BIN ...stdata/control_images/expected_composerpaper_markerborder/expected_composerpaper_markerborder.png
  78. BIN ...testdata/control_images/expected_composerpaper_transparent/expected_composerpaper_transparent.png
  79. BIN .../control_images/expected_composerpicture_badexpression/expected_composerpicture_badexpression.png
  80. BIN ...data/control_images/expected_composerpicture_clip_anchor/expected_composerpicture_clip_anchor.png
  81. BIN ...ges/expected_composerpicture_clip_anchoroversize/expected_composerpicture_clip_anchoroversize.png
  82. BIN ...stdata/control_images/expected_composerpicture_expression/expected_composerpicture_expression.png
  83. BIN ...ta/control_images/expected_composerpicture_itemrotation/expected_composerpicture_itemrotation.png
  84. BIN tests/testdata/control_images/expected_composerpicture_remote/expected_composerpicture_remote.png
  85. BIN ...data/control_images/expected_composerpicture_resize_clip/expected_composerpicture_resize_clip.png
  86. BIN ...ges/expected_composerpicture_resize_frametoimage/expected_composerpicture_resize_frametoimage.png
  87. BIN ...ontrol_images/expected_composerpicture_resize_stretch/expected_composerpicture_resize_stretch.png
  88. BIN ...data/control_images/expected_composerpicture_resize_zoom/expected_composerpicture_resize_zoom.png
  89. BIN ..._images/expected_composerpicture_resize_zoomresize/expected_composerpicture_resize_zoomresize.png
  90. BIN ...s/testdata/control_images/expected_composerpicture_rotation/expected_composerpicture_rotation.png
  91. BIN ...ol_images/expected_composerpicture_svg_frametoimage/expected_composerpicture_svg_frametoimage.png
  92. BIN ...data/control_images/expected_composerpicture_svg_stretch/expected_composerpicture_svg_stretch.png
  93. BIN ...s/testdata/control_images/expected_composerpicture_svg_zoom/expected_composerpicture_svg_zoom.png
  94. BIN ...ontrol_images/expected_composerpicture_svg_zoomresize/expected_composerpicture_svg_zoomresize.png
  95. BIN ...data/control_images/expected_composerpicture_zoom_anchor/expected_composerpicture_zoom_anchor.png
  96. BIN tests/testdata/control_images/expected_composerrotation_label/expected_composerrotation_label.png
  97. BIN ...ol_images/expected_composerrotation_mapitemrotation/expected_composerrotation_mapitemrotation.png
  98. BIN ...ta/control_images/expected_composerrotation_maprotation/expected_composerrotation_maprotation.png
  99. BIN tests/testdata/control_images/expected_composerrotation_shape/expected_composerrotation_shape.png
  100. BIN ...stdata/control_images/expected_composerscalebar_doublebox/expected_composerscalebar_doublebox.png
  101. BIN ...s/testdata/control_images/expected_composerscalebar_numeric/expected_composerscalebar_numeric.png
  102. BIN ...stdata/control_images/expected_composerscalebar_singlebox/expected_composerscalebar_singlebox.png
  103. BIN ...ol_images/expected_composerscalebar_singlebox_alpha/expected_composerscalebar_singlebox_alpha.png
  104. BIN tests/testdata/control_images/expected_composerscalebar_tick/expected_composerscalebar_tick.png
  105. BIN tests/testdata/control_images/expected_composershapes_ellipse/expected_composershapes_ellipse.png
  106. BIN ...s/testdata/control_images/expected_composershapes_rectangle/expected_composershapes_rectangle.png
  107. BIN ...stdata/control_images/expected_composershapes_roundedrect/expected_composershapes_roundedrect.png
  108. BIN tests/testdata/control_images/expected_composershapes_symbolv2/expected_composershapes_symbolv2.png
  109. BIN tests/testdata/control_images/expected_composershapes_triangle/expected_composershapes_triangle.png
  110. BIN tests/testdata/control_images/expected_piediagram/expected_piediagram.png
  111. BIN tests/testdata/control_images/expected_piediagram_expression/expected_piediagram_expression.png
@@ -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 );
};
@@ -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
@@ -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;
@@ -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 );
@@ -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 );
@@ -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;
@@ -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()
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.