QPixmap¶
Inherited by: QBitmap
Synopsis¶
Functions¶
def
cacheKey
()def
convertFromImage
(img[, flags=Qt.AutoColor])def
copy
([rect=QRect()])def
copy
(x, y, width, height)def
createHeuristicMask
([clipTight=true])def
createMaskFromColor
(maskColor[, mode=Qt.MaskInColor])def
fill
([fillColor=Qt.white])def
fill
(device, ofs)def
fill
(device, xofs, yofs)def
hasAlpha
()def
hasAlphaChannel
()def
isNull
()def
isQBitmap
()def
load
(fileName[, format=None[, flags=Qt.AutoColor]])def
loadFromData
(buf[, format=None[, flags=Qt.AutoColor]])def
loadFromData
(data[, format=None[, flags=Qt.AutoColor]])def
mask
()def
rect
()def
save
(device[, format=None[, quality=-1]])def
save
(fileName[, format=None[, quality=-1]])def
scaled
(s[, aspectMode=Qt.IgnoreAspectRatio[, mode=Qt.FastTransformation]])def
scaled
(w, h[, aspectMode=Qt.IgnoreAspectRatio[, mode=Qt.FastTransformation]])def
scaledToHeight
(h[, mode=Qt.FastTransformation])def
scaledToWidth
(w[, mode=Qt.FastTransformation])def
scroll
(dx, dy, rect[, exposed=None])def
scroll
(dx, dy, x, y, width, height[, exposed=None])def
setDevicePixelRatio
(scaleFactor)def
setMask
(arg__1)def
size
()def
swap
(other)def
toImage
()def
transformed
(arg__1[, mode=Qt.FastTransformation])def
transformed
(arg__1[, mode=Qt.FastTransformation])
Static functions¶
def
defaultDepth
()def
fromImage
(image[, flags=Qt.AutoColor])def
fromImage
(image[, flags=Qt.AutoColor])def
fromImageInPlace
(image[, flags=Qt.AutoColor])def
fromImageReader
(imageReader[, flags=Qt.AutoColor])def
grabWidget
(widget, rect)def
grabWidget
(widget[, x=0[, y=0[, w=-1[, h=-1]]]])def
grabWindow
(arg__1[, x=0[, y=0[, w=-1[, h=-1]]]])def
trueMatrix
(m, w, h)def
trueMatrix
(m, w, h)
Detailed Description¶
Qt provides four classes for handling image data:
QImage
,QPixmap
,QBitmap
andQPicture
.QImage
is designed and optimized for I/O, and for direct pixel access and manipulation, whileQPixmap
is designed and optimized for showing images on screen.QBitmap
is only a convenience class that inheritsQPixmap
, ensuring a depth of 1. TheisQBitmap()
function returnstrue
if aQPixmap
object is really a bitmap, otherwise returnsfalse
. Finally, theQPicture
class is a paint device that records and replaysQPainter
commands.A
QPixmap
can easily be displayed on the screen usingQLabel
or one ofQAbstractButton
‘s subclasses (such asQPushButton
andQToolButton
).QLabel
has a pixmap property, whereasQAbstractButton
has an icon property.
QPixmap
objects can be passed around by value since theQPixmap
class uses implicit data sharing. For more information, see the Implicit Data Sharing documentation.QPixmap
objects can also be streamed.Note that the pixel data in a pixmap is internal and is managed by the underlying window system. Because
QPixmap
is aQPaintDevice
subclass,QPainter
can be used to draw directly onto pixmaps. Pixels can only be accessed throughQPainter
functions or by converting theQPixmap
to aQImage
. However, thefill()
function is available for initializing the entire pixmap with a given color.There are functions to convert between
QImage
andQPixmap
. Typically, theQImage
class is used to load an image file, optionally manipulating the image data, before theQImage
object is converted into aQPixmap
to be shown on screen. Alternatively, if no manipulation is desired, the image file can be loaded directly into aQPixmap
.
QPixmap
provides a collection of functions that can be used to obtain a variety of information about the pixmap. In addition, there are several functions that enables transformation of the pixmap.
Reading and Writing Image Files¶
QPixmap
provides several ways of reading an image file: The file can be loaded when constructing theQPixmap
object, or by using theload()
orloadFromData()
functions later on. When loading an image, the file name can either refer to an actual file on disk or to one of the application’s embedded resources. See The Qt Resource System overview for details on how to embed images and other resource files in the application’s executable.Simply call the
save()
function to save aQPixmap
object.The complete list of supported file formats are available through the
supportedImageFormats()
andsupportedImageFormats()
functions. New file formats can be added as plugins. By default, Qt supports the following formats:
Format
Description
Qt’s support
BMP
Windows Bitmap
Read/write
GIF
Graphic Interchange Format (optional)
Read
JPG
Joint Photographic Experts Group
Read/write
JPEG
Joint Photographic Experts Group
Read/write
PNG
Portable Network Graphics
Read/write
PBM
Portable Bitmap
Read
PGM
Portable Graymap
Read
PPM
Portable Pixmap
Read/write
XBM
X11 Bitmap
Read/write
XPM
X11 Pixmap
Read/write
Pixmap Information¶
QPixmap
provides a collection of functions that can be used to obtain a variety of information about the pixmap:
Available Functions
Geometry
The
size()
,width()
andheight()
functions provide information about the pixmap’s size. Therect()
function returns the image’s enclosing rectangle.Alpha component
The
hasAlphaChannel()
returnstrue
if the pixmap has a format that respects the alpha channel, otherwise returnsfalse
. ThehasAlpha()
,setMask()
andmask()
functions are legacy and should not be used. They are potentially very slow.The
createHeuristicMask()
function creates and returns a 1-bpp heuristic mask (i.e. aQBitmap
) for this pixmap. It works by selecting a color from one of the corners and then chipping away pixels of that color, starting at all the edges. ThecreateMaskFromColor()
function creates and returns a mask (i.e. aQBitmap
) for the pixmap based on a given color.Low-level information
The
depth()
function returns the depth of the pixmap. ThedefaultDepth()
function returns the default depth, i.e. the depth used by the application on the given screen.The
cacheKey()
function returns a number that uniquely identifies the contents of theQPixmap
object.
Pixmap Conversion¶
A
QPixmap
object can be converted into aQImage
using thetoImage()
function. Likewise, aQImage
can be converted into aQPixmap
using thefromImage()
. If this is too expensive an operation, you can usefromImage()
instead.To convert a
QPixmap
to and from HICON you can use the QtWinExtras functions QtWin::toHICON() and QtWin::fromHICON() respectively.
Pixmap Transformations¶
QPixmap
supports a number of functions for creating a new pixmap that is a transformed version of the original:The
scaled()
,scaledToWidth()
andscaledToHeight()
functions return scaled copies of the pixmap, while thecopy()
function creates aQPixmap
that is a plain copy of the original one.The
transformed()
function returns a copy of the pixmap that is transformed with the given transformation matrix and transformation mode: Internally, the transformation matrix is adjusted to compensate for unwanted translation, i.e.transformed()
returns the smallest pixmap containing all transformed points of the original pixmap. The statictrueMatrix()
function returns the actual matrix used for transforming the pixmap.See also
- class PySide2.QtGui.QPixmap¶
PySide2.QtGui.QPixmap(image)
PySide2.QtGui.QPixmap(arg__1)
PySide2.QtGui.QPixmap(arg__1)
PySide2.QtGui.QPixmap(fileName[, format=None[, flags=Qt.AutoColor]])
PySide2.QtGui.QPixmap(xpm)
PySide2.QtGui.QPixmap(w, h)
- param w:
int
- param h:
int
- param xpm:
char[]
- param format:
str
- param image:
- param flags:
ImageConversionFlags
- param arg__1:
- param fileName:
str
Constructs a null pixmap.
See also
Constructs a pixmap from the file with the given
fileName
. If the file does not exist or is of an unknown format, the pixmap becomes a null pixmap.The loader attempts to read the pixmap using the specified
format
. If theformat
is not specified (which is the default), the loader probes the file for a header to guess the file format.The file name can either refer to an actual file on disk or to one of the application’s embedded resources. See the Resource System overview for details on how to embed images and other resource files in the application’s executable.
If the image needs to be modified to fit in a lower-resolution result (e.g. converting from 32-bit to 8-bit), use the
flags
to control the conversion.The
fileName
,format
andflags
parameters are passed on toload()
. This means that the data infileName
is not compiled into the binary. IffileName
contains a relative path (e.g. the filename only) the relevant file must be found relative to the runtime working directory.See also
Reading and Writing Image Files
Constructs a pixmap with the given
width
andheight
. If eitherwidth
orheight
is zero, a null pixmap is constructed.Warning
This will create a
QPixmap
with uninitialized data. Callfill()
to fill the pixmap with an appropriate color before drawing onto it withQPainter
.See also
- PySide2.QtGui.QPixmap.cacheKey()¶
- Return type:
int
Returns a number that identifies this
QPixmap
. DistinctQPixmap
objects can only have the same cache key if they refer to the same contents.The will change when the pixmap is altered.
- PySide2.QtGui.QPixmap.convertFromImage(img[, flags=Qt.AutoColor])¶
- Parameters:
img –
PySide2.QtGui.QImage
flags –
ImageConversionFlags
- Return type:
bool
Replaces this pixmap’s data with the given
image
using the specifiedflags
to control the conversion. Theflags
argument is a bitwise-OR of theImageConversionFlags
. Passing 0 forflags
sets all the default options. Returnstrue
if the result is that this pixmap is not null.Note: this function was part of Qt 3 support in Qt 4.6 and earlier. It has been promoted to official API status in 4.7 to support updating the pixmap’s image without creating a new
QPixmap
asfromImage()
would.See also
- PySide2.QtGui.QPixmap.copy([rect=QRect()])¶
- Parameters:
rect –
PySide2.QtCore.QRect
- Return type:
Returns a deep copy of the subset of the pixmap that is specified by the given
rectangle
. For more information on deep copies, see the Implicit Data Sharing documentation.If the given
rectangle
is empty, the whole image is copied.See also
operator=()
QPixmap()
Pixmap Transformations
- PySide2.QtGui.QPixmap.copy(x, y, width, height)
- Parameters:
x – int
y – int
width – int
height – int
- Return type:
This is an overloaded function.
Returns a deep copy of the subset of the pixmap that is specified by the rectangle
QRect
(x
,y
,width
,height
).
- PySide2.QtGui.QPixmap.createHeuristicMask([clipTight=true])¶
- Parameters:
clipTight – bool
- Return type:
Creates and returns a heuristic mask for this pixmap.
The function works by selecting a color from one of the corners and then chipping away pixels of that color, starting at all the edges. If
clipTight
is true (the default) the mask is just large enough to cover the pixels; otherwise, the mask is larger than the data pixels.The mask may not be perfect but it should be reasonable, so you can do things such as the following:
myPixmap = QPixmap() myPixmap.setMask(myPixmap.createHeuristicMask())
This function is slow because it involves converting to/from a
QImage
, and non-trivial computations.
- PySide2.QtGui.QPixmap.createMaskFromColor(maskColor[, mode=Qt.MaskInColor])¶
- Parameters:
maskColor –
PySide2.QtGui.QColor
mode –
MaskMode
- Return type:
Creates and returns a mask for this pixmap based on the given
maskColor
. If themode
isMaskInColor
, all pixels matching the maskColor will be transparent. Ifmode
isMaskOutColor
, all pixels matching the maskColor will be opaque.This function is slow because it involves converting to/from a
QImage
.
- static PySide2.QtGui.QPixmap.defaultDepth()¶
- Return type:
int
Returns the default pixmap depth used by the application.
On all platforms the depth of the primary screen will be returned.
Note
QGuiApplication
must be created before calling this function.See also
depth()
depth()
Pixmap Information
- PySide2.QtGui.QPixmap.fill(device, ofs)¶
- Parameters:
device –
PySide2.QtGui.QPaintDevice
ofs –
PySide2.QtCore.QPoint
Note
This function is deprecated.
- PySide2.QtGui.QPixmap.fill(device, xofs, yofs)
- Parameters:
device –
PySide2.QtGui.QPaintDevice
xofs – int
yofs – int
Note
This function is deprecated.
- PySide2.QtGui.QPixmap.fill([fillColor=Qt.white])
- Parameters:
fillColor –
PySide2.QtGui.QColor
Fills the pixmap with the given
color
.The effect of this function is undefined when the pixmap is being painted on.
See also
Pixmap Transformations
- static PySide2.QtGui.QPixmap.fromImage(image[, flags=Qt.AutoColor])¶
- Parameters:
image –
PySide2.QtGui.QImage
flags –
ImageConversionFlags
- Return type:
- static PySide2.QtGui.QPixmap.fromImage(image[, flags=Qt.AutoColor])
- Parameters:
image –
PySide2.QtGui.QImage
flags –
ImageConversionFlags
- Return type:
- static PySide2.QtGui.QPixmap.fromImageInPlace(image[, flags=Qt.AutoColor])¶
- Parameters:
image –
PySide2.QtGui.QImage
flags –
ImageConversionFlags
- Return type:
- static PySide2.QtGui.QPixmap.fromImageReader(imageReader[, flags=Qt.AutoColor])¶
- Parameters:
imageReader –
PySide2.QtGui.QImageReader
flags –
ImageConversionFlags
- Return type:
Create a
QPixmap
from an image read directly from animageReader
. Theflags
argument is a bitwise-OR of theImageConversionFlags
. Passing 0 forflags
sets all the default options.On some systems, reading an image directly to
QPixmap
can use less memory than reading aQImage
to convert it toQPixmap
.See also
fromImage()
toImage()
Pixmap Conversion
- static PySide2.QtGui.QPixmap.grabWidget(widget[, x=0[, y=0[, w=-1[, h=-1]]]])¶
- Parameters:
widget –
PySide2.QtCore.QObject
x – int
y – int
w – int
h – int
- Return type:
Note
This function is deprecated.
Use
grab()
instead.
- static PySide2.QtGui.QPixmap.grabWidget(widget, rect)
- Parameters:
widget –
PySide2.QtCore.QObject
rect –
PySide2.QtCore.QRect
- Return type:
Note
This function is deprecated.
Use
grab()
instead.
- static PySide2.QtGui.QPixmap.grabWindow(arg__1[, x=0[, y=0[, w=-1[, h=-1]]]])¶
- Parameters:
arg__1 –
WId
x – int
y – int
w – int
h – int
- Return type:
Note
This function is deprecated.
Creates and returns a pixmap constructed by grabbing the contents of the given
window
restricted byQRect
(x
,y
,width
,height
).The arguments (
x
,y
) specify the offset in the window, whereas (width
,height
) specify the area to be copied. Ifwidth
is negative, the function copies everything to the right border of the window. Ifheight
is negative, the function copies everything to the bottom of the window.The window system identifier (
WId
) can be retrieved using thewinId()
function. The rationale for using a window identifier and not aQWidget
, is to enable grabbing of windows that are not part of the application, window system frames, and so on.The function grabs pixels from the screen, not from the window, i.e. if there is another window partially or entirely over the one you grab, you get pixels from the overlying window, too. The mouse cursor is generally not grabbed.
Note on X11 that if the given
window
doesn’t have the same depth as the root window, and another window partially or entirely obscures the one you grab, you will not get pixels from the overlying window. The contents of the obscured areas in the pixmap will be undefined and uninitialized.On Windows Vista and above grabbing a layered window, which is created by setting the
WA_TranslucentBackground
attribute, will not work. Instead grabbing the desktop widget should work.Warning
In general, grabbing an area outside the screen is not safe. This depends on the underlying window system.
Warning
The function is deprecated in Qt 5.0 since there might be platform plugins in which window system identifiers (
WId
) are local to a screen. UsegrabWindow()
instead.See also
- PySide2.QtGui.QPixmap.hasAlpha()¶
- Return type:
bool
Returns
true
if this pixmap has an alpha channel, or has a mask, otherwise returnsfalse
.See also
- PySide2.QtGui.QPixmap.hasAlphaChannel()¶
- Return type:
bool
Returns
true
if the pixmap has a format that respects the alpha channel, otherwise returnsfalse
.See also
- PySide2.QtGui.QPixmap.isNull()¶
- Return type:
bool
Returns
true
if this is a null pixmap; otherwise returnsfalse
.A null pixmap has zero width, zero height and no contents. You cannot draw in a null pixmap.
- PySide2.QtGui.QPixmap.isQBitmap()¶
- Return type:
bool
Returns
true
if this is aQBitmap
; otherwise returnsfalse
.
- PySide2.QtGui.QPixmap.load(fileName[, format=None[, flags=Qt.AutoColor]])¶
- Parameters:
fileName – str
format – str
flags –
ImageConversionFlags
- Return type:
bool
Loads a pixmap from the file with the given
fileName
. Returns true if the pixmap was successfully loaded; otherwise invalidates the pixmap and returnsfalse
.The loader attempts to read the pixmap using the specified
format
. If theformat
is not specified (which is the default), the loader probes the file for a header to guess the file format.The file name can either refer to an actual file on disk or to one of the application’s embedded resources. See the Resource System overview for details on how to embed pixmaps and other resource files in the application’s executable.
If the data needs to be modified to fit in a lower-resolution result (e.g. converting from 32-bit to 8-bit), use the
flags
to control the conversion.Note that QPixmaps are automatically added to the
QPixmapCache
when loaded from a file in main thread; the key used is internal and cannot be acquired.See also
loadFromData()
Reading and Writing Image Files
- PySide2.QtGui.QPixmap.loadFromData(data[, format=None[, flags=Qt.AutoColor]])¶
- Parameters:
data –
PySide2.QtCore.QByteArray
format – str
flags –
ImageConversionFlags
- Return type:
bool
This is an overloaded function.
Loads a pixmap from the binary
data
using the specifiedformat
and conversionflags
.
- PySide2.QtGui.QPixmap.loadFromData(buf[, format=None[, flags=Qt.AutoColor]])
- Parameters:
buf – str
format – str
flags –
ImageConversionFlags
- Return type:
bool
Loads a pixmap from the
len
first bytes of the given binarydata
. Returnstrue
if the pixmap was loaded successfully; otherwise invalidates the pixmap and returnsfalse
.The loader attempts to read the pixmap using the specified
format
. If theformat
is not specified (which is the default), the loader probes the file for a header to guess the file format.If the data needs to be modified to fit in a lower-resolution result (e.g. converting from 32-bit to 8-bit), use the
flags
to control the conversion.See also
load()
Reading and Writing Image Files
This method must be used with an QPixmap object, not the class:
# Wrong pixmap = QPixmap.loadFromData(...) # Right pixmap = QPixmap().loadFromData(...)
- PySide2.QtGui.QPixmap.mask()¶
- Return type:
Extracts a bitmap mask from the pixmap’s alpha channel.
Warning
This is potentially an expensive operation. The mask of the pixmap is extracted dynamically from the pixeldata.
See also
setMask()
Pixmap Information
- PySide2.QtGui.QPixmap.rect()¶
- Return type:
Returns the pixmap’s enclosing rectangle.
See also
Pixmap Information
- PySide2.QtGui.QPixmap.save(fileName[, format=None[, quality=-1]])¶
- Parameters:
fileName – str
format – str
quality – int
- Return type:
bool
- PySide2.QtGui.QPixmap.save(device[, format=None[, quality=-1]])
- Parameters:
device –
PySide2.QtCore.QIODevice
format – str
quality – int
- Return type:
bool
This is an overloaded function.
This function writes a
QPixmap
to the givendevice
using the specified image fileformat
andquality
factor. This can be used, for example, to save a pixmap directly into aQByteArray
:pixmap = QPixmap() bytes = QByteArray() buffer(bytes) buffer.open(QIODevice.WriteOnly) pixmap.save(buffer, "PNG") # writes pixmap into bytes in PNG format
- PySide2.QtGui.QPixmap.scaled(s[, aspectMode=Qt.IgnoreAspectRatio[, mode=Qt.FastTransformation]])¶
- Parameters:
aspectMode –
AspectRatioMode
mode –
TransformationMode
- Return type:
Scales the pixmap to the given
size
, using the aspect ratio and transformation modes specified byaspectRatioMode
andtransformMode
.If
aspectRatioMode
isIgnoreAspectRatio
, the pixmap is scaled tosize
.If
aspectRatioMode
isKeepAspectRatio
, the pixmap is scaled to a rectangle as large as possible insidesize
, preserving the aspect ratio.If
aspectRatioMode
isKeepAspectRatioByExpanding
, the pixmap is scaled to a rectangle as small as possible outsidesize
, preserving the aspect ratio.
If the given
size
is empty, this function returns a null pixmap.In some cases it can be more beneficial to draw the pixmap to a painter with a scale set rather than scaling the pixmap. This is the case when the painter is for instance based on OpenGL or when the scale factor changes rapidly.
See also
isNull()
Pixmap Transformations
- PySide2.QtGui.QPixmap.scaled(w, h[, aspectMode=Qt.IgnoreAspectRatio[, mode=Qt.FastTransformation]])
- Parameters:
w – int
h – int
aspectMode –
AspectRatioMode
mode –
TransformationMode
- Return type:
This is an overloaded function.
Returns a copy of the pixmap scaled to a rectangle with the given
width
andheight
according to the givenaspectRatioMode
andtransformMode
.If either the
width
or theheight
is zero or negative, this function returns a null pixmap.
- PySide2.QtGui.QPixmap.scaledToHeight(h[, mode=Qt.FastTransformation])¶
- Parameters:
h – int
mode –
TransformationMode
- Return type:
Returns a scaled copy of the image. The returned image is scaled to the given
height
using the specified transformationmode
. The width of the pixmap is automatically calculated so that the aspect ratio of the pixmap is preserved.If
height
is 0 or negative, a null pixmap is returned.See also
isNull()
Pixmap Transformations
- PySide2.QtGui.QPixmap.scaledToWidth(w[, mode=Qt.FastTransformation])¶
- Parameters:
w – int
mode –
TransformationMode
- Return type:
Returns a scaled copy of the image. The returned image is scaled to the given
width
using the specified transformationmode
. The height of the pixmap is automatically calculated so that the aspect ratio of the pixmap is preserved.If
width
is 0 or negative, a null pixmap is returned.See also
isNull()
Pixmap Transformations
- PySide2.QtGui.QPixmap.scroll(dx, dy, rect[, exposed=None])¶
- Parameters:
dx – int
dy – int
rect –
PySide2.QtCore.QRect
exposed –
PySide2.QtGui.QRegion
Scrolls the area
rect
of this pixmap by (dx
,dy
). The exposed region is left unchanged. You can optionally pass a pointer to an emptyQRegion
to get the region that isexposed
by the scroll operation.pixmap = QPixmap("background.png") exposed = QRegion() pixmap.scroll(10, 10, pixmap.rect(), exposed)
You cannot scroll while there is an active painter on the pixmap.
See also
scroll()
scroll()
- PySide2.QtGui.QPixmap.scroll(dx, dy, x, y, width, height[, exposed=None])
- Parameters:
dx – int
dy – int
x – int
y – int
width – int
height – int
exposed –
PySide2.QtGui.QRegion
This convenience function is equivalent to calling (
dx
,dy
,QRect
(x
,y
,width
,height
),exposed
).See also
scroll()
scroll()
- PySide2.QtGui.QPixmap.setDevicePixelRatio(scaleFactor)¶
- Parameters:
scaleFactor – float
Sets the device pixel ratio for the pixmap. 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 pixmap 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 pixmap size will take the ratio into account:
QSize
layoutSize = pixmap.size()
/ pixmap.devicePixelRatio()
The net effect of this is that the pixmap is displayed as high-DPI pixmap rather than a large pixmap (seeDrawing High Resolution Versions of Pixmaps and Images
).See also
devicePixelRatio()
- PySide2.QtGui.QPixmap.setMask(arg__1)¶
- Parameters:
arg__1 –
PySide2.QtGui.QBitmap
Sets a mask bitmap.
This function merges the
mask
with the pixmap’s alpha channel. A pixel value of 1 on the mask means the pixmap’s pixel is unchanged; a value of 0 means the pixel is transparent. The mask must have the same size as this pixmap.Setting a null mask resets the mask, leaving the previously transparent pixels black. The effect of this function is undefined when the pixmap is being painted on.
Warning
This is potentially an expensive operation.
- PySide2.QtGui.QPixmap.size()¶
- Return type:
Returns the size of the pixmap.
See also
width()
height()
Pixmap Information
- PySide2.QtGui.QPixmap.swap(other)¶
- Parameters:
other –
PySide2.QtGui.QPixmap
Swaps pixmap
other
with this pixmap. This operation is very fast and never fails.
- PySide2.QtGui.QPixmap.toImage()¶
- Return type:
Converts the pixmap to a
QImage
. Returns a null image if the conversion fails.If the pixmap has 1-bit depth, the returned image will also be 1 bit deep. Images with more bits will be returned in a format closely represents the underlying system. Usually this will be
Format_ARGB32_Premultiplied
for pixmaps with an alpha andFormat_RGB32
orFormat_RGB16
for pixmaps without alpha.Note that for the moment, alpha masks on monochrome images are ignored.
See also
fromImage()
Image Formats
- PySide2.QtGui.QPixmap.transformed(arg__1[, mode=Qt.FastTransformation])¶
- Parameters:
arg__1 –
PySide2.QtGui.QMatrix
mode –
TransformationMode
- Return type:
Note
This function is deprecated.
- PySide2.QtGui.QPixmap.transformed(arg__1[, mode=Qt.FastTransformation])
- Parameters:
arg__1 –
PySide2.QtGui.QTransform
mode –
TransformationMode
- Return type:
- static PySide2.QtGui.QPixmap.trueMatrix(m, w, h)¶
- Parameters:
w – int
h – int
- Return type:
Note
This function is deprecated.
- static PySide2.QtGui.QPixmap.trueMatrix(m, w, h)
- Parameters:
w – int
h – int
- Return type:
© 2022 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.