QGIS API Documentation 4.3.0-Master (0cef2469b72)
Loading...
Searching...
No Matches
QgsPictureRasterizer Class Reference

Rasterizes and caches a QPicture as a QImage at a requested size. More...

#include <qgspicturerasterizer.h>

Inheritance diagram for QgsPictureRasterizer:

Signals

void rendered ()
 Emitted when a background rasterization finishes and a new cached image is available.

Public Member Functions

 QgsPictureRasterizer (QObject *parent=nullptr)
 Constructor for QgsPictureRasterizer, with the specified parent object.
 ~QgsPictureRasterizer () override
void clear ()
 Clears the source picture and cached image, canceling any in-progress background render.
QImage image (const QSize &targetSize)
 Immediately returns the best available QImage for the given targetSize.
void invalidate ()
 Immediately invalidates the current cached image.
bool isRendering () const
 Returns true if a background job is currently running or scheduled.
int maxCacheSize () const
 Returns the maximum width or height (in pixels) of the cached QImage.
QPicture picture () const
 Returns the current source QPicture.
void setMaxCacheSize (int maxSize)
 Sets the maximum width or height (in pixels) of the cached QImage.
void setPicture (const QPicture &picture)
 Sets the source picture to cache.

Detailed Description

Rasterizes and caches a QPicture as a QImage at a requested size.

Allows for background asynchronous regeneration of the cached image at a different size.

This class is useful for generating pre-rendered versions of QPictures for rendering on the main GUI thread, where those pictures are too expensive to draw directly.

Since
QGIS 4.4

Definition at line 69 of file qgspicturerasterizer.h.

Constructor & Destructor Documentation

◆ QgsPictureRasterizer()

PRIVATE QgsPictureRasterizer::QgsPictureRasterizer ( QObject * parent = nullptr)
explicit

Constructor for QgsPictureRasterizer, with the specified parent object.

Definition at line 98 of file qgspicturerasterizer.cpp.

◆ ~QgsPictureRasterizer()

QgsPictureRasterizer::~QgsPictureRasterizer ( )
override

Definition at line 106 of file qgspicturerasterizer.cpp.

Member Function Documentation

◆ clear()

void QgsPictureRasterizer::clear ( )

Clears the source picture and cached image, canceling any in-progress background render.

Definition at line 128 of file qgspicturerasterizer.cpp.

◆ image()

QImage QgsPictureRasterizer::image ( const QSize & targetSize)

Immediately returns the best available QImage for the given targetSize.

This method never blocks. If no cached image exists for the specified targetSize or the cache has been invalidated then the previously cached image is returned, and a background render at the desired targetSize will be started.

Definition at line 148 of file qgspicturerasterizer.cpp.

◆ invalidate()

void QgsPictureRasterizer::invalidate ( )

Immediately invalidates the current cached image.

Definition at line 139 of file qgspicturerasterizer.cpp.

◆ isRendering()

bool QgsPictureRasterizer::isRendering ( ) const

Returns true if a background job is currently running or scheduled.

Definition at line 177 of file qgspicturerasterizer.cpp.

◆ maxCacheSize()

int QgsPictureRasterizer::maxCacheSize ( ) const
inline

Returns the maximum width or height (in pixels) of the cached QImage.

See also
setMaxCacheSize()

Definition at line 130 of file qgspicturerasterizer.h.

◆ picture()

QPicture QgsPictureRasterizer::picture ( ) const
inline

Returns the current source QPicture.

See also
setPicture()

Definition at line 92 of file qgspicturerasterizer.h.

◆ rendered

void QgsPictureRasterizer::rendered ( )
signal

Emitted when a background rasterization finishes and a new cached image is available.

◆ setMaxCacheSize()

void QgsPictureRasterizer::setMaxCacheSize ( int maxSize)

Sets the maximum width or height (in pixels) of the cached QImage.

See also
maxCacheSize()

Definition at line 182 of file qgspicturerasterizer.cpp.

◆ setPicture()

void QgsPictureRasterizer::setPicture ( const QPicture & picture)

Sets the source picture to cache.

See also
picture()

Definition at line 112 of file qgspicturerasterizer.cpp.


The documentation for this class was generated from the following files: