缩放和转换QgraphicsPixMapiTem
Scaled and transform Qgraphicspixmapitem
我在缩放和转换QGraphicsPixmapItem
时有问题。我创建了图形编辑器,其中我使用的是初始尺寸为100,100的QGraphicsItem
,然后通过setTransform()
方法调整和旋转。
之后,我正在存储此转换,并将其用于我的另一个名为"播放器"的应用程序,其中我正在使用这些转换并在其上显示图像和视频,如果我设置了scaleded and setTransform
方法,我正在使用 QgraphicsPixmapItem
立即显示图像图像它的清晰度被宠坏了。
即使我对其进行缩放和转换也可以保持清晰度。我正在使用的图像为2560x1440像素。任何帮助将不胜感激。
代码是:
QGraphicsPixmapItem *pixitem = new QGraphicsPixmapItem;
pixitem->setFlags(QGraphicsItem::ItemIsMovable);
pixitem->setPos(50,50);
QTransform trans;
trans.setMatrix(4.20399,2.9286,0,-3.86601,0.761397,0,33.1015,-134.5,1);
pixitem->setPixmap(QPixmap("abc.jpg").scaled(100,100));
pixitem->setTransform(trans);
pixitem->setShapeMode(QGraphicsPixmapItem::MaskShape);
scene->addItem(pixitem);
您可以使用setTransformationMode
函数设置PixMap项目的转换模式。默认值为Qt::FastTransformation
。您应该将转换模式设置为 Qt::SmoothTransformation
,以启用双线性过滤,从而在缩放时会产生质量更好的质量:
pixitem->setTransformationMode(Qt::SmoothTransformation);