PDA

View Full Version : QGraphicsView ugly distortion yuck



genjix
23rd October 2010, 07:34
Hey.

I've made a bug report but searching around I could not find any similar questions so I thought maybe I'm doing something wrong?
http://img832.imageshack.us/img832/3521/distortion1.png
http://img202.imageshack.us/img202/8546/distortion2.png
That's QGraphicsView::scale(0.9, 0.9)... The distortion is really bad.
(I wrote a little demo app (http://bugreports.qt.nokia.com/secure/attachment/17851/test.zip) demonstrating this)

Now if I screenshot the app and then scale it using QImage (example (http://bugreports.qt.nokia.com/secure/attachment/17857/test.zip)), it's suddenly fine.

My idea is to draw QGraphicsScene onto a custom buffer and then scale that using a QImage for display. Unfortunately I can't find any way to get the rendered scene.

Can anyone give me any pointers how to do this?

Added after 52 minutes:

C++ Example (http://bugreports.qt.nokia.com/secure/attachment/17858/cpp_test.zip)
I just wrote that test to show what I mean for anyone who doesn't use PySide.

#include <QtGui>

#include "dialog.h"

Dialog::Dialog()
{
setWindowTitle(tr("Basic Layouts"));
QGraphicsScene *scene = new QGraphicsScene(this);
QPixmap *pic = new QPixmap("table.png");
scene->addPixmap(*pic);
view = new QGraphicsView();
view->setScene(scene);

view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOf f);
view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff) ;
view->setAlignment(Qt::AlignLeft|Qt::AlignTop);

view->setRenderHints(QPainter::Antialiasing|QPainter::Sm oothPixmapTransform);

QPixmap *p = new QPixmap("seat_empty.png");
QGraphicsPixmapItem *d = scene->addPixmap(*p);
d->setPos(400,30);
d = scene->addPixmap(*p);
d->setPos(80,220);
d = scene->addPixmap(*p);
d->setPos(60,30);
d = scene->addPixmap(*p);
d->setPos(20,120);
d = scene->addPixmap(*p);
d->setPos(460,120);
p = new QPixmap("other_cards.png");
d = scene->addPixmap(*p);
d->setPos(120,50);
d = scene->addPixmap(*p);
d->setPos(80,130);
d = scene->addPixmap(*p);
d->setPos(120,200);
d = scene->addPixmap(*p);
d->setPos(440,120);
p = new QPixmap("6.png");
d = scene->addPixmap(*p);
d->setPos(540,330);
p = new QPixmap("50.png");
d = scene->addPixmap(*p);
d->setPos(600,330);

setCentralWidget(view);
show();
}
void Dialog::resizeEvent(QResizeEvent* event)
{
}
void Dialog::keyPressEvent(QKeyEvent* event)
{
if (event->key() == Qt::Key_Equal)
view->scale(1.1, 1.1);
else if (event->key() == Qt::Key_Minus)
view->scale(0.9, 0.9);
}

Lykurg
23rd October 2010, 08:11
I just wrote that test to show what I mean for anyone who doesn't use PySide.That was a good idea, but posting images from a 3rd party side isn't. Please attach them on the board that your thread stays valid a long time and not depend on other sides.

To your problem. When scaling images one will always loose informations. Sure. If you want to ensure a clear border of the cards, you have to do the painting yourself and use a cosmetic pen to draw the border. That's the only way to enforce that and also have in mind Qt (and its classes) aren't a graphics program so the transformation might be a little worser than in a real graphics problem (which also has more time to do the transformations).

Anyway, if you use QGraphicsPixmapItem::setTransformationMode() with smooth transformation your problem should be gone.

genjix
23rd October 2010, 09:44
Aha Thank you. That was exactly what I needed, and was a great help.

Sorry about the images; I didn't realise and will remember that in the future. I've tried re-attaching those images to this thread, but whenever I click "Manage Attachments", I just get a blank window pop-up in Firefox.

wysota
23rd October 2010, 12:42
Sorry about the images; I didn't realise and will remember that in the future. I've tried re-attaching those images to this thread, but whenever I click "Manage Attachments", I just get a blank window pop-up in Firefox.
You might want to try disabling AdBlock for QtCentre. We don't have any ads anyway...

genjix
23rd October 2010, 14:05
OK, This is not my computer but the problem was 2 add-ons for firefox:
Torbutton 1.2.5 and GameBox 1.0.0
Individually they work fine, but when they're both on together then the Manage Attachments form is blank.53875388