
For more information see the Image Formats section. The bitPlaneCount() function tells how many of those bits that are used. The supported depths are 1 (monochrome), 8, 16, 24 and 32 bits. The depth() function returns the depth of the image. Use the setText() function to alter an image’s text. An image’s text keys can be retrieved using the textKeys() function. The text() function returns the image text associated with the given text key. See also the Pixel Manipulation and Image Transformations sections. The allGray() and isGrayscale() functions tell whether an image’s colors are all shades of gray. The hasAlphaChannel() function tells if the image’s format respects the alpha channel, or not. Note that if you create an 8-bit image manually, you have to set a valid color table on the image as well. To obtain a single entry, use the pixelIndex() function to retrieve the pixel index for a given pair of coordinates, then use the color() function to retrieve the color.

In case of monochrome and 8-bit images, the colorCount() and colorTable() functions provide information about the color components used to store the image data: The colorTable() function returns the image’s entire color table. The pixel() function returns the color as a QRgb value independent of the image’s format. The color of a pixel can be retrieved by passing its coordinates to the pixel() function. The offset() function returns the number of pixels by which the image is intended to be offset by when positioned relative to other images, which also can be manipulated using the setOffset() function. The valid() function tells if a given pair of coordinates is within this rectangle. The rect() function returns the image’s enclosing rectangle. The size(), width(), height(), dotsPerMeterX(), and dotsPerMeterY() functions provide information about the image size and aspect ratio. QImage objects can also be streamed and compared. QImage objects can be passed around by value since the QImage class uses implicit data sharing.

There are also several functions that enables transformation of the image. QImage provides a collection of functions that can be used to obtain a variety of information about the image.

These include monochrome, 8-bit, 32-bit and alpha-blended images which are available in all versions of Qt 4.x. The QImage class supports several image formats described by the Format enum. When using QPainter on a QImage, the painting can be performed in another thread than the current GUI thread. Finally, the QPicture class is a paint device that records and replays QPainter commands.īecause QImage is a QPaintDevice subclass, QPainter can be used to draw directly onto images. QBitmap is only a convenience class that inherits QPixmap, ensuring a depth of 1. QImage is designed and optimized for I/O, and for direct pixel access and manipulation, while QPixmap is designed and optimized for showing images on screen. Qt provides four classes for handling image data: QImage, QPixmap, QBitmap and QPicture. Def convertToFormat (f, colorTable)ĭef convertToFormat (f)ĭef convertToFormat_helper (format, flags)ĭef convertToFormat_inplace (format, flags)ĭef convertedTo (f)ĭef createAlphaMask ()ĭef createHeuristicMask ()ĭef createMaskFromColor (color)ĭef invertPixels ()ĭef mirror (])ĭef mirrored (])ĭef mirrored_helper (horizontal, vertical)ĭef mirrored_inplace (horizontal, vertical)ĭef save (device])ĭef save (fileName])ĭef scaled (s])ĭef scaled (w, h])ĭef scaledToHeight (h)ĭef scaledToWidth (w)ĭef transformed (matrix)
