enum FadeStyle {
NoFade,
FadeDown,
FadeRight,
FadeUp,
FadeLeft
};
enum MirrorStyle {
NoMirror,
MirrorOverX,
MirrorOverY
};
static inline QImage mirrorImage
(const QImage &img, MirrorStyle mirrorStyle
=MirrorOverX,
FadeStyle fadeStyle=FadeDown)
{
if (mirrorStyle != NoMirror)
tmpImage = tmpImage.mirrored(mirrorStyle == MirrorOverY,
mirrorStyle == MirrorOverX);
if (fadeStyle != NoFade) {
if (fadeStyle == FadeDown)
p2.setY(tmpImage.height());
else if (fadeStyle == FadeUp)
p1.setY(tmpImage.height());
else if (fadeStyle == FadeRight)
p2.setX(tmpImage.width());
else if (fadeStyle == FadeLeft)
p1.setX(tmpImage.width());
gradient.setColorAt(0, Qt::white);
gradient.
setColorAt(0.25,
QColor(0,
0,
0,
20));
gradient.setColorAt(1, Qt::transparent);
p.
setCompositionMode(QPainter::CompositionMode_DestinationIn);
p.fillRect(0, 0, tmpImage.width(), tmpImage.height(), gradient);
p.end();
}
return tmpImage;
}
enum FadeStyle {
NoFade,
FadeDown,
FadeRight,
FadeUp,
FadeLeft
};
enum MirrorStyle {
NoMirror,
MirrorOverX,
MirrorOverY
};
static inline QImage mirrorImage(const QImage &img, MirrorStyle mirrorStyle=MirrorOverX,
FadeStyle fadeStyle=FadeDown)
{
QImage tmpImage = img;
if (mirrorStyle != NoMirror)
tmpImage = tmpImage.mirrored(mirrorStyle == MirrorOverY,
mirrorStyle == MirrorOverX);
if (fadeStyle != NoFade) {
QPoint p1, p2;
if (fadeStyle == FadeDown)
p2.setY(tmpImage.height());
else if (fadeStyle == FadeUp)
p1.setY(tmpImage.height());
else if (fadeStyle == FadeRight)
p2.setX(tmpImage.width());
else if (fadeStyle == FadeLeft)
p1.setX(tmpImage.width());
QLinearGradient gradient(p1, p2);
gradient.setColorAt(0, Qt::white);
gradient.setColorAt(0.25, QColor(0, 0, 0, 20));
gradient.setColorAt(1, Qt::transparent);
QPainter p(&tmpImage);
p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
p.fillRect(0, 0, tmpImage.width(), tmpImage.height(), gradient);
p.end();
}
return tmpImage;
}
To copy to clipboard, switch view to plain text mode
Bookmarks