Scaled and transform Qgraphicspixmapitem
Asked Answered
O

1

2

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.

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.

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.

The code is :

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);
Ommatidium answered 6/5, 2015 at 6:12 Comment(0)
A
2

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);
Acreinch answered 6/5, 2015 at 6:46 Comment(5)
Thanks for reply Netaj. Image is more clear than before but not as it is with its original pixels.Is there any way to prevent original clarity.Ommatidium
When scaling, quality reduction is inevitable. Techniques like smooth transformation just makes it better and nothing more could be done.Acreinch
Thanks for responding :)Ommatidium
Using SVG image with QGraphicsSvgItem could help preserve the qualityFestoonery
@Festoonery , QGraphicsSvgItem seems only handle svg files? How about the other files?Faith

© 2022 - 2024 — McMap. All rights reserved.