diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2010-02-01 01:03:16 (GMT) |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2010-02-01 01:03:16 (GMT) |
commit | a16a6e6fb3cf9d9c70515d2361bc06c598c27f3f (patch) | |
tree | 5895900d5f4d351e3f8a2000868886a9a24f66f7 | |
parent | 2f3bf7b546186b9415f2d0b97ae431fea1a2cc48 (diff) | |
download | Qt-a16a6e6fb3cf9d9c70515d2361bc06c598c27f3f.zip Qt-a16a6e6fb3cf9d9c70515d2361bc06c598c27f3f.tar.gz Qt-a16a6e6fb3cf9d9c70515d2361bc06c598c27f3f.tar.bz2 |
Promote QPixmap::convertFromImage() to public API from Qt3Support
QPixmap::fromImage() creates a new pixmap from a QImage.
There was no way to replace a pixmap with a new QImage in-place
without using the private QPixmapData API. This change promotes
the Qt3Support function convertFromImage() back to official
status for updating a pixmap in-place.
Task-number: QTBUG-7361
Reviewed-by: Tom Cooksey
-rw-r--r-- | src/gui/image/qpixmap.cpp | 20 | ||||
-rw-r--r-- | src/gui/image/qpixmap.h | 4 |
2 files changed, 20 insertions, 4 deletions
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 5626485..fe03c93 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -1379,10 +1379,26 @@ void QPixmap::deref() */ /*! - \fn bool QPixmap::convertFromImage(const QImage &image, Qt::ImageConversionFlags flags) + Replaces this pixmap's data with the given \a image using the specified + \a flags to control the conversion. The \a flags argument is a + bitwise-OR of the \l{Qt::ImageConversionFlags}. Passing 0 for \a + flags sets all the default options. - Use the static fromImage() function instead. + Note: this function was part of Qt 3 support in Qt 4.6 and earlier. + It has been promoted to official API status in 4.7 to support updating + the pixmap's image without creating a new QPixmap as fromImage() would. + + \sa fromImage() + \since 4.7 */ +bool QPixmap::convertFromImage(const QImage &image, Qt::ImageConversionFlags flags) +{ + if (image.isNull() || !data) + *this = QPixmap::fromImage(image, flags); + else + data->fromImage(image, flags); + return !isNull(); +} /*! \fn QPixmap QPixmap::xForm(const QMatrix &matrix) const diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 46363f0..180af3b 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -141,6 +141,8 @@ public: bool save(const QString& fileName, const char* format = 0, int quality = -1) const; bool save(QIODevice* device, const char* format = 0, int quality = -1) const; + bool convertFromImage(const QImage &img, Qt::ImageConversionFlags flags = Qt::AutoColor); + #if defined(Q_WS_WIN) enum HBitmapFormat { NoAlpha, @@ -224,8 +226,6 @@ public: QT3_SUPPORT QPixmap &operator=(const QImage &); inline QT3_SUPPORT QImage convertToImage() const { return toImage(); } QT3_SUPPORT bool convertFromImage(const QImage &, ColorMode mode); - QT3_SUPPORT bool convertFromImage(const QImage &img, Qt::ImageConversionFlags flags = Qt::AutoColor) - { (*this) = fromImage(img, flags); return !isNull(); } inline QT3_SUPPORT operator QImage() const { return toImage(); } inline QT3_SUPPORT QPixmap xForm(const QMatrix &matrix) const { return transformed(QTransform(matrix)); } inline QT3_SUPPORT bool selfMask() const { return false; } |