Bin mit mathematik etwas kalt geworden...
es geht ja nur um eine bilder drehung....
Code: Alles auswählen
void EditorPics::setRotate( const int r )
{
if (LastAngleRotate == r) {
return;
}
NopermissionReselection = true;
LastAngleRotate = r;
rubberBand->hide();
Selection = QRect(0,0,0,0); /* QRubberBand go NULL novalid */
if (r < 360) {
QPixmap rotate_pic = QPixmap(OriginalCopypic);
int massimo = qMax(rotate_pic.width(),rotate_pic.height()); /* find max cube from image diagonale */
int fotox = (massimo / 2) - (rotate_pic.width() / 2);
int fotoy = (massimo / 2) - (rotate_pic.height() / 2);
QPixmap nuovo(massimo,massimo);
nuovo.fill( Qt::transparent );
QPainter painter;
painter.begin(&nuovo);
painter.setRenderHint(QPainter::Antialiasing);
painter.translate((massimo / 2),(massimo / 2));
painter.rotate(r);
painter.translate(-(massimo / 2),-(massimo / 2));
painter.drawPixmap(fotox,fotoy,rotate_pic);
painter.end();
pic = nuovo; /* new image */
update();
setMinimumSize(sizeHint());
setMaximumSize(sizeHint());
LastAngleRotate = r;
}
}