summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qimage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/image/qimage.cpp')
-rw-r--r--src/gui/image/qimage.cpp245
1 files changed, 19 insertions, 226 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 499c527cfc..5460104fd0 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -43,7 +43,6 @@
#include "qdatastream.h"
#include "qcolortransform.h"
#include "qmap.h"
-#include "qmatrix.h"
#include "qtransform.h"
#include "qimagereader.h"
#include "qimagewriter.h"
@@ -786,7 +785,7 @@ QImage::QImage(const QSize &size, Format format)
-QImageData *QImageData::create(uchar *data, int width, int height, int bpl, QImage::Format format, bool readOnly, QImageCleanupFunction cleanupFunction, void *cleanupInfo)
+QImageData *QImageData::create(uchar *data, int width, int height, qsizetype bpl, QImage::Format format, bool readOnly, QImageCleanupFunction cleanupFunction, void *cleanupInfo)
{
if (width <= 0 || height <= 0 || !data || format == QImage::Format_Invalid)
return nullptr;
@@ -798,7 +797,7 @@ QImageData *QImageData::create(uchar *data, int width, int height, int bpl, QIm
if (bpl > 0) {
// can't overflow, because has calculateImageParameters already done this multiplication
- const int min_bytes_per_line = (width * depth + 7)/8;
+ const qsizetype min_bytes_per_line = (qsizetype(width) * depth + 7)/8;
if (bpl < min_bytes_per_line)
return nullptr;
@@ -899,13 +898,17 @@ QImage::QImage(const uchar* data, int width, int height, Format format, QImageCl
initially empty and must be sufficiently expanded with
setColorCount() or setColorTable() before the image is used.
*/
+
+#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
+QImage::QImage(uchar *data, int width, int height, qsizetype bytesPerLine, Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo)
+#else
QImage::QImage(uchar *data, int width, int height, int bytesPerLine, Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo)
+#endif
:QPaintDevice()
{
d = QImageData::create(data, width, height, bytesPerLine, format, false, cleanupFunction, cleanupInfo);
}
-
/*!
Constructs an image with the given \a width, \a height and \a
format, that uses an existing memory buffer, \a data. The \a width
@@ -931,7 +934,11 @@ QImage::QImage(uchar *data, int width, int height, int bytesPerLine, Format form
data being changed.
*/
+#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
+QImage::QImage(const uchar *data, int width, int height, qsizetype bytesPerLine, Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo)
+#else
QImage::QImage(const uchar *data, int width, int height, int bytesPerLine, Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo)
+#endif
:QPaintDevice()
{
d = QImageData::create(const_cast<uchar*>(data), width, height, bytesPerLine, format, true, cleanupFunction, cleanupInfo);
@@ -1170,7 +1177,7 @@ QImage QImage::copy(const QRect& r) const
// Qt for Embedded Linux can create images with non-default bpl
// make sure we don't crash.
if (image.d->nbytes != d->nbytes) {
- int bpl = qMin(bytesPerLine(), image.bytesPerLine());
+ qsizetype bpl = qMin(bytesPerLine(), image.bytesPerLine());
for (int i = 0; i < height(); i++)
memcpy(image.scanLine(i), scanLine(i), bpl);
} else
@@ -1229,7 +1236,7 @@ QImage QImage::copy(const QRect& r) const
if (byteAligned) {
const uchar *src = d->data + ((x * d->depth) >> 3) + y * d->bytes_per_line;
uchar *dest = image.d->data + ((dx * d->depth) >> 3) + dy * image.d->bytes_per_line;
- const int bytes_to_copy = (pixels_to_copy * d->depth) >> 3;
+ const qsizetype bytes_to_copy = (qsizetype(pixels_to_copy) * d->depth) >> 3;
for (int i = 0; i < lines_to_copy; ++i) {
memcpy(dest, src, bytes_to_copy);
src += d->bytes_per_line;
@@ -1386,11 +1393,7 @@ int QImage::colorCount() const
\sa colorTable(), setColor(), {QImage#Image Transformations}{Image
Transformations}
*/
-#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
void QImage::setColorTable(const QVector<QRgb> &colors)
-#else
-void QImage::setColorTable(const QVector<QRgb> colors)
-#endif
{
if (!d)
return;
@@ -1400,11 +1403,7 @@ void QImage::setColorTable(const QVector<QRgb> colors)
if (!d)
return;
-#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
d->colortable = colors;
-#else
- d->colortable = std::move(const_cast<QVector<QRgb>&>(colors));
-#endif
d->has_alpha_clut = false;
for (int i = 0; i < d->colortable.size(); ++i) {
if (qAlpha(d->colortable.at(i)) != 255) {
@@ -1477,25 +1476,6 @@ void QImage::setDevicePixelRatio(qreal scaleFactor)
d->devicePixelRatio = scaleFactor;
}
-#if QT_DEPRECATED_SINCE(5, 10)
-/*!
- \since 4.6
- \obsolete
- Returns the number of bytes occupied by the image data.
-
- Note this method should never be called on an image larger than 2 gigabytes.
- Instead use sizeInBytes().
-
- \sa sizeInBytes(), bytesPerLine(), bits(), {QImage#Image Information}{Image
- Information}
-*/
-int QImage::byteCount() const
-{
- Q_ASSERT(!d || d->nbytes < std::numeric_limits<int>::max());
- return d ? int(d->nbytes) : 0;
-}
-#endif
-
/*!
\since 5.10
Returns the image data size in bytes.
@@ -1515,17 +1495,10 @@ qsizetype QImage::sizeInBytes() const
\sa scanLine()
*/
-#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
qsizetype QImage::bytesPerLine() const
{
return d ? d->bytes_per_line : 0;
}
-#else
-int QImage::bytesPerLine() const
-{
- return d ? d->bytes_per_line : 0;
-}
-#endif
/*!
@@ -1929,11 +1902,11 @@ void QImage::invertPixels(InvertMode mode)
if (depth() < 32) {
// This assumes no alpha-channel as the only formats with non-premultipled alpha are 32bit.
- int bpl = (d->width * d->depth + 7) / 8;
+ qsizetype bpl = (qsizetype(d->width) * d->depth + 7) / 8;
int pad = d->bytes_per_line - bpl;
uchar *sl = d->data;
for (int y=0; y<d->height; ++y) {
- for (int x=0; x<bpl; ++x)
+ for (qsizetype x=0; x<bpl; ++x)
*sl++ ^= 0xff;
sl += pad;
}
@@ -2882,65 +2855,6 @@ QImage QImage::scaledToHeight(int h, Qt::TransformationMode mode) const
return transformed(wm, mode);
}
-
-#if QT_DEPRECATED_SINCE(5, 15)
-
-/*!
- \obsolete
-
- Use trueMatrix(const QTransform &matrix, int w, int h) instead.
-
- \fn QMatrix QImage::trueMatrix(const QMatrix &matrix, int width, int height)
-
- Returns the actual matrix used for transforming an image with the
- given \a width, \a height and \a matrix.
-
- When transforming an image using the transformed() function, the
- transformation matrix is internally adjusted to compensate for
- unwanted translation, i.e. transformed() returns the smallest
- image containing all transformed points of the original image.
- This function returns the modified matrix, which maps points
- correctly from the original image into the new image.
-
- \sa transformed(), {QImage#Image Transformations}{Image
- Transformations}
-*/
-QMatrix QImage::trueMatrix(const QMatrix &matrix, int w, int h)
-{
- return trueMatrix(QTransform(matrix), w, h).toAffine();
-}
-
-/*!
- \obsolete
-
- Use transformed(const QTransform &matrix, Qt::TransformationMode mode) instead.
-
- Returns a copy of the image that is transformed using the given
- transformation \a matrix and transformation \a mode.
-
- The returned image will normally have the same {Image Formats}{format} as
- the original image. However, a complex transformation may result in an
- image where not all pixels are covered by the transformed pixels of the
- original image. In such cases, those background pixels will be assigned a
- transparent color value, and the transformed image will be given a format
- with an alpha channel, even if the orginal image did not have that.
-
- The transformation \a matrix is internally adjusted to compensate
- for unwanted translation; i.e. the image produced is the smallest
- image that contains all the transformed points of the original
- image. Use the trueMatrix() function to retrieve the actual matrix
- used for transforming an image.
-
- \sa trueMatrix(), {QImage#Image Transformations}{Image
- Transformations}
-*/
-QImage QImage::transformed(const QMatrix &matrix, Qt::TransformationMode mode) const
-{
- return transformed(QTransform(matrix), mode);
-}
-
-#endif // QT_DEPRECATED_SINCE(5, 15)
-
/*!
Builds and returns a 1-bpp mask from the alpha buffer in this
image. Returns a null image if the image's format is
@@ -4068,71 +3982,10 @@ void QImage::setText(const QString &key, const QString &value)
}
/*!
- \fn QString QImage::text(const char* key, const char* language) const
- \obsolete
-
- Returns the text recorded for the given \a key in the given \a
- language, or in a default language if \a language is \nullptr.
-
- Use text() instead.
-
- The language the text is recorded in is no longer relevant since
- the text is always set using QString and UTF-8 representation.
-*/
-
-/*!
- \fn QString QImage::text(const QImageTextKeyLang& keywordAndLanguage) const
- \overload
- \obsolete
-
- Returns the text recorded for the given \a keywordAndLanguage.
-
- Use text() instead.
-
- The language the text is recorded in is no longer relevant since
- the text is always set using QString and UTF-8 representation.
-*/
-
-/*!
- \fn void QImage::setText(const char* key, const char* language, const QString& text)
- \obsolete
-
- Sets the image text to the given \a text and associate it with the
- given \a key. The text is recorded in the specified \a language,
- or in a default language if \a language is \nullptr.
-
- Use setText() instead.
-
- The language the text is recorded in is no longer relevant since
- the text is always set using QString and UTF-8 representation.
-
- \omit
- Records string \a for the keyword \a key. The \a key should be
- a portable keyword recognizable by other software - some suggested
- values can be found in
- \l{http://www.libpng.org/pub/png/spec/1.2/png-1.2-pdg.html#C.Anc-text}
- {the PNG specification}. \a s can be any text. \a lang should
- specify the language code (see
- \l{http://www.rfc-editor.org/rfc/rfc1766.txt}{RFC 1766}) or \nullptr.
- \endomit
-*/
-
-/*
- Sets the image bits to the \a pixmap contents and returns a
- reference to the image.
-
- If the image shares data with other images, it will first
- dereference the shared data.
-
- Makes a call to QPixmap::convertToImage().
-*/
-
-/*!
\internal
Used by QPainter to retrieve a paint engine for the image.
*/
-
QPaintEngine *QImage::paintEngine() const
{
if (!d)
@@ -4264,8 +4117,8 @@ int QImage::metric(PaintDeviceMetric metric) const
trigy += m12;
// END OF MACRO
bool qt_xForm_helper(const QTransform &trueMat, int xoffset, int type, int depth,
- uchar *dptr, int dbpl, int p_inc, int dHeight,
- const uchar *sptr, int sbpl, int sWidth, int sHeight)
+ uchar *dptr, qsizetype dbpl, int p_inc, int dHeight,
+ const uchar *sptr, qsizetype sbpl, int sWidth, int sHeight)
{
int m11 = int(trueMat.m11()*4096.0);
int m12 = int(trueMat.m12()*4096.0);
@@ -4378,22 +4231,6 @@ bool qt_xForm_helper(const QTransform &trueMat, int xoffset, int type, int depth
#undef IWX_LSB
#undef IWX_PIX
-/*! \fn int QImage::serialNumber() const
- \obsolete
- Returns a number that identifies the contents of this
- QImage object. Distinct QImage objects can only have the same
- serial number if they refer to the same contents (but they don't
- have to).
-
- Use cacheKey() instead.
-
- \warning The serial number doesn't necessarily change when the
- image is altered. This means that it may be dangerous to use
- it as a cache key.
-
- \sa operator==()
-*/
-
/*!
Returns a number that identifies the contents of this QImage
object. Distinct QImage objects can only have the same key if they
@@ -4823,7 +4660,7 @@ QImage QImage::transformed(const QTransform &matrix, Qt::TransformationMode mode
int bpp = depth();
- int sbpl = bytesPerLine();
+ qsizetype sbpl = bytesPerLine();
const uchar *sptr = bits();
QImage::Format target_format = d->format;
@@ -4878,7 +4715,7 @@ QImage QImage::transformed(const QTransform &matrix, Qt::TransformationMode mode
// create target image (some of the code is from QImage::copy())
int type = format() == Format_Mono ? QT_XFORM_TYPE_MSBFIRST : QT_XFORM_TYPE_LSBFIRST;
- int dbpl = dImage.bytesPerLine();
+ qsizetype dbpl = dImage.bytesPerLine();
qt_xForm_helper(mat, 0, type, bpp, dImage.bits(), dbpl, 0, hd, sptr, sbpl, ws, hs);
}
copyMetadata(dImage.d, d);
@@ -5124,50 +4961,6 @@ QDebug operator<<(QDebug dbg, const QImage &i)
}
#endif
-/*!
- \fn void QImage::setNumColors(int n)
- \obsolete
-
- Resizes the color table to contain \a n entries.
-
- \sa setColorCount()
- */
-
-/*!
- \fn int QImage::numBytes() const
- \obsolete
-
- Returns the number of bytes occupied by the image data.
-
- \sa sizeInBytes()
- */
-
-/*!
- \fn QStringList QImage::textLanguages() const
- \obsolete
-
- Returns the language identifiers for which some texts are recorded.
- Note that if you want to iterate over the list, you should iterate over a copy.
-
- The language the text is recorded in is no longer relevant since the text is
- always set using QString and UTF-8 representation.
-
- \sa textKeys()
- */
-
-/*!
- \fn QList<QImageTextKeyLang> QImage::textList() const
- \obsolete
-
- Returns a list of QImageTextKeyLang objects that enumerate all the texts
- key/language pairs set for this image.
-
- The language the text is recorded in is no longer relevant since the text
- is always set using QString and UTF-8 representation.
-
- \sa textKeys()
- */
-
static Q_CONSTEXPR QPixelFormat pixelformats[] = {
//QImage::Format_Invalid:
QPixelFormat(),