summaryrefslogtreecommitdiff
path: root/noncore/graphics/opie-eye/slave/thumbnailtool.cpp
Unidiff
Diffstat (limited to 'noncore/graphics/opie-eye/slave/thumbnailtool.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/slave/thumbnailtool.cpp3
1 files changed, 0 insertions, 3 deletions
diff --git a/noncore/graphics/opie-eye/slave/thumbnailtool.cpp b/noncore/graphics/opie-eye/slave/thumbnailtool.cpp
index d2e169c..62bb1e6 100644
--- a/noncore/graphics/opie-eye/slave/thumbnailtool.cpp
+++ b/noncore/graphics/opie-eye/slave/thumbnailtool.cpp
@@ -22,40 +22,37 @@ static bool makeThumbDir( const QFileInfo& inf, bool make = false) {
22} 22}
23 23
24 24
25/* 25/*
26 * check if the Opie opie-eye dir exists 26 * check if the Opie opie-eye dir exists
27 * check if a thumbnail exists 27 * check if a thumbnail exists
28 * load the thumbnail 28 * load the thumbnail
29 * /foo/bar/imagefoo.gif 29 * /foo/bar/imagefoo.gif
30 * check for a png in /foo/bar/.opie-eye/%dx%d-imagefoo.gif 30 * check for a png in /foo/bar/.opie-eye/%dx%d-imagefoo.gif
31 */ 31 */
32QPixmap ThumbNailTool::getThumb( const QString& path, int width, int height ) { 32QPixmap ThumbNailTool::getThumb( const QString& path, int width, int height ) {
33 QFileInfo inf( path ); 33 QFileInfo inf( path );
34 owarn << "Get Thumb" << oendl;
35 if ( !makeThumbDir( inf ) ) { 34 if ( !makeThumbDir( inf ) ) {
36 QPixmap pix; 35 QPixmap pix;
37 return pix; 36 return pix;
38 } 37 }
39 QString str = QString( "/.opie-eye/%1x%2-%3" ).arg( width ).arg( height ).arg( inf.fileName() ); 38 QString str = QString( "/.opie-eye/%1x%2-%3" ).arg( width ).arg( height ).arg( inf.fileName() );
40 owarn << inf.dirPath()+str << oendl;
41 return QPixmap( inf.dirPath()+str,"PNG" ); 39 return QPixmap( inf.dirPath()+str,"PNG" );
42 40
43} 41}
44 42
45void ThumbNailTool::putThumb( const QString& path, const QPixmap& pix, int width, int height ) { 43void ThumbNailTool::putThumb( const QString& path, const QPixmap& pix, int width, int height ) {
46 QFileInfo inf( path ); 44 QFileInfo inf( path );
47 makeThumbDir( inf, true ); 45 makeThumbDir( inf, true );
48 QString str = QString( "/.opie-eye/%1x%2-%3" ).arg( width ).arg( height ).arg( inf.fileName() ); 46 QString str = QString( "/.opie-eye/%1x%2-%3" ).arg( width ).arg( height ).arg( inf.fileName() );
49 owarn << inf.dirPath()+str << oendl;
50 pix.save( inf.dirPath()+str, "PNG" ); 47 pix.save( inf.dirPath()+str, "PNG" );
51} 48}
52 49
53 50
54QPixmap ThumbNailTool::scaleImage( QImage& img, int w, int h ) { 51QPixmap ThumbNailTool::scaleImage( QImage& img, int w, int h ) {
55 double hs = (double)h / (double)img.height() ; 52 double hs = (double)h / (double)img.height() ;
56 double ws = (double)w / (double)img.width() ; 53 double ws = (double)w / (double)img.width() ;
57 double scaleFactor = (hs > ws) ? ws : hs; 54 double scaleFactor = (hs > ws) ? ws : hs;
58 int smoothW = (int)(scaleFactor * img.width()); 55 int smoothW = (int)(scaleFactor * img.width());
59 int smoothH = (int)(scaleFactor * img.height()); 56 int smoothH = (int)(scaleFactor * img.height());
60 QPixmap pixmap; 57 QPixmap pixmap;
61 if ( img.width() <= w && img.height() <= h ) 58 if ( img.width() <= w && img.height() <= h )