#include "thblend.h"
 
thblend::thblend()
{
}

void thblend::run()
{
	// *** Fondu enchaine ***
	for (int y = 0; y < srcImage.height(); y++)
	{
		for (int x = 0; x < srcImage.width(); x++)
		{
			srcPixel = srcImage.pixel(x, y);
			srcPixel2 = srcImage2.pixel(x, y);
			tmpcolor1 = srcPixel;
			tmpcolor2 = srcPixel2;
			tmpcolor3.setRed(tmpcolor1.red() * (1-(sequence/(float)100)) + tmpcolor2.red() * (sequence/(float)100));
			tmpcolor3.setGreen(tmpcolor1.green() * (1-(sequence/(float)100)) + tmpcolor2.green() * (sequence/(float)100));
			tmpcolor3.setBlue(tmpcolor1.blue() * (1-(sequence/(float)100)) + tmpcolor2.blue() * (sequence/(float)100));
			dstImage.setPixel(x, y, tmpcolor3.rgba());
		}				
	}
	if ( sequence < 100 )
	{
		sequence+=20;
		emit stepend();
	}
	else
	{
		emit endblend();
	}
}

