Introduce QImage::convertTo

QImage::convertTo can be used to change the format of an image in place.

[ChangeLog][QtGui][QImage] A new method convertTo is has been
added to change the format of a QImage in place.

Change-Id: Ib31379085c4b97e56c3cb569f144062bcd3fdc20
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
Mikhail Svetkin 2018-11-20 18:36:46 +05:00
parent c2b4e7a215
commit e81acde7d0
2 changed files with 25 additions and 0 deletions

View File

@ -2242,6 +2242,29 @@ bool QImage::reinterpretAsFormat(Format format)
return true; return true;
} }
/*!
\since 5.13
Detach and convert the image to the given \a format in place.
The specified image conversion \a flags control how the image data
is handled during the conversion process.
\sa convertToFormat()
*/
void QImage::convertTo(Format f, Qt::ImageConversionFlags flags)
{
if (!d || f == QImage::Format_Invalid)
return;
detach();
if (convertToFormat_inplace(f, flags))
return;
*this = convertToFormat_helper(f, flags);
}
/*! /*!
\fn bool QImage::valid(const QPoint &pos) const \fn bool QImage::valid(const QPoint &pos) const

View File

@ -196,6 +196,8 @@ public:
Q_REQUIRED_RESULT QImage convertToFormat(Format f, const QVector<QRgb> &colorTable, Qt::ImageConversionFlags flags = Qt::AutoColor) const; Q_REQUIRED_RESULT QImage convertToFormat(Format f, const QVector<QRgb> &colorTable, Qt::ImageConversionFlags flags = Qt::AutoColor) const;
bool reinterpretAsFormat(Format f); bool reinterpretAsFormat(Format f);
void convertTo(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor);
int width() const; int width() const;
int height() const; int height() const;
QSize size() const; QSize size() const;