#include "DiffWidget.h" #include "util.h" #include <QColorDialog> #include <QLayout> #include <QMessageBox> #include <QPalette> #include <QPainter> #include <QSlider> DiffWidget::DiffWidget( char* file1, char* file2 ) :BaseWidget( file1, file2 ) { //BaseWidget constructor sets up the two left projectors, the slider, //the scroll area, and the layouts. connect( slider, SIGNAL( valueChanged(int) ), this, SLOT( doBlend(int) ) ); main = new ImageProjector; main_l->addWidget( main ); diff = QImage( leg1.width(), leg1.height(), QImage::Format_ARGB32_Premultiplied ); //Scratch image scratch = QImage( leg1.width(), leg1.height(), QImage::Format_ARGB32_Premultiplied ); s_alpha = QImage( leg1.width(), leg1.height(), QImage::Format_Indexed8 ); QVector<QRgb> colors(256); for ( int i = 0 ; i < 256 ; i++ ) { colors[i] = qRgb( i, i, i ); } s_alpha.setColorTable( colors ); main->setImage( &diff ); slider->setRange( 0, 255 ); slider->setValue( 127 ); slider->setSingleStep( 16 ); slider->setPageStep( 255 ); mask = QBitmap( leg1.size() ); main->setMask( &mask ); } DiffWidget::~DiffWidget(void) { } void DiffWidget::doBlend( int eightBit ) { if ( diff.isNull() ) return; if ( eightBit == 0 ) { diff = leg2; } else if ( eightBit == 255 ) { diff = leg1; } else { s_alpha.fill( eightBit ); QPainter s; s.begin( &scratch ); s.drawImage( 0, 0, leg1 ); s.end(); scratch.setAlphaChannel( s_alpha ); QPainter p( &diff ); p.drawImage( 0, 0, leg2 ); p.drawImage( 0, 0, scratch ); } main->update(); } void DiffWidget::setDiffMask( bool on ) { main->setMaskEnabled( on ); } void DiffWidget::setTolerance( int dec ) { BaseWidget::setTolerance( dec ); imageDiff( leg1, leg2, &mask, tolerance ); main->update(); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#10 | 5548 | Sam Stafford |
Only apply alpha-channel diff fix to files that actually have alpha channels. (Painting images with no alpha channels on top of each other doesn't behave like I'd hoped it would.) |
||
#9 | 5543 | Sam Stafford |
Diffing transparent images produced some weird artifacts, since blending them requires hijacking the alpha channel. Fixed it by painting the images on top of opaque backgrounds before diffing them. |
||
#8 | 5539 | Sam Stafford | Kick off another window to merge alpha channels, if present. | ||
#7 | 5516 | Sam Stafford | The M is for Merge. | ||
#6 | 5512 | Sam Stafford | UI reshuffling - pushed stencil-related options into a dialog. | ||
#5 | 5508 | Sam Stafford | Infrastructure massaging to make way for Stage Two. | ||
#4 | 5506 | Sam Stafford | Better icons and default stencil color. | ||
#3 | 5505 | Sam Stafford | Add "diff stencil". | ||
#2 | 5502 | Sam Stafford |
Status bar with handy information, and infrastructure to allow ImageProjectors to have frames. |
||
#1 | 5501 | Sam Stafford |
Codename CALAMARI. Built with Qt 4.1.3 - needs QtCore4.dll and QtGui4.dll to run. |