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

Kermit Mei kermit.mei at gmail.com
Thu Feb 4 13:47:44 CET 2010


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




More information about the Qt-interest-old mailing list