summaryrefslogtreecommitdiff
path: root/noncore/graphics/opie-eye/lib/imagecache.h
blob: 939247aa57c73ce1b8273427f36a114487d54a49 (plain)
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
/*
 * GPLv2 zecke@handhelds.org
 * No WArranty...
 */

#ifndef PHUNK_IMAGE_CACHE_H
#define PHUNK_IMAGE_CACHE_H

#include <qimage.h>
#include <qpixmap.h>
#include <qcache.h>


class PImageCache : public QCache<QImage> {
private:
    PImageCache();
    ~PImageCache();

public:
    static PImageCache *self();
    QImage* cachedImage( const QString& path, int orientation = 3,  int max = 0); //const;
    void insertImage(  const QString& path, const QImage &, int orien = 3, int max = 0);
    void insertImage(  const QString& path, const QImage *, int orien=3, int max = 0 );
};


class PPixmapCache : public  QCache<QPixmap> {
private:
    PPixmapCache();
    ~PPixmapCache();

    unsigned int m_MaxImages;

public:
    static PPixmapCache *self();
    QPixmap* cachedImage(  const QString&  path, int width, int height );
    void insertImage( const QString& path, const QPixmap &, int width,  int height );
    void insertImage( const QString& path, const QPixmap *, int width, int height );
    void setMaxImages(unsigned int aMax);
    unsigned int maxImages()const{return m_MaxImages;}
};

inline void PPixmapCache::insertImage( const QString& path, const QPixmap& p, int width, int height ) {
    insertImage( path,  new QPixmap( p ), width, height );
}

inline void PImageCache::insertImage( const QString& path, const QImage& p, int width, int height ) {
    insertImage( path, new QImage( p ), width, height );
}

#endif