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);
}
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);
}