Skip to content

PythonQt.QtGui.QImage · declarations 003

Back to PythonQt.QtGui.QImage

scaledToWidth

scaledToWidth(w: int, mode: Any) -> Any

X.scaledToWidth(w, mode) -> PythonQt.QtGui.QImage

Supplemental documentation: Qt 5 reference:

QImage QImage::scaledToWidth(int width, Qt::TransformationMode mode \= Qt::FastTransformation) const

Returns a scaled copy of the image. The returned image is scaled to the given width using the specified transformation mode.

This function automatically calculates the height of the image so that its aspect ratio is preserved.

If the given width is 0 or negative, a null image is returned.

See also Image Transformations.

Upstream PySide2 reference signatures (binding differences may apply):

scaledToWidth(self, w: int, mode: PySide2.QtCore.Qt.TransformationMode=...) -> PySide2.QtGui.QImage

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#scaledToWidth

scanLine

scanLine(line: Any) -> str

X.scanLine(line)

Supplemental documentation: Qt 5 reference:

uchar *QImage::scanLine(int i)

Returns a pointer to the pixel data at the scanline with index i. The first scanline is at index 0.

The scanline data is as minimum 32-bit aligned. For 64-bit formats it follows the native alignment of 64-bit integers (64-bit for most platforms, but notably 32-bit on i386).

Warning: If you are accessing 32-bpp image data, cast the returned pointer to QRgb* (QRgb has a 32-bit size) and use it to read/write the pixel value. You cannot use the uchar* pointer directly, because the pixel format depends on the byte order on the underlying platform. Use qRed(), qGreen(), qBlue(), and qAlpha() to access the pixels.

See also bytesPerLine(), bits(), Pixel Manipulation, and constScanLine().

const uchar *QImage::scanLine(int i) const

This is an overloaded function.

Upstream PySide2 reference signatures (binding differences may apply):

scanLine(self, arg__1: int) -> str

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#scanLine

setAlphaChannel

setAlphaChannel(alphaChannel: Any) -> None

X.setAlphaChannel(alphaChannel)

Supplemental documentation: Qt 5 reference:

void QImage::setAlphaChannel(const QImage \&alphaChannel)

Sets the alpha channel of this image to the given alphaChannel.

If alphaChannel is an 8 bit alpha image, the alpha values are used directly. Otherwise, alphaChannel is converted to 8 bit grayscale and the intensity of the pixel values is used.

If the image already has an alpha channel, the existing alpha channel is multiplied with the new one. If the image doesn't have an alpha channel it will be converted to a format that does.

The operation is similar to painting alphaChannel as an alpha image over this image using QPainter::CompositionMode_DestinationIn.

See also hasAlphaChannel(), alphaChannel(), Image Transformations, and Image Formats.

Upstream PySide2 reference signatures (binding differences may apply):

setAlphaChannel(self, alphaChannel: PySide2.QtGui.QImage) -> None

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#setAlphaChannel

setColor

setColor(i: int, c: int) -> None

X.setColor(i, c)

Supplemental documentation: Qt 5 reference:

void QImage::setColor(int index, QRgb colorValue)

Sets the color at the given index in the color table, to the given to colorValue. The color value is an ARGB quadruplet.

If index is outside the current size of the color table, it is expanded with setColorCount().

See also color(), colorCount(), setColorTable(), and Pixel Manipulation.

Upstream PySide2 reference signatures (binding differences may apply):

setColor(self, i: int, c: int) -> None

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#setColor

setColorCount

setColorCount(arg__1: int) -> None

X.setColorCount(arg__1)

Supplemental documentation: Qt 5 reference:

void QImage::setColorCount(int colorCount)

Resizes the color table to contain colorCount entries.

If the color table is expanded, all the extra colors will be set to transparent (i.e qRgba(0, 0, 0, 0)).

When the image is used, the color table must be large enough to have entries for all the pixel/index values present in the image, otherwise the results are undefined.

This function was introduced in Qt 4.6.

See also colorCount(), colorTable(), setColor(), and Image Transformations.

Upstream PySide2 reference signatures (binding differences may apply):

setColorCount(self, arg__1: int) -> None

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#setColorCount

setDevicePixelRatio

setDevicePixelRatio(scaleFactor: float) -> None

X.setDevicePixelRatio(scaleFactor)

Supplemental documentation: Qt 5 reference:

void QImage::setDevicePixelRatio(qreal scaleFactor)

Sets the device pixel ratio for the image. This is the ratio between image pixels and device-independent pixels.

The default scaleFactor is 1.0. Setting it to something else has two effects:

QPainters that are opened on the image will be scaled. For example, painting on a 200x200 image if with a ratio of 2.0 will result in effective (device-independent) painting bounds of 100x100.

Code paths in Qt that calculate layout geometry based on the image size will take the ratio into account: QSize layoutSize \= image.size() / image.devicePixelRatio() The net effect of this is that the image is displayed as high-DPI image rather than a large image (see Drawing High Resolution Versions of Pixmaps and Images).

See also devicePixelRatio().

Upstream PySide2 reference signatures (binding differences may apply):

setDevicePixelRatio(self, scaleFactor: float) -> None

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#setDevicePixelRatio

setDotsPerMeterX

setDotsPerMeterX(arg__1: int) -> None

X.setDotsPerMeterX(arg__1)

Supplemental documentation: Qt 5 reference:

void QImage::setDotsPerMeterX(int x)

Sets the number of pixels that fit horizontally in a physical meter, to x.

Together with dotsPerMeterY(), this number defines the intended scale and aspect ratio of the image, and determines the scale at which QPainter will draw graphics on the image. It does not change the scale or aspect ratio of the image when it is rendered on other paint devices.

See also dotsPerMeterX() and Image Information.

Upstream PySide2 reference signatures (binding differences may apply):

setDotsPerMeterX(self, arg__1: int) -> None

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#setDotsPerMeterX

setDotsPerMeterY

setDotsPerMeterY(arg__1: int) -> None

X.setDotsPerMeterY(arg__1)

Supplemental documentation: Qt 5 reference:

void QImage::setDotsPerMeterY(int y)

Sets the number of pixels that fit vertically in a physical meter, to y.

Together with dotsPerMeterX(), this number defines the intended scale and aspect ratio of the image, and determines the scale at which QPainter will draw graphics on the image. It does not change the scale or aspect ratio of the image when it is rendered on other paint devices.

See also dotsPerMeterY() and Image Information.

Upstream PySide2 reference signatures (binding differences may apply):

setDotsPerMeterY(self, arg__1: int) -> None

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#setDotsPerMeterY

setOffset

setOffset(arg__1: Any) -> None

X.setOffset(arg__1)

Supplemental documentation: Qt 5 reference:

void QImage::setOffset(const QPoint \&offset)

Sets the number of pixels by which the image is intended to be offset by when positioning relative to other images, to offset.

See also offset() and Image Information.

Upstream PySide2 reference signatures (binding differences may apply):

setOffset(self, arg__1: PySide2.QtCore.QPoint) -> None

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#setOffset

setPixel

setPixel(x: Any, y: Any, index_or_rgb: int) -> None

X.setPixel(x, y, index_or_rgb)

Supplemental documentation: Qt 5 reference:

void QImage::setPixel(const QPoint \&position, uint index_or_rgb)

Sets the pixel index or color at the given position to index_or_rgb.

If the image's format is either monochrome or paletted, the given index_or_rgb value must be an index in the image's color table, otherwise the parameter must be a QRgb value.

If position is not a valid coordinate pair in the image, or if index_or_rgb >\= colorCount() in the case of monochrome and paletted images, the result is undefined.

Warning: This function is expensive due to the call of the internal detach() function called within; if performance is a concern, we recommend the use of scanLine() or bits() to access pixel data directly.

See also pixel() and Pixel Manipulation.

void QImage::setPixel(int x, int y, uint index_or_rgb)

This is an overloaded function.

Sets the pixel index or color at (x, y) to index_or_rgb.

Upstream PySide2 reference signatures (binding differences may apply):

setPixel(self, pt: PySide2.QtCore.QPoint, index_or_rgb: int) -> None
setPixel(self, x: int, y: int, index_or_rgb: int) -> None

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#setPixel

setPixelColor

setPixelColor(x: Any, y: Any, c: Any) -> None

X.setPixelColor(x, y, c)

Supplemental documentation: Qt 5 reference:

void QImage::setPixelColor(const QPoint \&position, const QColor \&color)

Sets the color at the given position to color.

If position is not a valid coordinate pair in the image, or the image's format is either monochrome or paletted, the result is undefined.

Warning: This function is expensive due to the call of the internal detach() function called within; if performance is a concern, we recommend the use of scanLine() or bits() to access pixel data directly.

This function was introduced in Qt 5.6.

See also pixelColor(), pixel(), bits(), scanLine(), and Pixel Manipulation.

void QImage::setPixelColor(int x, int y, const QColor \&color)

This is an overloaded function.

Sets the pixel color at (x, y) to color.

This function was introduced in Qt 5.6.

Upstream PySide2 reference signatures (binding differences may apply):

setPixelColor(self, pt: PySide2.QtCore.QPoint, c: PySide2.QtGui.QColor) -> None
setPixelColor(self, x: int, y: int, c: PySide2.QtGui.QColor) -> None

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#setPixelColor

setText

setText(key: str, value: str) -> None

X.setText(key, value)

Supplemental documentation: Qt 5 reference:

void QImage::setText(const QString \&key, const QString \&text)

Sets the image text to the given text and associate it with the given key.

If you just want to store a single text block (i.e., a "comment" or just a description), you can either pass an empty key, or use a generic key like "Description".

The image text is embedded into the image data when you call save() or QImageWriter::write().

Not all image formats support embedded text. You can find out if a specific image or format supports embedding text by using QImageWriter::supportsOption(). We give an example:

    QImageWriter writer;
    writer.setFormat("png");
    if (writer.supportsOption(QImageIOHandler::Description))
        qDebug() << "Png supports embedded text";

You can use QImageWriter::supportedImageFormats() to find out which image formats are available to you.

See also text() and textKeys().

Upstream PySide2 reference signatures (binding differences may apply):

setText(self, key: str, value: str) -> None

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#setText

size

size() -> Any

X.size() -> PythonQt.QtCore.QSize

Supplemental documentation: Qt 5 reference:

QSize QImage::size() const

Returns the size of the image, i.e. its width() and height().

See also Image Information.

Upstream PySide2 reference signatures (binding differences may apply):

size(self) -> PySide2.QtCore.QSize

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#size

smoothScaled

smoothScaled(w: int, h: int) -> Any

X.smoothScaled(w, h) -> PythonQt.QtGui.QImage

Supplemental documentation: Qt 5 reference:

[protected] QImage QImage::smoothScaled(int w, int h) const

Returns a smoothly scaled copy of the image. The returned image has a size of width w by height h pixels.

Upstream PySide2 reference signatures (binding differences may apply):

smoothScaled(self, w: int, h: int) -> PySide2.QtGui.QImage

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#smoothScaled

swap

swap(other: Any) -> None

X.swap(other)

Supplemental documentation: Qt 5 reference:

void QImage::swap(QImage \&other)

Swaps image other with this image. This operation is very fast and never fails.

This function was introduced in Qt 4.8.

Upstream PySide2 reference signatures (binding differences may apply):

swap(self, other: PySide2.QtGui.QImage) -> None

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#swap

text

text(key: str) -> str

X.text(key) -> str

Supplemental documentation: Qt 5 reference:

QString QImage::text(const QString \&key \= QString()) const

Returns the image text associated with the given key. If the specified key is an empty string, the whole image text is returned, with each key-text pair separated by a newline.

See also setText() and textKeys().

Upstream PySide2 reference signatures (binding differences may apply):

text(self, key: str=...) -> str

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#text

textKeys

textKeys() -> tuple

X.textKeys() -> tuple

Supplemental documentation: Qt 5 reference:

QStringList QImage::textKeys() const

Returns the text keys for this image.

You can use these keys with text() to list the image text for a certain key.

See also text().

Upstream PySide2 reference signatures (binding differences may apply):

textKeys(self) -> typing.List[str]

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#textKeys

toImageFormat

toImageFormat(format: Any) -> Any

X.toImageFormat(format)

Supplemental documentation: Qt 5 reference:

[static] QImage::Format QImage::toImageFormat(QPixelFormat format)

Converts format into a QImage::Format

Upstream PySide2 reference signatures (binding differences may apply):

toImageFormat(format: PySide2.QtGui.QPixelFormat) -> PySide2.QtGui.QImage.Format

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#toImageFormat

toPixelFormat

toPixelFormat(format: Any) -> Any

X.toPixelFormat(format) -> PythonQt.QtGui.QPixelFormat

Supplemental documentation: Qt 5 reference:

[static] QPixelFormat QImage::toPixelFormat(QImage::Format format)

Converts format into a QPixelFormat

Upstream PySide2 reference signatures (binding differences may apply):

toPixelFormat(format: PySide2.QtGui.QImage.Format) -> PySide2.QtGui.QPixelFormat

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#toPixelFormat

transformed

transformed(matrix: Any, mode: Any) -> Any

X.transformed(matrix, mode) -> PythonQt.QtGui.QImage

Supplemental documentation: Qt 5 reference:

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

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.

Unlike the other overload, this function can be used to perform perspective transformations on images.

See also trueMatrix() and Image Transformations.

Upstream PySide2 reference signatures (binding differences may apply):

transformed(self, matrix: PySide2.QtGui.QMatrix, mode: PySide2.QtCore.Qt.TransformationMode=...) -> PySide2.QtGui.QImage
transformed(self, matrix: PySide2.QtGui.QTransform, mode: PySide2.QtCore.Qt.TransformationMode=...) -> PySide2.QtGui.QImage

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#transformed

trueMatrix

trueMatrix(arg__1: Any, w: int, h: int) -> Any

X.trueMatrix(arg__1, w, h) -> PythonQt.QtGui.QMatrix

Supplemental documentation: Qt 5 reference:

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

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.

Unlike the other overload, this function creates transformation matrices that can be used to perform perspective transformations on images.

See also transformed() and Image Transformations.

Upstream PySide2 reference signatures (binding differences may apply):

trueMatrix(arg__1: PySide2.QtGui.QMatrix, w: int, h: int) -> PySide2.QtGui.QMatrix
trueMatrix(arg__1: PySide2.QtGui.QTransform, w: int, h: int) -> PySide2.QtGui.QTransform

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#trueMatrix

valid

valid(x: Any, y: Any) -> bool

X.valid(x, y) -> bool

Supplemental documentation: Qt 5 reference:

bool QImage::valid(const QPoint \&pos) const

Returns true if pos is a valid coordinate pair within the image; otherwise returns false.

See also rect() and QRect::contains().

bool QImage::valid(int x, int y) const

This is an overloaded function.

Returns true if QPoint(x, y) is a valid coordinate pair within the image; otherwise returns false.

Upstream PySide2 reference signatures (binding differences may apply):

valid(self, pt: PySide2.QtCore.QPoint) -> bool
valid(self, x: int, y: int) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#valid

width

width() -> int

X.width() -> int

Supplemental documentation: Qt 5 reference:

int QImage::width() const

Returns the width of the image.

See also Image Information.

Upstream PySide2 reference signatures (binding differences may apply):

width(self) -> int

Source: https://doc.qt.io/archives/qt-5.15/qimage.html#width