[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/multimedia/amarok/src
From: Seb Ruiz <seb100 () optusnet ! com ! au>
Date: 2005-07-03 6:32:51
Message-ID: 1120372371.539617.15754.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 431079 by seb:
Add shadow images for the osd.
Pro:
looks damn sexy
Con:
slower...
markey: if you can take a look at my code i would appreciate it, i'm not very good at \
this whole 'making images fast' thing yet :) CCMAIL:markey@web.de
M +34 -9 osd.cpp
--- trunk/extragear/multimedia/amarok/src/osd.cpp #431078:431079
@@ -11,13 +11,17 @@
* (C) 2004, 2005 Max Howell
*/
+#include "amarok.h"
#include "amarokconfig.h"
#include "debug.h"
#include "collectiondb.h" //for albumCover location
+#include "osd.h"
+
#include <kapplication.h>
#include <kpixmap.h>
#include <kpixmapeffect.h>
-#include "osd.h"
+#include <kstandarddirs.h> //locate
+
#include <qbitmap.h>
#include <qpainter.h>
#include <qregexp.h>
@@ -132,8 +136,13 @@
QMIN( rect.height(), m_cover.height() ),
QImage::ScaleMin ); //this will force us to be with our bounds
+ int shadowWidth = 0;
+ if( m_drawShadow && !m_scaledCover.hasAlpha() )
+ shadowWidth = static_cast<uint>( m_scaledCover.width() / 100.0 * 6.0 );
+
const int widthIncludingImage = rect.width()
+ m_scaledCover.width()
+ + shadowWidth
+ M; //margin between text + image
rect.setWidth( widthIncludingImage );
@@ -237,15 +246,33 @@
QRect r( rect );
r.setTop( (size.height() - m_scaledCover.height()) / 2 );
r.setSize( m_scaledCover.size() );
- p.drawPixmap( r.topLeft(), m_scaledCover );
- if( !m_scaledCover.hasAlpha() ) {
- // don't draw a border for eg, the amaroK icon
- r.addCoords( -1, -1, 1, 1 );
- p.setPen( shadowColor );
- p.drawRect( r );
+ if( !m_scaledCover.hasAlpha() && m_drawShadow ) {
+ // don't draw a shadow for eg, the amaroK icon
+ QImage shadow;
+ const uint shadowSize = static_cast<uint>( m_scaledCover.width() / 100.0 \
* 6.0 ); +
+ const QString folder = amaroK::saveLocation( "covershadow-cache/" );
+ const QString file = QString( "shadow_albumcover%1x%2.png" ).arg( \
m_scaledCover.width() + shadowSize ) + \
.arg( m_scaledCover.height() + shadowSize ); + if ( QFile::exists( folder \
+ file ) ) + shadow.load( folder + file );
+ else {
+ shadow.load( locate( "data", "amarok/images/shadow_albumcover.png" ) \
); + shadow = shadow.smoothScale( m_scaledCover.width() + shadowSize, \
m_scaledCover.height() + shadowSize ); + shadow.save( folder + file, \
"PNG" ); + }
+
+ QPixmap target;
+ target.convertFromImage( shadow ); //FIXME slow
+ copyBlt( &target, 0, 0, &m_scaledCover );
+ m_scaledCover = target;
+ r.setTop( (size.height() - m_scaledCover.height()) / 2 );
+ r.setSize( m_scaledCover.size() );
}
+ p.drawPixmap( r.topLeft(), m_scaledCover );
+
rect.rLeft() += m_scaledCover.width() + M;
}
@@ -311,8 +338,6 @@
}
-
-
////// OSDPreviewWidget below /////////////////////
#include <kcursor.h>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic