Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.
Reading big images in Qt
This example shows you how to load big images into memory using QImageReader.
Successive loading of big images with a large memory footprint using the QPixmap::load() method may sometimes fail due to RAM restrictions (detected with images taken with the device camera on Nokia 5800 XpressMusic or Nokia N97). To avoid this, you have to use QImageReader and set QImageReader::setScaledSize() for the reader before loading the image. The following code has been tested with JPEG images.
// Set image name
// Read image current size
QSize imageSize = reader.size();
// Scale image to fit to screen
// Set wanted image size for reader
// Read image
QImage image = reader.read();
// Make QPixmap (if needed)
QPixmap pixmap = QPixmap::fromImage(image);
The device is able to read big JPEG images.