void Scene::genFrames() { QPixmap pixmap = QPixmap( QString( ":Textures/pla1.bmp" ) ); const unsigned int step = pixmap.width() / 4; QPixmap copyPixmap; for ( unsigned int i = 0; i < 4; ++i ) { copyPixmap = pixmap.copy( i * step, 0, step, step ); framesToRight.push_back( copyPixmap ); } for( unsigned int i = 0; i < framesToRight.size(); ++i ) { QImage image = framesToRight[i].toImage(); framesToLeft.push_back( QPixmap::fromImage( image.mirrored( true, false ) ) ); } for( unsigned int i = 0; i < framesToRight.size(); ++i ) { QPixmap rotatedPixmap( framesToRight[i] ); QMatrix rm; rm.rotate( 90 ); framesToDown.push_back( rotatedPixmap.transformed( rm ) ); } for( unsigned int i = 0; i < framesToDown.size(); ++i ) { QImage image = framesToDown[i].toImage(); framesToUp.push_back( QPixmap::fromImage( image.mirrored( false, true ) ) ); } }
QPixmap MainWindow::rotatePixmap(QPixmap *pixmapOriginal,qint16 degree) { QPixmap rotatedPixmap(pixmapOriginal->size()); rotatedPixmap.fill(Qt::transparent); QPainter p(&rotatedPixmap); p.setRenderHint(QPainter::Antialiasing); p.setRenderHint(QPainter::SmoothPixmapTransform); p.setRenderHint(QPainter::HighQualityAntialiasing); p.translate(rotatedPixmap.size().width() / 2, rotatedPixmap.size().height() / 2); p.rotate(degree); p.translate(-rotatedPixmap.size().width() / 2, -rotatedPixmap.size().height() / 2); p.drawPixmap(0, 0, *compassPixmap); p.end(); return rotatedPixmap; }
QPixmap GPS::rotatePixmap(int angle){ QSize size = Avion.size(); QPixmap rotatedPixmap(size); rotatedPixmap.fill(QColor::fromRgb(0, 0, 0, 0)); //the new pixmap must be transparent. QPainter* p = new QPainter(&rotatedPixmap); p->translate(size.height()/2,size.height()/2); p->rotate(angle); p->translate(-size.height()/2,-size.height()/2); p->drawPixmap(0, 0, Avion); p->end(); delete p; return rotatedPixmap; }