fix image distortion for card images after playing a while

This commit is contained in:
doitux
2007-11-08 11:45:24 +00:00
parent 0326c0be26
commit d0aa437dec
3 changed files with 30 additions and 37 deletions
+10 -16
View File
@@ -29,10 +29,7 @@ MyCardsPixmapLabel::MyCardsPixmapLabel(QFrame* parent)
// rotationIntervall = 0.03;
isFlipside = FALSE;
front = new QPixmap;
flipside = new QPixmap;
fadeOutTimer = new QTimer;
connect(fadeOutTimer, SIGNAL(timeout()), this, SLOT(nextFadeOutFrame()));
flipCardsTimer = new QTimer;
@@ -78,7 +75,7 @@ void MyCardsPixmapLabel::nextFadeOutFrame() {
}
void MyCardsPixmapLabel::startFlipCards(int speed, QPixmap frontPix, QPixmap *flipsidePix) {
void MyCardsPixmapLabel::startFlipCards(int speed, const QPixmap &frontPix, const QPixmap &flipsidePix) {
stopFlipCards = FALSE;
@@ -87,11 +84,8 @@ void MyCardsPixmapLabel::startFlipCards(int speed, QPixmap frontPix, QPixmap *fl
frameFlipCardsAction1Size = 1.0;
frameFlipCardsAction2Size = 0.0;
*front = frontPix;
flipside = flipsidePix;
*flipside = flipside->scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
*front = front->scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
front = frontPix.scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);;
flipside = flipsidePix.scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);;
if(speed <= 4) { flipCardsScaleIntervall = 0.1; }
if(speed > 4 && speed <= 6) { flipCardsScaleIntervall = 0.20; }
@@ -152,7 +146,7 @@ void MyCardsPixmapLabel::setPixmap(const QPixmap &pic, const bool flipsideIs) {
void MyCardsPixmapLabel::setFrontPixmap ( const QPixmap &pic ) {
myHiddenFront = pic;
myHiddenFront = pic.scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);;
}
void MyCardsPixmapLabel::paintEvent(QPaintEvent * event) {
@@ -180,26 +174,26 @@ void MyCardsPixmapLabel::paintEvent(QPaintEvent * event) {
if (flipCardsAction1) {
QPainter painter2(this);
QPointF center(flipside->width()/2.0, flipside->height()/2.0);
QPointF center(flipside.width()/2.0, flipside.height()/2.0);
painter2.translate(center);
painter2.scale(frameFlipCardsAction1Size ,1);
painter2.translate(-center);
painter2.drawPixmap(0,0, *flipside);
painter2.drawPixmap(0,0, flipside);
}
if (flipCardsAction2) {
QPainter painter3(this);
QPointF center(front->width()/2.0, front->height()/2.0);
QPointF center(front.width()/2.0, front.height()/2.0);
painter3.translate(center);
painter3.scale(frameFlipCardsAction2Size ,1);
painter3.translate(-center);
painter3.drawPixmap(0,0, *front);
painter3.drawPixmap(0,0, front);
}
if (fastFlipCardsFront && !fadeOutAction && !flipCardsAction1 && !flipCardsAction2) {
if(objectName().contains("pixmapLabel_card0")) {
QPainter painter4(this);
painter4.drawPixmap(0,0, myHiddenFront.scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
painter4.drawPixmap(0,0, myHiddenFront);
}
}
}