旋转图片

作者: 巴黎人在线官网平台  发布:2019-08-01
QPainter painter(this);
QPixmap pix("./logo.jpg");

if( ! pix.isNull() )
{
    QMatrix matrix;
    matrix.rotate(90);
    QPixmap pixTr = pix.transformed(matrix);
    pixTr.save("logo90.jpg");

    setGeometry(0, 0, pixTr.width(), pixTr.height());

    painter.drawPixmap(0, 0, pixTr);
}

 QPainter painter(this);
 painter.setPen(QPen(Qt::blue, 1, Qt::DashLine));
 painter.drawRect(0, 0, 100, 100);

 QMatrix matrix;
 matrix.translate(50, 50);
 matrix.rotate(45);
 matrix.scale(0.5, 1.0);
 painter.setMatrix(matrix);

 painter.setFont(QFont("Helvetica", 24));
 painter.setPen(QPen(Qt::black, 1));
 painter.drawText(20, 10, "QMatrix");
//该片段来自于http://outofmemory.cn

本文由巴黎人游戏官网发布于巴黎人在线官网平台,转载请注明出处:旋转图片

关键词: