mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-11-04 00:04:25 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			102 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			102 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
/************************************************************************
 | 
						|
 * 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(signature="appended")
 | 
						|
A cache for images derived from raster files.
 | 
						|
 | 
						|
:py:class:`QgsImageCache` stores pre-rendered resampled versions of raster image files, allowing efficient
 | 
						|
reuse without incurring the cost of resampling on every render.
 | 
						|
 | 
						|
:py:class:`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, const QSize size, const bool keepAspectRatio, const double opacity, bool &fitsInCache /Out/, bool blocking = false, double targetDpi = 96 );
 | 
						|
%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). A size in which the width or height is
 | 
						|
set to zero will have the zeroed value automatically computed when keepAspectRatio is ``True``.
 | 
						|
 | 
						|
If ``keepAspectRatio`` is ``True``, then the original raster aspect ratio will be maintained during
 | 
						|
any resampling operations.
 | 
						|
 | 
						|
An ``opacity`` parameter dictates the opacity of the image.
 | 
						|
 | 
						|
If the resultant raster was of a sufficiently small size to store in the cache, then ``fitsInCache``
 | 
						|
will be set to ``True``.
 | 
						|
 | 
						|
The ``blocking`` boolean forces to wait for loading before returning image. The content is loaded
 | 
						|
in the same thread to ensure provided the image. WARNING: the ``blocking`` parameter must NEVER
 | 
						|
be ``True`` from GUI based applications (like the main QGIS application) or crashes will result. Only for
 | 
						|
use in external scripts or QGIS server.
 | 
						|
 | 
						|
Since QGIS 3.22 the ``targetDpi`` argument can be used to specify an explicit DPI to render the image
 | 
						|
at. This is used for some image formats (e.g. PDF) to ensure that content is rendered at the desired
 | 
						|
DPI. This argument is only used when an invalid ``size`` argument is specified. If a valid ``size`` is
 | 
						|
specified then the image will always be rendered at this size, regardless of the ``targetDpi``.
 | 
						|
%End
 | 
						|
 | 
						|
    QSize originalSize( const QString &path, bool blocking = false ) const;
 | 
						|
%Docstring
 | 
						|
Returns the original size (in pixels) of the image at the specified ``path``.
 | 
						|
 | 
						|
``path`` may be a local file, remote (HTTP) url, or a base 64 encoded string (with a "base64:" prefix).
 | 
						|
 | 
						|
If ``path`` is a remote file, then an invalid size may be returned while the image is in the process
 | 
						|
of being fetched.
 | 
						|
 | 
						|
The ``blocking`` boolean forces to wait for loading before returning the original size. The content is loaded
 | 
						|
in the same thread to ensure provided the original size. WARNING: the ``blocking`` parameter must NEVER
 | 
						|
be ``True`` from GUI based applications (like the main QGIS application) or crashes will result. Only for
 | 
						|
use in external scripts or QGIS server.
 | 
						|
 | 
						|
If the image could not be read then an invalid QSize is returned.
 | 
						|
%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   *
 | 
						|
 ************************************************************************/
 |