gpt4 book ai didi

c++ - 缩放和变换 Qgraphicspixmapitem

转载 作者:行者123 更新时间:2023-11-30 05:43:51 25 4
gpt4 key购买 nike

我在缩放和转换 QGraphicsPixmapItem 时遇到问题。我创建了图形编辑器,我在其中使用初始大小为 100,100 的 QGraphicsItem,之后我通过 setTransform() 方法调整大小和旋转它。

之后,我将存储此转换并将其用于我的另一个名为播放器的应用程序,我在其中使用这些转换并在其上显示图像和视频,我现在使用 QgraphicsPixmapItem 显示图像,如果我设置了缩放和 setTransform 方法来成像它的清晰度被破坏了。

是否可以保持清晰度,即使我缩放和转换它。我使用的图像是 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 函数来设置像素图项目的转换模式。默认值为 Qt::FastTransformation。您应该将转换模式设置为 Qt::SmoothTransformation 以启用双线性过滤,从而在缩放时获得更好的质量:

pixitem->setTransformationMode(Qt::SmoothTransformation);

关于c++ - 缩放和变换 Qgraphicspixmapitem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30068886/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com