缩放并转换Qgraphicspixmapitem [英] Scaled and transform Qgraphicspixmapitem
问题描述
缩放和转换QGraphicsPixmapItem
时遇到问题.我创建了图形编辑器,在其中使用初始大小为100,100的QGraphicsItem
,然后通过setTransform()
方法调整大小和旋转它.
I have a problem while scaling and transforming QGraphicsPixmapItem
. I have created graphics editor in which I am using QGraphicsItem
of initial size 100,100 and after that I am resizing and rotating it by setTransform()
method.
此后,我将存储此转换并将其用于另一个名为播放器的应用程序,在该应用程序中我将使用这些转换并在其上显示图像和视频,如果我设置了scale和setTransform
对其清晰度进行成像的方法被破坏了.
After that I am storing this transform and using these for my another application called player in which I am using those transform and showing images and videos on it, I am using QgraphicsPixmapItem
to show images now if I set scaled and setTransform
methods to image its clarity gets spoiled.
即使缩放和变换图像,也可以保持其清晰度.我使用的图像大小为2560x1440像素. 任何帮助将不胜感激.
Is it possible to keep clarity as it is even if I scaled and transform it.The image I am using is of 2560x1440 pixels. Any help will be appreciated.
代码是:
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
函数设置像素图项目的转换模式.默认值为Qt::FastTransformation
.您应该将转换模式设置为Qt::SmoothTransformation
以启用双线性过滤,这样在缩放时可获得更好的质量:
You can use setTransformationMode
function to set the pixmap item's transformation mode. The default value is Qt::FastTransformation
. You should set the transform mode to Qt::SmoothTransformation
to enable bilinear filtering which results in a better quality when scaled :
pixitem->setTransformationMode(Qt::SmoothTransformation);
这篇关于缩放并转换Qgraphicspixmapitem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!