if( isFitAll )
fitAll();
}
+
void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const char* theKey,
int theUIANb, int theVIANb)
{
return true;
}
+QImage TestViewer::diff( const QImage& theExpectedRefImage, const QImage& theActualImage )
+{
+ const QImage::Format aFormat = QImage::Format_RGB32;
+
+ QImage anExpectedRefImage = theExpectedRefImage.convertToFormat( aFormat );
+ QImage anActualImage = theActualImage.convertToFormat( aFormat );
+
+ QImage aDiff( anExpectedRefImage.width(), anExpectedRefImage.height(), aFormat );
+ QPainter aPainter( &aDiff );
+ aPainter.drawImage( 0, 0, anExpectedRefImage );
+ aPainter.setCompositionMode( QPainter::RasterOp_SourceXorDestination );
+ aPainter.drawImage( 0, 0, anActualImage );
+ return aDiff;
+}
+
bool TestViewer::AssertImages( QString& theMessage, const QImage* theImage, const char* theCase, bool swapRGB )
{
QImage anActualImage;
//std::cout << anActualImage.width() << "x" << anActualImage.height() << std::endl;
theMessage = "The viewer contents does not correspond to the reference image: " + myKey;
- QImage aDiff( anExpectedRefImage.width(), anExpectedRefImage.height(), QImage::Format_ARGB32 );
- QPainter aPainter( &aDiff );
- aPainter.drawImage( 0, 0, anExpectedRefImage );
- aPainter.setCompositionMode( QPainter::RasterOp_SourceXorDestination );
- aPainter.drawImage( 0, 0, anActualImage );
+ QImage aDiff = diff( anExpectedRefImage, anActualImage );
QString aDiffFilePath = temp + "/" + myKey + "_diff.png";
aDiff.save( aDiffFilePath );
#include <HYDROData_Document.h>
#include <HYDROData_Image.h>
+#include <TestViewer.h>
#include <QPainter>
+#include <QImage>
+
+extern QString REF_DATA_PATH;
static QImage TestImage() {
QImage aPic(50, 40, QImage::Format_RGB32);
aDoc->Close();
}
+
+void test_HYDROData_Image::testDiff()
+{
+ QImage im1, im2;
+ im1.load( REF_DATA_PATH + "/LandCover_Triangles.png" );
+ im2.load( REF_DATA_PATH + "/LandCover_Triangles_Split.png" );
+
+ QImage im3 = TestViewer::diff( im1, im2 );
+ CPPUNIT_ASSERT_IMAGES3( &im3, "diff_image", false );
+}