[Qt-interest] how to show large image fastly?

Jason H scorp1us at yahoo.com
Fri Aug 20 03:16:43 CEST 2010


Since it's a square, it wastes exponential CPU to process pixels you don't need. 
When you scroll, determine  the new desired region, process only those pixels. 
(QPixmap::copy()) If you need to animate it, you can do low quality scaling then 
on the final pass do a high quality scale.





----- Original Message ----
From: wanneng <yangguosdxl at gmail.com>
To: Jason H <scorp1us at yahoo.com>
Cc: qt-interest at trolltech.com
Sent: Thu, August 19, 2010 9:07:41 PM
Subject: Re: [Qt-interest] how to show large image fastly?

On 2010年08月20日 02:05, Jason H wrote:
> 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
>
>
>
>
>
>    
Sorry, I didn't say it clear. When I load the picture, its spead is ok 
for me, but when I zoom in or zoom out or move it in the view, it is slow.

-- 
--------------------------
万能
普赛科技


      




More information about the Qt-interest-old mailing list