PySide6.QtCanvasPainter.QCanvasOffscreenCanvas¶
- class QCanvasOffscreenCanvas¶
QCanvasOffscreenCanvasrepresents an offscreen canvas thatQCanvasPaintercan target.Details
An offscreen canvas is essentially a color buffer (a QRhiTexture), and possibly other associated graphics resources. After content has been rendered into the canvas’s color buffer, the canvas can be
registeredto the painter to retrieve aQCanvasImagethat can then be used indrawImage()calls or as animage pattern.To create an offscreen canvas, call
createCanvas(). To target an offscreen canvas with with draw commands, call the appropriatebeginPaint()overload when working with the lower level API, orbeginCanvasPainting()orbeginCanvasPainting()when using the convenience widget or Qt Quick item classes.Similarly to
QCanvasImageandQCanvasBrush,QCanvasOffscreenCanvasis explicitly shared. See Implicit Data Sharing and QSharedDataPointer for details.Note
As with
QCanvasImage, aQCanvasOffscreenCanvascan be seen as an object merely containing handles. Even when a detach occurs, the actual resources, e.g. the underlying texture and the image data in it, are never actually copied or duplicated. The actual owner of any real graphics resources (e.g., a QRhiTexture) is theQCanvasPainterthat handed out theQCanvasOffscreenCanvasviacreateCanvas().A canvas always belongs to the
QCanvasPainterthat created it. Manually destroying canvases is done by callingdestroyCanvas(). In most cases this will not be necessary, however, since the painter will automatically destroy any canvases during its own destruction.Synopsis¶
Methods¶
def
__init__()def
fillColor()def
flags()def
isNull()def
__ne__()def
__eq__()def
setFillColor()def
swap()def
texture()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
- class Flag¶
(inherits
enum.Flag) Specifies the flags for the canvas.Constant
Description
QCanvasOffscreenCanvas.Flag.Flag.PreserveContents
Indicates that the contents of the canvas is preserved when painting to it. This can have a negative effect on performance, depending on the GPU architecture. See QRhiTextureRenderTarget::PreserveColorContents for details. Setting this flag is not supported when the sample count is greater than 1.
QCanvasOffscreenCanvas.Flag.Flag.MipMaps
Indicates that the canvas’ backing texture should have mipmapping enabled. Setting this flag is not supported when the sample count is greater than 1. Note that the mipmap sequence is generated when calling
addImage()with theGenerateMipmapsflag set. This implies that addImage() must be called every time after the canvas’ content changes, so that the mipmap chain is regenerated. Frequent mipmap generation can have a negative effect on performance.
- __init__()¶
- __init__(canvas)
- Parameters:
canvas –
QCanvasOffscreenCanvas
Copy constructor.
Returns the current fill color.
See also
Returns the flags with which the canvas was created.
The flags are immutable and cannot be changed once the canvas has been created.
- isNull()¶
- Return type:
bool
Returns true if this canvas has valid data.
Normally this will always be true.
See also
- __ne__(rhs)¶
- Parameters:
rhs –
QCanvasOffscreenCanvas- Return type:
bool
- __eq__(rhs)¶
- Parameters:
rhs –
QCanvasOffscreenCanvas- Return type:
bool
Sets the fill (clear) color to
color.By default this is set to the value passed to
createCanvas().See also
- swap(other)¶
- Parameters:
other –
QCanvasOffscreenCanvas
- texture()¶
- Return type:
Returns the texture backing this offscreen canvas.
See also