#include <QBitmap> #include <QFile> #include <QImage> #include <QImageReader> #include <QPainter> #include "util.h" QString imageInfo( char* file, QSize size ) { QString result; result += file; result += ": "; result += QImageReader::imageFormat( file ).toUpper(); result += " image, "; result += QString::number( size.width() ); result += "x"; result += QString::number( size.height() ); result += " pixels, "; unsigned int b = QFile( file ).size(); if ( b < 512 ) { result += QString::number( b, 'G', 3 ); result += " bytes"; } else if ( b < 524288 ) { result += QString::number( b / 1024.0, 'G', 3 ); result += " kb"; } else { result += QString::number( b / 1048576.0, 'G', 3 ); result += " Mb"; } return result; } void imageDiff( QImage i1, QImage i2, QBitmap* diff, float tolerance ) { if ( i1.size() != i2.size() ) return; if ( !diff || diff->size() != i1.size() ) return; short tol = tolerance * 255 * 3; QRgb c1, c2; short d; QPainter p( diff ); for ( int x = 0 ; x < i1.width() ; x++ ) { for ( int y = 0 ; y < i1.height() ; y++ ) { c1 = i1.pixel( x, y ); c2 = i2.pixel( x, y ); d = abs( qRed( c1 ) - qRed( c2 ) ); d += abs( qGreen( c1 ) - qGreen( c2 ) ); d += abs( qBlue( c1 ) - qBlue( c2 ) ); if ( d > tol ) { p.setPen( Qt::color0 ); } else { p.setPen( Qt::color1 ); } p.drawPoint( x, y ); } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 5505 | Sam Stafford | Add "diff stencil". | ||
#1 | 5502 | Sam Stafford |
Status bar with handy information, and infrastructure to allow ImageProjectors to have frames. |