summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-08-28 21:51:54 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-08-28 21:51:54 +0000
commit5a9856e1a30e71d1b457e386a7bfb3f8fdbce51c (patch)
tree787e37bcd8800856419728793fee69940d2f013e
parent3f6123639423caade4d83c6d4d75b109447952a1 (diff)
downloadamarok-5a9856e1a30e71d1b457e386a7bfb3f8fdbce51c.tar.gz
amarok-5a9856e1a30e71d1b457e386a7bfb3f8fdbce51c.zip
Enhance Amarok OSD in ARGB mode
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/amarok@1249948 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
-rw-r--r--amarok/src/osd.cpp45
1 files changed, 36 insertions, 9 deletions
diff --git a/amarok/src/osd.cpp b/amarok/src/osd.cpp
index a9c2f517..a76ddf15 100644
--- a/amarok/src/osd.cpp
+++ b/amarok/src/osd.cpp
@@ -36,6 +36,9 @@
#include <tqtimer.h>
#include <tqvaluevector.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
namespace ShadowEngine
{
TQImage makeShadow( const TQPixmap &textPixmap, const TQColor &bgColor );
@@ -314,6 +317,16 @@ OSDWidget::render( const uint M, const TQSize &size )
KPixmapEffect::fade( background, 0.80, backgroundColor() );
p.drawPixmap( 0, 0, background );
}
+ else if (( m_translucency ) && (kapp->isX11CompositionAvailable()))
+ {
+ // Make the background semi-transparent
+ TQPixmap background( m_screenshot.width(), m_screenshot.height(), 32 );
+ TQRgb blend_color = tqRgba(backgroundColor().red(), backgroundColor().green(), backgroundColor().blue(), 204); // RGBA
+ float alpha = tqAlpha(blend_color) / 255.0;
+ int pixel = tqAlpha(blend_color) << 24 | int(tqRed(blend_color) * alpha) << 16 | int(tqGreen(blend_color) * alpha) << 8 | int(tqBlue(blend_color) * alpha);
+ background.fill(TQColor(blend_color, pixel));
+ bitBlt( &m_buffer, 0, 0, &background );
+ }
else
p.fillRect( rect, backgroundColor() );
@@ -392,6 +405,16 @@ OSDWidget::render( const uint M, const TQSize &size )
KPixmapEffect::fade( background, 0.80, backgroundColor() );
bitBlt( &vol, -r.left(), -r.top(), &background );
}
+ else if (( m_translucency ) && (kapp->isX11CompositionAvailable()))
+ {
+ // Make the background semi-transparent
+ TQPixmap background( m_screenshot.width(), m_screenshot.height(), 32 );
+ TQRgb blend_color = tqRgba(backgroundColor().red(), backgroundColor().green(), backgroundColor().blue(), 204); // RGBA
+ float alpha = tqAlpha(blend_color) / 255.0;
+ int pixel = tqAlpha(blend_color) << 24 | int(tqRed(blend_color) * alpha) << 16 | int(tqGreen(blend_color) * alpha) << 8 | int(tqBlue(blend_color) * alpha);
+ background.fill(TQColor(blend_color, pixel));
+ bitBlt( &vol, -r.left(), -r.top(), &background );
+ }
else
vol.fill( backgroundColor() );
@@ -496,23 +519,27 @@ OSDWidget::paintMe()
blendedImage = blendedImage.convertDepth(32);
blendedImage.setAlphaBuffer(true);
+ // Convert the ARGB pixmap to an ARGB image
+ // NOTE 1: TQPixmap::convertToImage() always converts an ARGB pixmap into an RGB image
+ // NOTE 2: This should eventually make its way into kdelibs or Qt itself,
+ // as it would also be useful in applications other than Amarok
int w = blendedImage.width();
int h = blendedImage.height();
-
+ Pixmap rawpixmap = m_buffer.handle();
+ XImage *image;
+ image = XGetImage (qt_xdisplay(), rawpixmap, 0, 0, w, h, AllPlanes, XYPixmap);
for (int y = 0; y < h; ++y) {
TQRgb *ls = (TQRgb *)blendedImage.scanLine( y );
for (int x = 0; x < w; ++x) {
- TQRgb l = ls[x];
- //int desired_alpha = 127;
- int desired_alpha = 204;
- float alpha_adjust = (desired_alpha/256.0);
- int r = int( tqRed( l ) * alpha_adjust );
- int g = int( tqGreen( l ) * alpha_adjust );
- int b = int( tqBlue( l ) * alpha_adjust );
- int a = int( desired_alpha );
+ unsigned int rawpixel = XGetPixel(image, x, y);
+ int r = int( (rawpixel & 0x00ff0000) >> 16 );
+ int g = int( (rawpixel & 0x0000ff00) >> 8 );
+ int b = int( (rawpixel & 0x000000ff) );
+ int a = int( (rawpixel & 0xff000000) >> 24 );
ls[x] = tqRgba( r, g, b, a );
}
}
+ XFree (image);
// Finally, paint it
TQPainter p1;