author | zecke <zecke> | 2004-03-22 23:32:41 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-03-22 23:32:41 (UTC) |
commit | 428b687982966dc2efabaf6dbcc55ad0ea30aa10 (patch) (unidiff) | |
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 @@ | |||
1 | /* | ||
2 | * GPLv2 zecke@handhelds.org | ||
3 | * No WArranty... | ||
4 | */ | ||
5 | |||
6 | #include <iface/dirview.h> | ||
7 | #include <iface/dirlister.h> | ||
8 | |||
9 | #include "imagecache.h" | ||
10 | |||
11 | namespace { | ||
12 | PImageCache * _imgCache = 0; | ||
13 | PPixmapCache* _pxmCache = 0; | ||
14 | } | ||
15 | |||
16 | |||
17 | PImageCache::PImageCache() | ||
18 | : QCache<QImage>() | ||
19 | { | ||
20 | /* just to set an initial value.. 4 big images */ | ||
21 | setMaxCost( (1024*1024*16)/8*4 ); | ||
22 | } | ||
23 | |||
24 | PImageCache::~PImageCache() { | ||
25 | } | ||
26 | |||
27 | PImageCache* PImageCache::self() { | ||
28 | if ( !_imgCache ) | ||
29 | _imgCache = new PImageCache; | ||
30 | return _imgCache; | ||
31 | } | ||
32 | |||
33 | QImage* PImageCache::cachedImage( const QString& _path, int ori, int max ) { | ||
34 | QString path = QString( "%1_%2:" ).arg( ori ).arg( max ); | ||
35 | path += _path; | ||
36 | |||
37 | QImage* img = find( path ); | ||
38 | if ( !img ) { | ||
39 | // img = currentView()->dirLister()->image( _path, PDirLister::Factor(ori), max); | ||
40 | // insertImage( _path, img, ori, max ); | ||
41 | currentView()->dirLister()->image( _path, PDirLister::Factor( ori ), max ); | ||
42 | } | ||
43 | |||
44 | |||
45 | return img; | ||
46 | } | ||
47 | |||
48 | void PImageCache::insertImage( const QString& _path, const QImage* img, int ori, int max ) { | ||
49 | QString path = QString("%1_%2:" ).arg( ori ).arg( max ); | ||
50 | path += _path; | ||
51 | insert( path, img, (img->height()*img->width()*img->depth())/8 ); | ||
52 | } | ||
53 | |||
54 | |||
55 | PPixmapCache::PPixmapCache() { | ||
56 | /* | ||
57 | * 20 64x64 16 bit images | ||
58 | */ | ||
59 | setMaxCost( 64*64*QPixmap::defaultDepth()/8*20 ); | ||
60 | } | ||
61 | |||
62 | PPixmapCache::~PPixmapCache() { | ||
63 | } | ||
64 | |||
65 | PPixmapCache* PPixmapCache::self() { | ||
66 | if ( !_pxmCache ) | ||
67 | _pxmCache = new PPixmapCache; | ||
68 | |||
69 | return _pxmCache; | ||
70 | } | ||
71 | |||
72 | QPixmap* PPixmapCache::cachedImage( const QString& _path, int width, int height ) { | ||
73 | QString path = QString( "%1_%2:" ).arg( width ).arg( height ); | ||
74 | path += _path; | ||
75 | |||
76 | QPixmap* pxm = find( path ); | ||
77 | |||
78 | |||
79 | |||
80 | return pxm; | ||
81 | } | ||
82 | |||
83 | void PPixmapCache::insertImage( const QString& _path, const QPixmap* pix, int width, int height ) { | ||
84 | QString path = QString("%1_%2:" ).arg( width ).arg( height ); | ||
85 | path += _path; | ||
86 | insert( path, pix, (pix->height()*pix->width()*pix->depth())/8 ); | ||
87 | } | ||