[Qt-interest] How can I read a large image fastly?

Jason H scorp1us at yahoo.com
Thu Feb 4 15:01:19 CET 2010


You can;t speed loading, but you can load it into memory then use QPixmap::copy() to access/scale,etc only the visible area.


Or are you trying to scale the thing in entirety?
There are a couple scaling algorithms. Also avoid use of SmoothPixmapTransform,as you'll be doing sub-pixel interpolation.



----- Original Message ----
From: Kermit Mei <kermit.mei at gmail.com>
To: qt-interest <qt-interest at trolltech.com>
Sent: Thu, February 4, 2010 7:47:44 AM
Subject: [Qt-interest] How can I read a large image fastly?

Hello community!

     I run Qt on a slow embedded device, now we want to show some large 
image on it, but the speed of loading is too slowly. For example, if we 
decode a 6M jpg picture, we always need 100s to show it.

    Does Qt4 can support that  read  parts of  the  image to make it 
shows quickly. For example, the picture is 4000x4000,  in fact we just 
need to show 320x240. Can I just show a part of the picture to make it 
faster?

I use QImageReader like this:

void Browser::paintEvent(QPaintEvent *event) {
    imgReader->setFileName("./test.jpg");
    imgReader->setClipRect(QRect(0,0,320,240));
    imgReader->setScaledSize(QSize(3200,2400));
    qDebug("canRead: %d",imgReader->canRead());
    QPainter p(this);
    p.drawImage(QRect(0,0,320,240),imgReader->read());
}*
**
*But it shows all the picture which is reduced to 320x240, so the speed 
is also slow.

Is there something wrong of the code?



Thanks
Kermit Mei

_______________________________________________
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