Home · All Namespaces · All Classes · Grouped Classes · Modules · Functions |
The QThumbnail class provides thumbnails of large images. More...
#include <QThumbnail>
The QThumbnail class provides thumbnails of large images.
A thumbnail is a small version of an image loaded from a file or QIODevice.
Thumbnail pixmaps are generated by calling pixmap(maximum_size). Usually, aspect ratio is preserved, so the actualSize() of the image may have a smaller width or height than the maximum size.
For many image formats, thumbnails are loaded by methods more efficient than the naive method of simply loading the entire image and scaling it down. For other formats, the naive method is used.
This code paints the contents of image.jpg centered on the calling widget:
QPainter painter( this ); QThumbnail thumbnail( "image.jpg" ); offset = (size() - thumbnail.actualSize(size())) / 2; painter.drawPixmap( offset.width(), offset.height(), thumbnail.pixmap(size()));
Constructs the thumbnail for the given image fileName. The file is not loaded at this time, but it is opened.
Constructs the thumbnail for an image to be read from the given io device.
Destroys the thumbnail.
Returns the actual size of the thumbnail for the requested size and mode. An invalid size is returned if the image is not able to be read. The whole image may be loaded if the image handler does not support the QImageIOHandler::Size option.
If size is invalid the function returns the size as defined by QImageIOHandler::Size. This can be used to prevent that the image is scaled up when calling QThumbnail::pixmap():
thumbnail.pixmap( thumbnail.actualSize( maxsize.boundedTo( thumbnail.actualSize(QSize()) ) ) )
See also pixmap().
Returns a pixmap with the requested size and mode. A null pixmap is returned if the image cannot be loaded.
The pixmap will be generated by scaling the image as it is being loaded where possible. This is reliant on the support for the QImageIOHandler::ScaledSize option in the image handler. If the option is not supported the whole image will be loaded and then scaled with the requested transformationMode.
See also actualSize().
Copyright © 2009 Trolltech | Trademarks | Qt Extended 4.4.3 |