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

Kermit Mei kermit.mei at gmail.com
Thu Feb 4 14:49:36 CET 2010


Thomas Dähling wrote:
> Did you take a look at the overload for read that takes a QImage
> pointer as parameter?
>   
Sorry, I can't understand you. Do you mean make the QImage as a buffer?
I fact, I want it load more faster at the first time:)

Thanks
B.R
Kermit

> 2010/2/4 Kermit Mei <kermit.mei at gmail.com>:
>   
>> Lorenzo Masini wrote:
>>     
>>> Il giorno gio, 04/02/2010 alle 20.47 +0800, Kermit Mei ha scritto:
>>>
>>>       
>>>> 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?
>>>>
>>>>         
>>> The paintEvent isn't the right place to load an image.
>>> It is called every time is performed an update. For example on
>>> resizeEvent.
>>>
>>> I think you have to load the image into another part of your code, cache
>>> the resulting image, and then display it into the paintEvent.
>>>
>>> I don't understand if you need to show a part of the image or the image
>>> resized.
>>>
>>> cheers
>>> Lorenzo
>>>
>>>       
>> Thanks, Cheers. But in fact, what I want to know is not how to paint it
>> fast, I want to know how can I load it more fast.
>>
>> This paintEvent() is just a test routine, and it just load only one
>> time.  In another words, I want to know how to improve the speed of
>> "imgReader->read()". And why I can't load just part of it?
>>
>>
>> B.R
>> Kermit
>>
>> _______________________________________________
>> 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