banner



What Is A Scaled Copy

The QImage class provides a hardware-independent image representation that allows direct access to the pixel data, and tin be used as a paint device. More than...

Member Function Documentation

QImage &&QImage::rgbSwapped() &&

QImage QImage::rgbSwapped() const &

Returns a QImage in which the values of the red and blue components of all pixels have been swapped, effectively converting an RGB image to an BGR paradigm.

The original QImage is not inverse.

Encounter also Image Transformations.

QImage &&QImage::mirrored(bool horizontal = false, bool vertical = true) &&

QImage QImage::mirrored(bool horizontal = false, bool vertical = true) const &

Returns a mirror of the prototype, mirrored in the horizontal and/or the vertical direction depending on whether horizontal and vertical are set to true or false.

Annotation that the original image is not changed.

See also Image Transformations.

QImage QImage::convertToFormat(QImage::Format format, Qt::ImageConversionFlags flags = Qt::AutoColor) &&

QImage QImage::convertToFormat(QImage::Format format, Qt::ImageConversionFlags flags = Qt::AutoColor) const &

Returns a re-create of the image in the given format.

The specified prototype conversion flags control how the image data is handled during the conversion procedure.

See also Image Formats.

QImage::QImage(QImage &&other)

Move-constructs a QImage example, making it indicate at the same object that other was pointing to.

This function was introduced in Qt 5.ii.

QImage::QImage(const QImage &paradigm)

Constructs a shallow copy of the given image.

For more information nigh shallow copies, see the Implicit Data Sharing documentation.

See besides copy().

QImage::QImage(const QString &fileName, const char *format = nullptr)

Constructs an image and tries to load the image from the file with the given fileName.

The loader attempts to read the image using the specified format. If the format is not specified (which is the default), it is auto-detected based on the file'due south suffix and header. For details, meet {QImageReader::setAutoDetectImageFormat()}{QImageReader}.

If the loading of the image failed, this object is a cypher image.

The file name tin can either refer to an bodily file on deejay or to one of the application'southward embedded resource. See the Resource Organization overview for details on how to embed images and other resource files in the application's executable.

See as well isNull() and Reading and Writing Image Files.

QImage::QImage(const char *const [] xpm)

Constructs an image from the given xpm image.

Make sure that the image is a valid XPM image. Errors are silently ignored.

Notation that it'due south possible to squeeze the XPM variable a footling bit by using an unusual declaration:

                        static            const            char            *            const            start_xpm[            ]            =            {            "16 15 8 1"            ,            "a c #cec6bd"            ,            .            .            .            .          

The extra const makes the entire definition read-only, which is slightly more efficient (e.thou., when the code is in a shared library) and able to exist stored in ROM with the application.

QImage::QImage(const uchar *data, int width, int height, int bytesPerLine, QImage::Format format, QImageCleanupFunction cleanupFunction = nullptr, void *cleanupInfo = nullptr)

Constructs an epitome with the given width, height and format, that uses an existing retentiveness buffer, data. The width and height must be specified in pixels. bytesPerLine specifies the number of bytes per line (footstep).

The buffer must remain valid throughout the life of the QImage and all copies that have not been modified or otherwise detached from the original buffer. The image does not delete the buffer at destruction. You lot can provide a role pointer cleanupFunction along with an extra pointer cleanupInfo that will be chosen when the last copy is destroyed.

If format is an indexed color format, the epitome color table is initially empty and must be sufficiently expanded with setColorCount() or setColorTable() before the paradigm is used.

Unlike the similar QImage constructor that takes a not-const data buffer, this version will never change the contents of the buffer. For example, calling QImage::bits() will return a deep copy of the paradigm, rather than the buffer passed to the constructor. This allows for the efficiency of constructing a QImage from raw data, without the possibility of the raw data being changed.

QImage::QImage(uchar *data, int width, int height, int bytesPerLine, QImage::Format format, QImageCleanupFunction cleanupFunction = nullptr, void *cleanupInfo = nullptr)

Constructs an paradigm with the given width, tiptop and format, that uses an existing memory buffer, information. The width and pinnacle must exist specified in pixels. bytesPerLine specifies the number of bytes per line (stride).

The buffer must remain valid throughout the life of the QImage and all copies that have non been modified or otherwise discrete from the original buffer. The image does not delete the buffer at destruction. You can provide a office pointer cleanupFunction forth with an extra pointer cleanupInfo that volition be chosen when the last re-create is destroyed.

If format is an indexed color format, the epitome colour table is initially empty and must be sufficiently expanded with setColorCount() or setColorTable() before the prototype is used.

QImage::QImage(const uchar *data, int width, int height, QImage::Format format, QImageCleanupFunction cleanupFunction = nullptr, void *cleanupInfo = nullptr)

Constructs an prototype with the given width, height and format, that uses an existing read-simply retention buffer, data. The width and pinnacle must be specified in pixels, information must be 32-fleck aligned, and each scanline of information in the image must too be 32-chip aligned.

The buffer must remain valid throughout the life of the QImage and all copies that have not been modified or otherwise detached from the original buffer. The image does not delete the buffer at destruction. You can provide a function pointer cleanupFunction along with an extra pointer cleanupInfo that will be called when the terminal copy is destroyed.

If format is an indexed color format, the paradigm color tabular array is initially empty and must be sufficiently expanded with setColorCount() or setColorTable() before the paradigm is used.

Dissimilar the similar QImage constructor that takes a non-const information buffer, this version volition never modify the contents of the buffer. For example, calling QImage::$.25() will return a deep copy of the paradigm, rather than the buffer passed to the constructor. This allows for the efficiency of constructing a QImage from raw data, without the possibility of the raw information being changed.

QImage::QImage(uchar *data, int width, int meridian, QImage::Format format, QImageCleanupFunction cleanupFunction = nullptr, void *cleanupInfo = nullptr)

Constructs an image with the given width, height and format, that uses an existing retention buffer, information. The width and summit must be specified in pixels, data must be 32-bit aligned, and each scanline of data in the prototype must also be 32-bit aligned.

The buffer must remain valid throughout the life of the QImage and all copies that accept not been modified or otherwise detached from the original buffer. The image does non delete the buffer at destruction. Yous can provide a function pointer cleanupFunction along with an actress arrow cleanupInfo that will be called when the concluding copy is destroyed.

If format is an indexed color format, the image color tabular array is initially empty and must be sufficiently expanded with setColorCount() or setColorTable() before the image is used.

QImage::QImage(int width, int summit, QImage::Format format)

Constructs an epitome with the given width, height and format.

A null epitome will be returned if memory cannot be allocated.

Warning: This will create a QImage with uninitialized data. Telephone call fill() to fill the image with an advisable pixel value before drawing onto information technology with QPainter.

QImage::QImage(const QSize &size, QImage::Format format)

Constructs an image with the given size and format.

A null image is returned if memory cannot be allocated.

Warning: This will create a QImage with uninitialized data. Call fill() to fill up the prototype with an appropriate pixel value before drawing onto it with QPainter.

QImage::QImage()

Constructs a zippo image.

See also isNull().

QImage &QImage::operator=(QImage &&other)

Motion-assigns other to this QImage case.

This office was introduced in Qt 5.2.

QImage &QImage::operator=(const QImage &epitome)

Assigns a shallow copy of the given image to this image and returns a reference to this image.

For more data nigh shallow copies, see the Implicit Information Sharing documentation.

See also copy() and QImage().

[virtual] QImage::~QImage()

Destroys the image and cleans up.

bool QImage::allGray() const

Returns truthful if all the colors in the prototype are shades of grey (i.due east. their red, green and blue components are equal); otherwise false.

Notation that this role is boring for images without color tabular array.

Run into too isGrayscale().

void QImage::applyColorTransform(const QColorTransform &transform)

Applies the color transformation transform to all pixels in the image.

This function was introduced in Qt 5.14.

int QImage::bitPlaneCount() const

Returns the number of bit planes in the paradigm.

The number of bit planes is the number of bits of colour and transparency information for each pixel. This is different from (i.e. smaller than) the depth when the image format contains unused bits.

This role was introduced in Qt iv.7.

See also depth(), format(), and Epitome Formats.

uchar *QImage::$.25()

Returns a pointer to the starting time pixel data. This is equivalent to scanLine(0).

Notation that QImage uses implicit data sharing. This function performs a deep copy of the shared pixel data, thus ensuring that this QImage is the only one using the electric current return value.

Come across likewise scanLine(), sizeInBytes(), and constBits().

const uchar *QImage::bits() const

This is an overloaded office.

Note that QImage uses implicit information sharing, simply this part does not perform a deep copy of the shared pixel information, considering the returned data is const.

int QImage::bytesPerLine() const

Returns the number of bytes per prototype scanline.

This is equivalent to sizeInBytes() / height() if height() is non-zero.

Come across likewise scanLine().

qint64 QImage::cacheKey() const

Returns a number that identifies the contents of this QImage object. Distinct QImage objects can simply have the same cardinal if they refer to the same contents.

The key will change when the epitome is altered.

QRgb QImage::colour(int i) const

Returns the color in the colour table at index i. The get-go color is at alphabetize 0.

The colors in an image'southward color table are specified as ARGB quadruplets (QRgb). Use the qAlpha(), qRed(), qGreen(), and qBlue() functions to get the colour value components.

See as well setColor(), pixelIndex(), and Pixel Manipulation.

int QImage::colorCount() const

Returns the size of the color table for the image.

Discover that colorCount() returns 0 for 32-bpp images because these images exercise not use colour tables, just instead encode pixel values as ARGB quadruplets.

This office was introduced in Qt four.6.

See also setColorCount() and Image Information.

QColorSpace QImage::colorSpace() const

Returns the color space of the image if a color space is defined.

This function was introduced in Qt 5.14.

See too setColorSpace().

QVector<QRgb> QImage::colorTable() const

Returns a list of the colors independent in the image's color table, or an empty listing if the paradigm does not have a colour table

See besides setColorTable(), colorCount(), and colour().

const uchar *QImage::constBits() const

Returns a pointer to the starting time pixel information.

Note that QImage uses implicit data sharing, but this function does not perform a deep copy of the shared pixel data, because the returned information is const.

This function was introduced in Qt iv.7.

See too $.25() and constScanLine().

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

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

The scanline data is equally minimum 32-fleck aligned. For 64-scrap formats information technology follows the native alignment of 64-bit integers (64-scrap for about platforms, but notably 32-chip on i386).

Notation that QImage uses implicit information sharing, just this function does non perform a deep copy of the shared pixel data, because the returned data is const.

This function was introduced in Qt four.7.

See also scanLine() and constBits().

void QImage::convertTo(QImage::Format format, Qt::ImageConversionFlags flags = Qt::AutoColor)

Detach and convert the image to the given format in place.

The specified prototype conversion flags control how the image data is handled during the conversion process.

This function was introduced in Qt v.13.

Run into likewise convertToFormat().

void QImage::convertToColorSpace(const QColorSpace &colorSpace)

Converts the paradigm to colorSpace.

If the epitome has no valid color space, the method does nothing.

This function was introduced in Qt 5.14.

Meet also convertedToColorSpace() and setColorSpace().

QImage QImage::convertToFormat(QImage::Format format, const QVector<QRgb> &colorTable, Qt::ImageConversionFlags flags = Qt::AutoColor) const

This is an overloaded function.

Returns a copy of the image converted to the given format, using the specified colorTable.

Conversion from RGB formats to indexed formats is a slow functioning and will apply a straightforward nearest color approach, with no dithering.

QImage QImage::convertedToColorSpace(const QColorSpace &colorSpace) const

Returns the epitome converted to colorSpace.

If the epitome has no valid colour infinite, a null QImage is returned.

This function was introduced in Qt 5.fourteen.

Run into likewise convertToColorSpace().

QImage QImage::copy(const QRect &rectangle = QRect()) const

Returns a sub-area of the image as a new image.

The returned paradigm is copied from the position (rectangle.x(), rectangle.y()) in this image, and will always have the size of the given rectangle.

In areas beyond this image, pixels are set to 0. For 32-scrap RGB images, this means black; for 32-bit ARGB images, this means transparent black; for eight-fleck images, this means the color with index 0 in the colour table which can be anything; for 1-bit images, this means Qt::color0.

If the given rectangle is a null rectangle the entire image is copied.

See also QImage().

QImage QImage::copy(int x, int y, int width, int acme) const

This is an overloaded part.

The returned image is copied from the position (x, y) in this epitome, and will always have the given width and summit. In areas beyond this paradigm, pixels are prepare to 0.

QImage QImage::createAlphaMask(Qt::ImageConversionFlags flags = Qt::AutoColor) const

Builds and returns a ane-bpp mask from the alpha buffer in this image. Returns a zero epitome if the prototype'due south format is QImage::Format_RGB32.

The flags argument is a bitwise-OR of the Qt::ImageConversionFlags, and controls the conversion procedure. Passing 0 for flags sets all the default options.

The returned paradigm has little-endian fleck order (i.e. the image's format is QImage::Format_MonoLSB), which you lot can convert to big-endian (QImage::Format_Mono) using the convertToFormat() function.

See also createHeuristicMask() and Paradigm Transformations.

QImage QImage::createHeuristicMask(bool clipTight = true) const

Creates and returns a ane-bpp heuristic mask for this image.

The part works by selecting a color from i of the corners, and then chipping away pixels of that colour starting at all the edges. The 4 corners vote for which color is to exist masked away. In case of a draw (this generally means that this function is not applicable to the paradigm), the issue is arbitrary.

The returned epitome has trivial-endian bit order (i.eastward. the image's format is QImage::Format_MonoLSB), which you can convert to big-endian (QImage::Format_Mono) using the convertToFormat() function.

If clipTight is true (the default) the mask is just large enough to embrace the pixels; otherwise, the mask is larger than the data pixels.

Note that this office disregards the alpha buffer.

Run into also createAlphaMask() and Image Transformations.

QImage QImage::createMaskFromColor(QRgb color, Qt::MaskMode mode = Qt::MaskInColor) const

Creates and returns a mask for this prototype based on the given color value. If the way is MaskInColor (the default value), all pixels matching colour volition be opaque pixels in the mask. If manner is MaskOutColor, all pixels matching the given color volition be transparent.

See also createAlphaMask() and createHeuristicMask().

int QImage::depth() const

Returns the depth of the paradigm.

The paradigm depth is the number of $.25 used to shop a single pixel, also called bits per pixel (bpp).

The supported depths are 1, 8, 16, 24, 32 and 64.

See too bitPlaneCount(), convertToFormat(), Image Formats, and Prototype Data.

qreal QImage::devicePixelRatio() const

Returns the device pixel ratio for the prototype. This is the ratio between device pixels and device independent pixels.

Use this function when calculating layout geometry based on the image size: QSize layoutSize = epitome.size() / image.devicePixelRatio()

The default value is 1.0.

Run into also setDevicePixelRatio() and QImageReader.

int QImage::dotsPerMeterX() const

Returns the number of pixels that fit horizontally in a physical meter. Together with dotsPerMeterY(), this number defines the intended scale and aspect ratio of the epitome.

Meet too setDotsPerMeterX() and Prototype Information.

int QImage::dotsPerMeterY() const

Returns the number of pixels that fit vertically in a concrete meter. Together with dotsPerMeterX(), this number defines the intended scale and aspect ratio of the image.

See as well setDotsPerMeterY() and Image Data.

void QImage::make full(uint pixelValue)

Fills the unabridged image with the given pixelValue.

If the depth of this epitome is one, only the lowest flake is used. If you lot say fill up(0), fill(2), etc., the image is filled with 0s. If you say fill(1), fill(3), etc., the image is filled with 1s. If the depth is 8, the lowest viii bits are used and if the depth is sixteen the lowest 16 bits are used.

Note: QImage::pixel() returns the color of the pixel at the given coordinates while QColor::pixel() returns the pixel value of the underlying window system (essentially an index value), so normally you will desire to utilise QImage::pixel() to use a color from an existing epitome or QColor::rgb() to use a specific color.

See too depth() and Paradigm Transformations.

void QImage::make full(const QColor &colour)

This is an overloaded role.

Fills the unabridged epitome with the given colour.

If the depth of the image is one, the epitome will be filled with 1 if color equals Qt::color1; it volition otherwise exist filled with 0.

If the depth of the epitome is 8, the image will exist filled with the alphabetize corresponding the color in the color table if present; information technology will otherwise be filled with 0.

This function was introduced in Qt 4.8.

void QImage::fill(Qt::GlobalColor color)

This is an overloaded function.

Fills the image with the given color, described every bit a standard global colour.

This function was introduced in Qt four.viii.

QImage::Format QImage::format() const

Returns the format of the image.

See also Epitome Formats.

[static] QImage QImage::fromData(const uchar *data, int size, const char *format = nullptr)

Constructs a QImage from the first size bytes of the given binary information. The loader attempts to read the image using the specified format. If format is not specified (which is the default), the loader probes the data for a header to guess the file format.

If format is specified, it must exist one of the values returned past QImageReader::supportedImageFormats().

If the loading of the image fails, the epitome returned volition be a nil image.

Meet also load(), save(), and Reading and Writing Image Files.

[static] QImage QImage::fromData(const QByteArray &information, const char *format = nullptr)

This is an overloaded role.

Loads an epitome from the given QByteArray information.

bool QImage::hasAlphaChannel() const

Returns true if the paradigm has a format that respects the alpha channel, otherwise returns false.

See as well Paradigm Data.

int QImage::acme() const

Returns the height of the prototype.

See also Epitome Information.

void QImage::invertPixels(QImage::InvertMode mode = InvertRgb)

Inverts all pixel values in the prototype.

The given capsize way just have a meaning when the image's depth is 32. The default manner is InvertRgb, which leaves the alpha channel unchanged. If the style is InvertRgba, the alpha $.25 are also inverted.

Inverting an eight-bit image means to replace all pixels using color index i with a pixel using color index 255 minus i. The same is the case for a 1-bit image. Note that the colour table is not changed.

If the image has a premultiplied alpha channel, the image is outset converted to an unpremultiplied image format to be inverted and then converted back.

Come across as well Image Transformations.

bool QImage::isGrayscale() const

For 32-bit images, this function is equivalent to allGray().

For color indexed images, this function returns true if color(i) is QRgb(i, i, i) for all indexes of the colour tabular array; otherwise returns faux.

Encounter also allGray() and Image Formats.

bool QImage::isNull() const

Returns true if it is a naught image, otherwise returns simulated.

A null image has all parameters set to zero and no allocated data.

bool QImage::load(const QString &fileName, const char *format = nullptr)

Loads an paradigm from the file with the given fileName. Returns true if the image was successfully loaded; otherwise invalidates the paradigm and returns simulated.

The loader attempts to read the epitome using the specified format, east.thousand., PNG or JPG. If format is non specified (which is the default), it is auto-detected based on the file's suffix and header. For details, run across QImageReader::setAutoDetectImageFormat().

The file name tin can either refer to an actual file on disk or to one of the awarding's embedded resource. See the Resource System overview for details on how to embed images and other resources files in the application'southward executable.

Run across also Reading and Writing Prototype Files.

bool QImage::load(QIODevice *device, const char *format)

This is an overloaded function.

This office reads a QImage from the given device. This can, for instance, be used to load an image directly into a QByteArray.

bool QImage::loadFromData(const uchar *data, int len, const char *format = nullptr)

Loads an image from the first len bytes of the given binary data. Returns true if the image was successfully loaded; otherwise invalidates the image and returns false.

The loader attempts to read the image using the specified format, e.thousand., PNG or JPG. If format is not specified (which is the default), the loader probes the file for a header to judge the file format.

See also Reading and Writing Image Files.

bool QImage::loadFromData(const QByteArray &data, const char *format = nullptr)

This is an overloaded office.

Loads an image from the given QByteArray data.

QPoint QImage::first() const

Returns the number of pixels by which the epitome is intended to be offset by when positioning relative to other images.

Run into also setOffset() and Image Information.

QRgb QImage::pixel(const QPoint &position) const

Returns the color of the pixel at the given position.

If the position is non valid, the results are undefined.

Warning: This office is expensive when used for massive pixel manipulations. Utilize constBits() or constScanLine() when many pixels needs to be read.

See as well setPixel(), valid(), constBits(), constScanLine(), and Pixel Manipulation.

QRgb QImage::pixel(int 10, int y) const

This is an overloaded function.

Returns the color of the pixel at coordinates (10, y).

QColor QImage::pixelColor(const QPoint &position) const

Returns the color of the pixel at the given position as a QColor.

If the position is not valid, an invalid QColor is returned.

Warning: This office is expensive when used for massive pixel manipulations. Apply constBits() or constScanLine() when many pixels needs to be read.

This part was introduced in Qt 5.six.

Come across also setPixelColor(), setPixel(), valid(), constBits(), constScanLine(), and Pixel Manipulation.

QColor QImage::pixelColor(int ten, int y) const

This is an overloaded function.

Returns the color of the pixel at coordinates (x, y) as a QColor.

This role was introduced in Qt 5.6.

QPixelFormat QImage::pixelFormat() const

Returns the QImage::Format as a QPixelFormat

int QImage::pixelIndex(const QPoint &position) const

Returns the pixel index at the given position.

If position is non valid, or if the image is not a paletted image (depth() > 8), the results are undefined.

Come across also valid(), depth(), and Pixel Manipulation.

int QImage::pixelIndex(int x, int y) const

This is an overloaded part.

Returns the pixel index at (x, y).

QRect QImage::rect() const

Returns the enclosing rectangle (0, 0, width(), height()) of the image.

See also Epitome Information.

bool QImage::reinterpretAsFormat(QImage::Format format)

Changes the format of the epitome to format without changing the information. Only works betwixt formats of the same depth.

Returns true if successful.

This function tin can exist used to modify images with alpha-channels to their corresponding opaque formats if the data is known to be opaque-just, or to alter the format of a given epitome buffer earlier overwriting it with new data.

Alert: The function does not check if the epitome data is valid in the new format and volition all the same return true if the depths are compatible. Operations on an image with invalid data are undefined.

Warning: If the image is not detached, this will cause the data to exist copied.

This role was introduced in Qt 5.9.

See also hasAlphaChannel() and convertToFormat().

bool QImage::save(const QString &fileName, const char *format = nullptr, int quality = -i) const

Saves the image to the file with the given fileName, using the given prototype file format and quality factor. If format is nullptr, QImage will attempt to guess the format past looking at fileName's suffix.

The quality gene must be in the range 0 to 100 or -1. Specify 0 to obtain small compressed files, 100 for large uncompressed files, and -1 (the default) to use the default settings.

Returns truthful if the image was successfully saved; otherwise returns false.

See likewise Reading and Writing Paradigm Files.

bool QImage::save(QIODevice *device, const char *format = nullptr, int quality = -i) const

This is an overloaded function.

This office writes a QImage to the given device.

This can, for case, be used to save an image direct into a QByteArray:

QImage QImage::scaled(const QSize &size, Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio, Qt::TransformationMode transformMode = Qt::FastTransformation) const

Returns a copy of the prototype scaled to a rectangle defined by the given size according to the given aspectRatioMode and transformMode.

  • If aspectRatioMode is Qt::IgnoreAspectRatio, the prototype is scaled to size.
  • If aspectRatioMode is Qt::KeepAspectRatio, the image is scaled to a rectangle as large equally possible inside size, preserving the aspect ratio.
  • If aspectRatioMode is Qt::KeepAspectRatioByExpanding, the image is scaled to a rectangle equally small as possible outside size, preserving the aspect ratio.

If the given size is empty, this part returns a zilch image.

See as well isNull() and Image Transformations.

QImage QImage::scaled(int width, int meridian, Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio, Qt::TransformationMode transformMode = Qt::FastTransformation) const

This is an overloaded part.

Returns a re-create of the image scaled to a rectangle with the given width and pinnacle according to the given aspectRatioMode and transformMode.

If either the width or the height is zero or negative, this function returns a null image.

QImage QImage::scaledToHeight(int meridian, Qt::TransformationMode way = Qt::FastTransformation) const

Returns a scaled re-create of the epitome. The returned image is scaled to the given tiptop using the specified transformation manner.

This part automatically calculates the width of the prototype so that the ratio of the epitome is preserved.

If the given elevation is 0 or negative, a nothing paradigm is returned.

See also Image Transformations.

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

Returns a scaled re-create of the image. The returned paradigm is scaled to the given width using the specified transformation mode.

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

If the given width is 0 or negative, a cypher prototype is returned.

See also Paradigm Transformations.

uchar *QImage::scanLine(int i)

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

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

Alarm: If you are accessing 32-bpp paradigm data, bandage the returned pointer to QRgb* (QRgb has a 32-chip size) and utilize information technology 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. Utilize qRed(), qGreen(), qBlue(), and qAlpha() to access the pixels.

Run across also bytesPerLine(), bits(), Pixel Manipulation, and constScanLine().

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

This is an overloaded part.

void QImage::setAlphaChannel(const QImage &alphaChannel)

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

If alphaChannel is an 8 chip alpha image, the blastoff values are used directly. Otherwise, alphaChannel is converted to viii 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 ane. If the image doesn't have an blastoff channel it will be converted to a format that does.

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

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

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

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

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

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

void QImage::setColorCount(int colorCount)

Resizes the colour tabular array to incorporate 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 nowadays in the image, otherwise the results are undefined.

This function was introduced in Qt 4.vi.

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

void QImage::setColorSpace(const QColorSpace &colorSpace)

Sets the prototype color space to colorSpace without performing any conversions on image data.

This part was introduced in Qt five.14.

See as well colorSpace().

void QImage::setColorTable(const QVector<QRgb> colors)

Sets the color table used to translate color indexes to QRgb values, to the specified colors.

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

See as well colorTable(), setColor(), and Epitome Transformations.

void QImage::setDevicePixelRatio(qreal scaleFactor)

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

The default scaleFactor is 1.0. Setting information technology to something else has two furnishings:

QPainters that are opened on the prototype will exist scaled. For example, painting on a 200x200 paradigm if with a ratio of two.0 volition result in constructive (device-independent) painting bounds of 100x100.

Lawmaking paths in Qt that calculate layout geometry based on the paradigm size volition take the ratio into business relationship: QSize layoutSize = paradigm.size() / paradigm.devicePixelRatio() The net issue of this is that the epitome is displayed as high-DPI prototype rather than a big image (meet Drawing High Resolution Versions of Pixmaps and Images).

See also devicePixelRatio().

void QImage::setDotsPerMeterX(int x)

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

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

Run across also dotsPerMeterX() and Epitome Information.

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 calibration at which QPainter will draw graphics on the prototype. It does not change the scale or aspect ratio of the image when it is rendered on other paint devices.

See also dotsPerMeterY() and Paradigm Information.

void QImage::setOffset(const QPoint &start)

Sets the number of pixels by which the paradigm is intended to exist start by when positioning relative to other images, to get-go.

See also offset() and Image Data.

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 prototype'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.

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

Run into too pixel() and Pixel Manipulation.

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

This is an overloaded function.

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

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

Sets the color at the given position to color.

If position is not a valid coordinate pair in the image, or the prototype'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 chosen inside; if functioning is a concern, we recommend the utilise of scanLine() or $.25() to access pixel data directly.

This role was introduced in Qt 5.half-dozen.

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 (ten, y) to color.

This function was introduced in Qt 5.6.

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 lot just want to shop a single text cake (i.e., a "comment" or merely a clarification), you tin either pass an empty key, or apply a generic cardinal similar "Description".

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

Not all prototype formats support embedded text. You can observe out if a specific image or format supports embedding text by using QImageWriter::supportsOption(). We requite an case:

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

Run across besides text() and textKeys().

QSize QImage::size() const

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

See as well Image Information.

qsizetype QImage::sizeInBytes() const

Returns the epitome data size in bytes.

This part was introduced in Qt 5.10.

Encounter also byteCount(), bytesPerLine(), $.25(), and Image Information.

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

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

void QImage::swap(QImage &other)

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

This function was introduced in Qt iv.viii.

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

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

See likewise setText() and textKeys().

QStringList QImage::textKeys() const

Returns the text keys for this image.

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

See likewise text().

CGImageRef QImage::toCGImage() const

Creates a CGImage equivalent to this QImage. Returns a CGImageRef handle.

The returned CGImageRef partakes in the QImage implicit sharing, and holds a reference to the QImage data. CGImage is immutable and will never detach the QImage. Writing to the QImage will disassemble as usual.

This office is fast, and does not copy or catechumen image data.

The following image formats are supported, and will be mapped to a corresponding native image type:

Other formats are not supported; this function returns a goose egg CGImageRef for those cases. Users of this function may then catechumen the QImage to a supported formate first, for example Format_ARGB32_Premultiplied.

The CGImageRef colour space is set to the sRGB color space.

Meet also QtMac::toNSImage().

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

Converts format into a QImage::Format

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

Converts format into a QPixelFormat

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

Returns a re-create of the epitome that is transformed using the given transformation matrix and transformation way.

The returned image volition normally accept the same {Image Formats}{format} as the original prototype. However, a complex transformation may result in an image where non all pixels are covered by the transformed pixels of the original image. In such cases, those groundwork pixels will exist assigned a transparent color value, and the transformed image will exist given a format with an alpha channel, even if the orginal paradigm did not have that.

The transformation matrix is internally adjusted to compensate for unwanted translation; i.due east. the epitome produced is the smallest prototype that contains all the transformed points of the original image. Utilise the trueMatrix() function to remember the actual matrix used for transforming an epitome.

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

See besides trueMatrix() and Image Transformations.

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

Returns the bodily matrix used for transforming an prototype with the given width, tiptop 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 epitome. This function returns the modified matrix, which maps points correctly from the original paradigm into the new image.

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

Run across also transformed() and Image Transformations.

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

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

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

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

This is an overloaded part.

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

int QImage::width() const

Returns the width of the image.

Run into likewise Prototype Data.

QVariant QImage::operator QVariant() const

Returns the image every bit a QVariant.

bool QImage::operator!=(const QImage &paradigm) const

Returns truthful if this image and the given image have dissimilar contents; otherwise returns simulated.

The comparison tin can be slow, unless in that location is some obvious deviation, such every bit unlike widths, in which case the function will render quickly.

Run across too operator=().

bool QImage::operator==(const QImage &prototype) const

Returns truthful if this image and the given image have the same contents; otherwise returns fake.

The comparison can be ho-hum, unless at that place is some obvious difference (eastward.yard. different size or format), in which case the function will return speedily.

See besides operator=().

What Is A Scaled Copy,

Source: https://doc.qt.io/qt-5/qimage.html

Posted by: banksobling.blogspot.com

0 Response to "What Is A Scaled Copy"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel