18#ifndef QGSIMAGECACHE_H
19#define QGSIMAGECACHE_H
25#include <QElapsedTimer>
48 QgsImageSizeCacheEntry(
const QString &path ) ;
54 void dump()
const override;
55 bool isEqual(
const QgsAbstractContentCacheEntry *other )
const override;
78 ~QgsImageSizeCache()
override;
79 long maximumSize()
const {
return mMaxCacheSize; }
80 QSize originalSize(
const QString &path,
bool blocking =
false );
104 QgsImageCacheEntry(
const QString &path, QSize size,
bool keepAspectRatio,
double opacity,
double targetDpi,
int frameNumber ) ;
110 bool keepAspectRatio =
true;
113 double opacity = 1.0;
123 bool isMissingImage =
false;
130 double targetDpi = 96;
137 int frameNumber = -1;
144 int totalFrameCount = -1;
151 int nextFrameDelay = -1;
154 void dump()
const override;
155 bool isEqual(
const QgsAbstractContentCacheEntry *other )
const override;
227 QImage pathAsImage(
const QString &path,
const QSize size,
const bool keepAspectRatio,
const double opacity,
bool &fitsInCache
SIP_OUT,
bool blocking =
false,
double targetDpi = 96,
int frameNumber = -1,
bool *isMissing
SIP_PYARGREMOVE =
nullptr );
244 QSize originalSize(
const QString &path,
bool blocking =
false )
const;
263 int totalFrameCount(
const QString &path,
bool blocking =
false );
283 int nextFrameDelay(
const QString &path,
int currentFrame = 0,
bool blocking =
false );
290 void prepareAnimation(
const QString &path );
301 QImage pathAsImagePrivate(
const QString &path,
const QSize size,
const bool keepAspectRatio,
const double opacity,
bool &fitsInCache,
bool blocking,
double targetDpi,
int frameNumber,
bool *isMissing,
int &
totalFrameCount,
int &nextFrameDelayMs );
303 QImage renderImage(
const QString &path, QSize size,
const bool keepAspectRatio,
const double opacity,
double targetDpi,
int frameNumber,
bool &isBroken,
int &
totalFrameCount,
int &nextFrameDelayMs,
bool blocking =
false )
const;
305 static QImage getFrameFromReader( QImageReader &reader,
int frameNumber );
307 QSize originalSizePrivate(
const QString &path,
bool blocking =
false )
const;
310 QByteArray mMissingSvg;
312 QByteArray mFetchingSvg;
314 QMap< QString, QString > mExtractedAnimationPaths;
315 std::unique_ptr< QTemporaryDir > mTemporaryDir;
316 QMap< QString, int > mTotalFrameCounts;
317 QMap< QString, QVector< int > > mImageDelays;
A QObject derived base class for QgsAbstractContentCache.
Base class for entries in a QgsAbstractContentCache.
virtual int dataSize() const =0
Returns the memory usage in bytes for the entry.
virtual void dump() const =0
Dumps debugging strings containing the item's properties.
virtual bool isEqual(const QgsAbstractContentCacheEntry *other) const =0
Tests whether this entry matches another entry.
Abstract base class for file content caches, such as SVG or raster image caches.
QgsAbstractContentCache(QObject *parent=nullptr, const QString &typeString=QString(), long maxCacheSize=20000000, int fileModifiedCheckTimeout=30000)
A cache for images derived from raster files.
friend class TestQgsImageCache
friend class QgsImageSizeCache
QgsImageCache(QObject *parent=nullptr)
Constructor for QgsImageCache, with the specified parent object.
int totalFrameCount(const QString &path, bool blocking=false)
Returns the total frame count of the image at the specified path.
~QgsImageCache() override
void remoteImageFetched(const QString &url)
Emitted when the cache has finished retrieving an image file from a remote url.
long maximumSize() const
Returns the maximum size of the cache, in bytes.