Diffstat (limited to 'noncore/multimedia/opieplayer2/skin.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/skin.cpp | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/noncore/multimedia/opieplayer2/skin.cpp b/noncore/multimedia/opieplayer2/skin.cpp index 7d05d80..ef70957 100644 --- a/noncore/multimedia/opieplayer2/skin.cpp +++ b/noncore/multimedia/opieplayer2/skin.cpp | |||
@@ -11,3 +11,3 @@ Skin::Skin( const QString &name, const QString &fileNameInfix ) | |||
11 | 11 | ||
12 | void Skin::preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) | 12 | void Skin::preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount, const QSize &buttonAreaSize ) |
13 | { | 13 | { |
@@ -16,4 +16,3 @@ void Skin::preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint butt | |||
16 | buttonDownImage(); | 16 | buttonDownImage(); |
17 | for ( uint i = 0; i < buttonCount; ++i ) | 17 | ( void )buttonMask( skinButtonInfo, buttonCount, buttonAreaSize ); |
18 | ( void )buttonMaskImage( skinButtonInfo[ i ].fileName ); | ||
19 | } | 18 | } |
@@ -41,2 +40,33 @@ QImage Skin::buttonDownImage() const | |||
41 | 40 | ||
41 | QImage Skin::buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount, const QSize &buttonAreaSize ) const | ||
42 | { | ||
43 | if ( buttonAreaSize != m_buttonMask.size() ) | ||
44 | m_buttonMask = QImage(); | ||
45 | |||
46 | if ( !m_buttonMask.isNull() ) | ||
47 | return m_buttonMask; | ||
48 | |||
49 | m_buttonMask = QImage( buttonAreaSize, 8, 255 ); | ||
50 | m_buttonMask.fill( 0 ); | ||
51 | |||
52 | for ( uint i = 0; i < buttonCount; ++i ) | ||
53 | addButtonToMask( skinButtonInfo[ i ].command + 1, buttonMaskImage( skinButtonInfo[ i ].fileName ) ); | ||
54 | |||
55 | return m_buttonMask; | ||
56 | } | ||
57 | |||
58 | void Skin::addButtonToMask( int tag, const QImage &maskImage ) const | ||
59 | { | ||
60 | if ( maskImage.isNull() ) | ||
61 | return; | ||
62 | |||
63 | uchar **dest = m_buttonMask.jumpTable(); | ||
64 | for ( int y = 0; y < m_buttonMask.height(); y++ ) { | ||
65 | uchar *line = dest[y]; | ||
66 | for ( int x = 0; x < m_buttonMask.width(); x++ ) | ||
67 | if ( !qRed( maskImage.pixel( x, y ) ) ) | ||
68 | line[x] = tag; | ||
69 | } | ||
70 | } | ||
71 | |||
42 | QImage Skin::buttonMaskImage( const QString &fileName ) const | 72 | QImage Skin::buttonMaskImage( const QString &fileName ) const |