[Qt-interest] QImage fade
Mihail Naydenov
mlists at ymail.com
Sat May 7 09:02:08 CEST 2011
The main speedup is not to do it yourself probably.
I do not know I you have tested it, but this is trivial using the painter.
Especially if this is for the screen and you can use Pixmaps.
MihailNaydenov
----- Original Message ----
> From: Joshua Grauman <jnfo-c at grauman.com>
> To: qt-interest at qt.nokia.com
> Sent: Sat, May 7, 2011 3:41:44 AM
> Subject: [Qt-interest] QImage fade
>
> Hello all,
>
> I've written a little function to fade two QImages to a 3rd. It works fine
> and the results are expected. I cycle through fadeval values to fade the
> two images. I was wondering if anyone had any tricks I'm missing to *speed
> it up* though...
>
> FYI the function is dependant on all three QImages being the same size,
> and they all need to be QImage::Format_ARGB32...
>
>
> static int fadeMax=50;
>
> void fadeImages(QImage *dest, QImage *src1, QImage *src2, unsigned char
>fadeval)
> {
> for(int y = 0; y < dest->height(); y++)
> {
> QRgb *destrow = (QRgb*)dest->scanLine(y);
> QRgb *src1row = (QRgb*)src1->scanLine(y);
> QRgb *src2row = (QRgb*)src2->scanLine(y);
> for(int x = 0; x < dest->width(); x++)
> {
> ((unsigned char*)&destrow[x])[0] = (((unsigned
>char*)&src1row[x])[0]*fadeval/fadeMax + ((unsigned
>char*)&src2row[x])[0]*(fadeMax-fadeval)/fadeMax);
> ((unsigned char*)&destrow[x])[1] = (((unsigned
>char*)&src1row[x])[1]*fadeval/fadeMax + ((unsigned
>char*)&src2row[x])[1]*(fadeMax-fadeval)/fadeMax);
> ((unsigned char*)&destrow[x])[2] = (((unsigned
>char*)&src1row[x])[2]*fadeval/fadeMax + ((unsigned
>char*)&src2row[x])[2]*(fadeMax-fadeval)/fadeMax);
> ((unsigned char*)&destrow[x])[3] = 255;
> }
> }
> }
>
>
> Josh
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
More information about the Qt-interest-old
mailing list