00001
00002
00003
00004
00005
00006 #ifndef PHUNK_IMAGE_CACHE_H
00007 #define PHUNK_IMAGE_CACHE_H
00008
00009 #include <qimage.h>
00010 #include <qpixmap.h>
00011 #include <qcache.h>
00012
00013
00014 class PImageCache : public QCache<QImage> {
00015 private:
00016 PImageCache();
00017 ~PImageCache();
00018
00019 public:
00020 static PImageCache *self();
00021 QImage* cachedImage( const QString& path, int orientation = 3, int max = 0);
00022 void insertImage( const QString& path, const QImage &, int orien = 3, int max = 0);
00023 void insertImage( const QString& path, const QImage *, int orien=3, int max = 0 );
00024 };
00025
00026
00027 class PPixmapCache : public QCache<QPixmap> {
00028 private:
00029 PPixmapCache();
00030 ~PPixmapCache();
00031
00032 unsigned int m_MaxImages;
00033
00034 public:
00035 static PPixmapCache *self();
00036 QPixmap* cachedImage( const QString& path, int width, int height );
00037 void insertImage( const QString& path, const QPixmap &, int width, int height );
00038 void insertImage( const QString& path, const QPixmap *, int width, int height );
00039 void setMaxImages(unsigned int aMax);
00040 unsigned int maxImages()const{return m_MaxImages;}
00041 };
00042
00043 inline void PPixmapCache::insertImage( const QString& path, const QPixmap& p, int width, int height ) {
00044 insertImage( path, new QPixmap( p ), width, height );
00045 }
00046
00047 inline void PImageCache::insertImage( const QString& path, const QImage& p, int width, int height ) {
00048 insertImage( path, new QImage( p ), width, height );
00049 }
00050
00051 #endif