From ffff5455b4559c9018e5db42b872f0a32e727b33 Mon Sep 17 00:00:00 2001 From: Ryan Cumming Date: Thu, 4 Jul 2002 02:43:54 +0000 Subject: [PATCH] Dither the titlebar graident on 15 and 16bpp displays. Thanks to gallium for the Qt::OrderedDither tip. svn path=/trunk/kdebase/kwin/; revision=164671 --- clients/redmond/redmond.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/clients/redmond/redmond.cpp b/clients/redmond/redmond.cpp index 5f92068ada..831ea9e073 100644 --- a/clients/redmond/redmond.cpp +++ b/clients/redmond/redmond.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -591,8 +592,20 @@ void GalliumClient::paintEvent( QPaintEvent* ) KPixmap* titleBuffer = new KPixmap; titleBuffer->resize(w-8, titleHeight); - KPixmapEffect::gradient(*titleBuffer, c1, c2, - KPixmapEffect::HorizontalGradient); + if (titleBuffer->depth() > 16) + { + KPixmapEffect::gradient(*titleBuffer, c1, c2, + KPixmapEffect::HorizontalGradient); + } + else + { + // This enables dithering on 15 and 16bit displays, preventing + // some pretty horrible banding effects + QImage image = KImageEffect::gradient(titleBuffer->size(), c1, c2, + KImageEffect::HorizontalGradient); + + titleBuffer->convertFromImage(image, Qt::OrderedDither); + } QPainter p2( titleBuffer, this );