Create consistent sets of QImage methods
Adds consistently named inplace and imperative methods. Change-Id: I8739c1c4585d2ba4aa181bb9a681255d76c120d7 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
parent
aa5f3c829c
commit
d263ab6af5
@ -2033,7 +2033,20 @@ QImage::Format QImage::format() const
|
||||
The specified image conversion \a flags control how the image data
|
||||
is handled during the conversion process.
|
||||
|
||||
\sa {Image Formats}
|
||||
\sa convertTo(), {Image Formats}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QImage QImage::convertedTo(Format format, Qt::ImageConversionFlags flags) const &
|
||||
\fn QImage QImage::convertedTo(Format format, Qt::ImageConversionFlags flags) &&
|
||||
\since 6.0
|
||||
|
||||
Returns a copy of the image in the given \a format.
|
||||
|
||||
The specified image conversion \a flags control how the image data
|
||||
is handled during the conversion process.
|
||||
|
||||
\sa convertTo(), {Image Formats}
|
||||
*/
|
||||
|
||||
/*!
|
||||
@ -2235,7 +2248,7 @@ bool QImage::reinterpretAsFormat(Format format)
|
||||
The specified image conversion \a flags control how the image data
|
||||
is handled during the conversion process.
|
||||
|
||||
\sa convertToFormat()
|
||||
\sa convertedTo()
|
||||
*/
|
||||
|
||||
void QImage::convertTo(Format format, Qt::ImageConversionFlags flags)
|
||||
@ -3066,7 +3079,17 @@ QImage QImage::createMaskFromColor(QRgb color, Qt::MaskMode mode) const
|
||||
|
||||
Note that the original image is not changed.
|
||||
|
||||
\sa {QImage#Image Transformations}{Image Transformations}
|
||||
\sa mirror(), {QImage#Image Transformations}{Image Transformations}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QImage::mirror(bool horizontal = false, bool vertical = true)
|
||||
\since 6.0
|
||||
|
||||
Mirrors of the image in the horizontal and/or the vertical direction depending
|
||||
on whether \a horizontal and \a vertical are set to true or false.
|
||||
|
||||
\sa mirrored(), {QImage#Image Transformations}{Image Transformations}
|
||||
*/
|
||||
|
||||
template<class T> inline void do_mirror_data(QImageData *dst, QImageData *src,
|
||||
@ -3278,7 +3301,17 @@ void QImage::mirrored_inplace(bool horizontal, bool vertical)
|
||||
|
||||
The original QImage is not changed.
|
||||
|
||||
\sa {QImage#Image Transformations}{Image Transformations}
|
||||
\sa rgbSwap(), {QImage#Image Transformations}{Image Transformations}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QImage::rgbSwap()
|
||||
\since 6.0
|
||||
|
||||
Swaps the values of the red and blue components of all pixels, effectively converting
|
||||
an RGB image to an BGR image.
|
||||
|
||||
\sa rgbSwapped(), {QImage#Image Transformations}{Image Transformations}
|
||||
*/
|
||||
|
||||
static inline void rgbSwapped_generic(int width, int height, const QImage *src, QImage *dst, const QPixelLayout* layout)
|
||||
|
@ -170,6 +170,10 @@ public:
|
||||
Qt::ImageConversionFlags flags = Qt::AutoColor) const;
|
||||
bool reinterpretAsFormat(Format f);
|
||||
|
||||
Q_REQUIRED_RESULT QImage convertedTo(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) const &
|
||||
{ return convertToFormat(f, flags); }
|
||||
Q_REQUIRED_RESULT QImage convertedTo(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) &&
|
||||
{ return convertToFormat(f, flags); }
|
||||
void convertTo(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor);
|
||||
|
||||
int width() const;
|
||||
@ -245,14 +249,18 @@ public:
|
||||
QImage scaledToHeight(int h, Qt::TransformationMode mode = Qt::FastTransformation) const;
|
||||
QImage transformed(const QTransform &matrix, Qt::TransformationMode mode = Qt::FastTransformation) const;
|
||||
static QTransform trueMatrix(const QTransform &, int w, int h);
|
||||
QImage mirrored(bool horizontally = false, bool vertically = true) const &
|
||||
Q_REQUIRED_RESULT QImage mirrored(bool horizontally = false, bool vertically = true) const &
|
||||
{ return mirrored_helper(horizontally, vertically); }
|
||||
QImage &&mirrored(bool horizontally = false, bool vertically = true) &&
|
||||
Q_REQUIRED_RESULT QImage mirrored(bool horizontally = false, bool vertically = true) &&
|
||||
{ mirrored_inplace(horizontally, vertically); return std::move(*this); }
|
||||
QImage rgbSwapped() const &
|
||||
Q_REQUIRED_RESULT QImage rgbSwapped() const &
|
||||
{ return rgbSwapped_helper(); }
|
||||
QImage &&rgbSwapped() &&
|
||||
Q_REQUIRED_RESULT QImage rgbSwapped() &&
|
||||
{ rgbSwapped_inplace(); return std::move(*this); }
|
||||
void mirror(bool horizontally = false, bool vertically = true)
|
||||
{ mirrored_inplace(horizontally, vertically); }
|
||||
void rgbSwap()
|
||||
{ rgbSwapped_inplace(); }
|
||||
void invertPixels(InvertMode = InvertRgb);
|
||||
|
||||
QColorSpace colorSpace() const;
|
||||
|
@ -2431,11 +2431,11 @@ void tst_QImage::rgbSwapped()
|
||||
QCOMPARE(swappedColor.blue(), referenceColor.red());
|
||||
}
|
||||
|
||||
QImage imageSwappedTwice = imageSwapped.rgbSwapped();
|
||||
imageSwapped.rgbSwap();
|
||||
|
||||
QCOMPARE(image, imageSwappedTwice);
|
||||
QCOMPARE(image, imageSwapped);
|
||||
|
||||
QCOMPARE(memcmp(image.constBits(), imageSwappedTwice.constBits(), image.sizeInBytes()), 0);
|
||||
QCOMPARE(memcmp(image.constBits(), imageSwapped.constBits(), image.sizeInBytes()), 0);
|
||||
}
|
||||
|
||||
void tst_QImage::mirrored_data()
|
||||
@ -2543,16 +2543,16 @@ void tst_QImage::mirrored()
|
||||
}
|
||||
}
|
||||
|
||||
QImage imageMirroredTwice = imageMirrored.mirrored(swap_horizontal, swap_vertical);
|
||||
imageMirrored.mirror(swap_horizontal, swap_vertical);
|
||||
|
||||
QCOMPARE(image, imageMirroredTwice);
|
||||
QCOMPARE(image, imageMirrored);
|
||||
|
||||
if (format != QImage::Format_Mono && format != QImage::Format_MonoLSB)
|
||||
QCOMPARE(memcmp(image.constBits(), imageMirroredTwice.constBits(), image.sizeInBytes()), 0);
|
||||
QCOMPARE(memcmp(image.constBits(), imageMirrored.constBits(), image.sizeInBytes()), 0);
|
||||
else {
|
||||
for (int i = 0; i < image.height(); ++i)
|
||||
for (int j = 0; j < image.width(); ++j)
|
||||
QCOMPARE(image.pixel(j,i), imageMirroredTwice.pixel(j,i));
|
||||
QCOMPARE(image.pixel(j,i), imageMirrored.pixel(j,i));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user