Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE][API] Add a content cache for raster images
This new class QgsImageCache is the equivalent of QgsSvgCache but for raster images. QgsImageCache stores pre-rendered resampled versions of raster image files, allowing efficient reuse without incurring the cost of resampling on every render. Additionally, it offers the other benefits QgsSvgCache has, such as thread safety, ability to transparently download remote images, and support for base64 encoded strings.
- Loading branch information
1 parent
cdba8f5
commit 84838d1
Showing
29 changed files
with
788 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgsimagecache.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
|
||
|
||
class QgsImageCache : QgsAbstractContentCacheBase | ||
{ | ||
%Docstring | ||
A cache for images derived from raster files. | ||
|
||
QgsImageCache stores pre-rendered resampled versions of raster image files, allowing efficient | ||
reuse without incurring the cost of resampling on every render. | ||
|
||
QgsImageCache is not usually directly created, but rather accessed through | ||
:py:func:`QgsApplication.imageCache()` | ||
|
||
.. versionadded:: 3.6 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsimagecache.h" | ||
%End | ||
public: | ||
|
||
QgsImageCache( QObject *parent /TransferThis/ = 0 ); | ||
%Docstring | ||
Constructor for QgsImageCache, with the specified ``parent`` object. | ||
%End | ||
|
||
QImage pathAsImage( const QString &path, QSize size, bool keepAspectRatio, bool &fitsInCache /Out/ ); | ||
%Docstring | ||
Returns the specified ``path`` rendered as an image. If possible, a pre-existing cached | ||
version of the image will be used. If not, the image is fetched and resampled to the desired | ||
size, and then the result cached for subsequent lookups. | ||
|
||
``path`` may be a local file, remote (HTTP) url, or a base 64 encoded string (with a "base64:" prefix). | ||
|
||
The ``size`` parameter dictates the target size of the image. An invalid size indicates the | ||
original raster image size (with no resampling). | ||
|
||
If ``keepAspectRatio`` is true, then the original raster aspect ratio will be maintained during | ||
any resampling operations. | ||
|
||
If the resultant raster was of a sufficiently small size to store in the cache, then ``fitsInCache`` | ||
will be set to true. | ||
%End | ||
|
||
signals: | ||
|
||
void remoteImageFetched( const QString &url ); | ||
%Docstring | ||
Emitted when the cache has finished retrieving an image file from a remote ``url``. | ||
%End | ||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgsimagecache.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.