[Qt-interest] how to show large image fastly?
Jason H
scorp1us at yahoo.com
Thu Aug 19 20:05:35 CEST 2010
PNGs are compressed, this is likely your problem.
Use another format (bmp) or decompress to a QPixMap before you need to show it
quickly.
I actually wrote a thread to load PNGs and hand them off uncompressed to the
main thread. This greatly increased performance on my dual-core system.
----- Original Message ----
From: wanneng <yangguosdxl at gmail.com>
To: qt-interest at trolltech.com
Sent: Thu, August 19, 2010 4:53:32 AM
Subject: [Qt-interest] how to show large image fastly?
My code like following, and the image is 125KB, format is png. it is
slow when show the picture. and more bad is that I may be use the larger
picture, it may be 1MB. So does anyone know how to show large image
fastly? thank you.
Map::Map(QWidget* parent) : QWidget(parent)
{
isShow = true;
worldMap = new QPixmap(":/images/map.png", "png");
qreal factor = this->width()/worldMap->width();
qDebug("worldMap.width, height: %d, %d", worldMap->width(),
worldMap->height());
//scene = new QGraphicsScene(0, 0, worldMap->width(),
worldMap->height());
scene = new QGraphicsScene(0, 0, 400, 300);
scene->setBackgroundBrush(QColor(255, 255, 238));
/* add map to scene */
mapItem = scene->addPixmap(*worldMap);
qDebug() << "mapItem boundingRect" << mapItem->boundingRect();
mapItem->setFlags(QGraphicsItem::ItemIsMovable);
//mapItem->setTransformationMode(Qt::FastTransformation);
//mapItem->setCacheMode(QGraphicsItem::ItemCoordinateCache);
// this cache mode make drag the picture fast
mapItem->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
/* add station node to scene */
drawStationNode();
view = new MapView(this);
view->setScene(scene);
// let the view fit the widget automatically
QVBoxLayout* vLayout = new QVBoxLayout;
vLayout->addWidget(view);
setLayout(vLayout);
createActions();
//slotFitWidget();
updateAct();
}
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list