Obsolete Members for QImage

The following members of class QImage are obsolete. They are provided to keep old source code working. We strongly advise against using them in new code.

Public Functions

(obsolete) QImage alphaChannel() const
(obsolete) int byteCount() const
(obsolete) int numBytes() const
(obsolete) int numColors() const
(obsolete) int serialNumber() const
(obsolete) void setNumColors(int n)
(obsolete) void setText(const char *key, const char *language, const QString &text)
(obsolete) QString text(const char *key, const char *language = nullptr) const
(obsolete) QString text(const QImageTextKeyLang &keywordAndLanguage) const
(obsolete) QStringList textLanguages() const
(obsolete) QList<QImageTextKeyLang> textList() const
(obsolete) QImage transformed(const QMatrix &matrix, Qt::TransformationMode mode = Qt::FastTransformation) const

Static Public Members

(obsolete) QMatrix trueMatrix(const QMatrix &matrix, int width, int height)

Member Function Documentation

QImage QImage::alphaChannel() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Returns the alpha channel of the image as a new grayscale QImage in which each pixel's red, green, and blue values are given the alpha value of the original image. The color depth of the returned image is 8-bit.

You can see an example of use of this function in QPixmap's alphaChannel(), which works in the same way as this function on QPixmaps.

Most usecases for this function can be replaced with QPainter and using composition modes.

Note this returns a color-indexed image if you want the alpha channel in the alpha8 format instead use convertToFormat(Format_Alpha8) on the source image.

Warning: This is an expensive function.

See also setAlphaChannel(), hasAlphaChannel(), convertToFormat(), Pixmap, and Image Transformations.

int QImage::byteCount() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

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().

This function was introduced in Qt 4.6.

See also sizeInBytes(), bytesPerLine(), bits(), and Image Information.

int QImage::numBytes() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Returns the number of bytes occupied by the image data.

See also sizeInBytes().

int QImage::numColors() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Returns the size of the color table for the image.

See also setNumColors() and setColorCount().

int QImage::serialNumber() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

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.

See also operator==().

void QImage::setNumColors(int n)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Resizes the color table to contain n entries.

See also numColors() and setColorCount().

void QImage::setText(const char *key, const char *language, const QString &text)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Sets the image text to the given text and associate it with the given key. The text is recorded in the specified language, or in a default language if 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.

QString QImage::text(const char *key, const char *language = nullptr) const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Returns the text recorded for the given key in the given language, or in a default language if 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.

QString QImage::text(const QImageTextKeyLang &keywordAndLanguage) const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

This is an overloaded function.

Returns the text recorded for the given 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.

QStringList QImage::textLanguages() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

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.

See also textKeys().

QList<QImageTextKeyLang> QImage::textList() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

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.

See also textKeys().

QImage QImage::transformed(const QMatrix &matrix, Qt::TransformationMode mode = Qt::FastTransformation) const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use transformed(const QTransform &matrix, Qt::TransformationMode mode) instead.

Returns a copy of the image that is transformed using the given transformation matrix and transformation 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 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.

See also trueMatrix() and Image Transformations.

[static] QMatrix QImage::trueMatrix(const QMatrix &matrix, int width, int height)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use trueMatrix(const QTransform &matrix, int w, int h) instead.

Returns the actual matrix used for transforming an image with the given width, height and 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.

See also transformed() and Image Transformations.

© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.