forked from benlau/quickandroid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqadrawableprovider.h
52 lines (34 loc) · 1.21 KB
/
qadrawableprovider.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef QADRAWABLEPROVIDER_H
#define QADRAWABLEPROVIDER_H
#include <QQuickImageProvider>
#include <QMap>
#include <QMutex>
#include <QCache>
class QADrawableProvider : public QQuickImageProvider
{
public:
QADrawableProvider();
QString basePath() const;
/// Set the base path for resource loading
void setBasePath(const QString &basePath);
virtual QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize);
/// Get the cache size limit
int limit() const;
/// Set the cache size limit by bytes
void setLimit(int limit);
private:
bool contains(const QString &id);
QImage get(const QString &id);
void insert(const QString &id,QImage image);
QImage loadFileName(QString filename,QString dpi,QColor tintColor,qreal scale = 1.0);
QImage loadPrefix(QString prefix,QColor tintColor, qreal scale = 1.0);
QImage loadAbsPath(QString path,QColor tintColor, qreal scale = 1.0);
QColor parseTintColor(const QString& query);
QImage colorize(QImage image,QColor color);
void gray(QImage&dest, QImage& image);
QString m_basePath;
QCache<QString,QImage> storage;
mutable QMutex mutex;
int m_limit;
};
#endif // QADRAWABLEPROVIDER_H