author | zecke <zecke> | 2004-03-22 23:32:41 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-03-22 23:32:41 (UTC) |
commit | 428b687982966dc2efabaf6dbcc55ad0ea30aa10 (patch) (side-by-side diff) | |
tree | 86da20abd2e4b97a59dc32e17996bde5ee74cc91 /noncore/graphics/opie-eye/lib/imagecache.cpp | |
parent | 7ce623c6351646ce738a81e103632d73c5454ecc (diff) | |
download | opie-428b687982966dc2efabaf6dbcc55ad0ea30aa10.zip opie-428b687982966dc2efabaf6dbcc55ad0ea30aa10.tar.gz opie-428b687982966dc2efabaf6dbcc55ad0ea30aa10.tar.bz2 |
Initial Check in of the Eye Of Zilla. This ImageViewer features
Image Infos, EXIF, Jpeg,Png,Gif support. It supports scaled loading
of Jpegs. an smart image cache....
GUI needs some work and we need to find a bug in QCOP as well.
TODO:
Add Image Service for example Mailer
Add ImageCanvas/Zoomer/Display
Diffstat (limited to 'noncore/graphics/opie-eye/lib/imagecache.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/opie-eye/lib/imagecache.cpp | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/noncore/graphics/opie-eye/lib/imagecache.cpp b/noncore/graphics/opie-eye/lib/imagecache.cpp new file mode 100644 index 0000000..3b74a83 --- a/dev/null +++ b/noncore/graphics/opie-eye/lib/imagecache.cpp @@ -0,0 +1,87 @@ +/* + * GPLv2 zecke@handhelds.org + * No WArranty... + */ + +#include <iface/dirview.h> +#include <iface/dirlister.h> + +#include "imagecache.h" + +namespace { + PImageCache * _imgCache = 0; + PPixmapCache* _pxmCache = 0; +} + + +PImageCache::PImageCache() + : QCache<QImage>() +{ + /* just to set an initial value.. 4 big images */ + setMaxCost( (1024*1024*16)/8*4 ); +} + +PImageCache::~PImageCache() { +} + +PImageCache* PImageCache::self() { + if ( !_imgCache ) + _imgCache = new PImageCache; + return _imgCache; +} + +QImage* PImageCache::cachedImage( const QString& _path, int ori, int max ) { + QString path = QString( "%1_%2:" ).arg( ori ).arg( max ); + path += _path; + + QImage* img = find( path ); + if ( !img ) { +// img = currentView()->dirLister()->image( _path, PDirLister::Factor(ori), max); +// insertImage( _path, img, ori, max ); + currentView()->dirLister()->image( _path, PDirLister::Factor( ori ), max ); + } + + + return img; +} + +void PImageCache::insertImage( const QString& _path, const QImage* img, int ori, int max ) { + QString path = QString("%1_%2:" ).arg( ori ).arg( max ); + path += _path; + insert( path, img, (img->height()*img->width()*img->depth())/8 ); +} + + +PPixmapCache::PPixmapCache() { + /* + * 20 64x64 16 bit images + */ + setMaxCost( 64*64*QPixmap::defaultDepth()/8*20 ); +} + +PPixmapCache::~PPixmapCache() { +} + +PPixmapCache* PPixmapCache::self() { + if ( !_pxmCache ) + _pxmCache = new PPixmapCache; + + return _pxmCache; +} + +QPixmap* PPixmapCache::cachedImage( const QString& _path, int width, int height ) { + QString path = QString( "%1_%2:" ).arg( width ).arg( height ); + path += _path; + + QPixmap* pxm = find( path ); + + + + return pxm; +} + +void PPixmapCache::insertImage( const QString& _path, const QPixmap* pix, int width, int height ) { + QString path = QString("%1_%2:" ).arg( width ).arg( height ); + path += _path; + insert( path, pix, (pix->height()*pix->width()*pix->depth())/8 ); +} |