PDA

View Full Version : Is there a better way to load a big image?



learning_qt
26th November 2008, 06:24
I hope to load a big image, for example 10MP with the QImage. But it is too slow, is there a better way to speed up the loading process?

Thanks

wysota
26th November 2008, 08:40
If the image takes 10MB compressed (I take it that this is the case) then it has to take time to load and to uncompress itself. There is no way to avoid it. What you can do is compose the image from smaller images. Qt doesn't support progressive loading as it could also be a kind of a solution for you. What you can do is to load the image in another thread so that your application remains responsive while the image is being opened.

learning_qt
26th November 2008, 13:29
How can we compose the big image from small images? Or can we cut a big image to small images?

maverick_pol
26th November 2008, 15:00
QImage QImage::copy ( const QRect & rectangle = QRect() ) const

Returns a sub-area of the image as a new image.
The returned image is copied from the position (rectangle.x(), rectangle.y()) in this image, and will always have the size of the given rectangle.
In areas beyond this image, pixels are set to 0. For 32-bit RGB images, this means black; for 32-bit ARGB images, this means transparent black; for 8-bit images, this means the color with index 0 in the color table which can be anything; for 1-bit images, this means Qt::color0.
If the given rectangle is a null rectangle the entire image is copied.
See also QImage().

Once loaded you can cut the image to smaller parts.