diff options
author | Benjamin Poulain <benjamin.poulain@nokia.com> | 2010-06-29 17:47:53 (GMT) |
---|---|---|
committer | Benjamin Poulain <benjamin.poulain@nokia.com> | 2010-06-30 12:45:58 (GMT) |
commit | 176024dfea7d354451a65b61fa2e82dd422b4dfb (patch) | |
tree | a631b5be0010489f645b7ca553929ec1361437a2 /src/gui/image | |
parent | c16162214eb8757a62e221c34d38cefc402e5b05 (diff) | |
download | Qt-176024dfea7d354451a65b61fa2e82dd422b4dfb.zip Qt-176024dfea7d354451a65b61fa2e82dd422b4dfb.tar.gz Qt-176024dfea7d354451a65b61fa2e82dd422b4dfb.tar.bz2 |
Add the conversion in-place for QPixmap::fromImageReader() on raster.
Since raster uses QImage internal, QPixmap::fromImageReader() can use
conversion in-place of the image. This avoid a memory peak during the
conversion and is a bit faster.
Reviewed-by: Samuel Rødal
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qpixmap_raster.cpp | 11 | ||||
-rw-r--r-- | src/gui/image/qpixmap_raster_p.h | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index e188745..53f3559 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -152,6 +152,17 @@ void QRasterPixmapData::fromImage(const QImage &sourceImage, createPixmapForImage(image, flags, /* inplace = */false); } +void QRasterPixmapData::fromImageReader(QImageReader *imageReader, + Qt::ImageConversionFlags flags) +{ + Q_UNUSED(flags); + QImage image = imageReader->read(); + if (image.isNull()) + return; + + createPixmapForImage(image, flags, /* inplace = */true); +} + // from qwindowsurface.cpp extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset); diff --git a/src/gui/image/qpixmap_raster_p.h b/src/gui/image/qpixmap_raster_p.h index a46e054..36a9b2f 100644 --- a/src/gui/image/qpixmap_raster_p.h +++ b/src/gui/image/qpixmap_raster_p.h @@ -74,6 +74,7 @@ public: void fromFile(const QString &filename, Qt::ImageConversionFlags flags); bool fromData(const uchar *buffer, uint len, const char *format, Qt::ImageConversionFlags flags); void fromImage(const QImage &image, Qt::ImageConversionFlags flags); + void fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags); void copy(const QPixmapData *data, const QRect &rect); bool scroll(int dx, int dy, const QRect &rect); |