Alpha Blending for KDE?

From Rik Hemsley: "I hacked KIconLoader to allow me to get a QImage instead of a QPixmap, which was quite easy, because it uses QImage internally and only converts to QPixmap just before returning a processed pic. I also wrote a very fast blend function that takes 2 QImages and blends the first over the second, honouring the alpha channel. I couldn't find anything in Qt or KDE to do this, so I had to hand-roll it. In tests on my Celeron 600 it can blend 65 million pixels (about 1/2 of which have alpha != 0) in 5 seconds. That's about 5ms for a 256x256 image, so approximately 0.17ms for our largest icons (48x48). [...] Anyway, enough talk. I'm tired and I'm sure a screenshot is in order. ;) Apologies for the hideous background tile, but I needed something to illustrate the point." Good stuff for KDE 2.1.

Dot Categories: 

Comments

by tweaker (not verified)

That looks really cool. The KDE 1.X series wasn't very visually attractive. KDE 2 is so much better and keeps getting better all the time. Totally awsome stuff, developers keep it up.

by Evan "JabberWok... (not verified)

ftp://ftp.kde.org/pub/kde/Incoming/gnome.png

Is this supposed to illustrate something? I can't see any Alpha blending in this screenshot anywhere; certainly not in the wharf/menu area.

Am I just missing the point?

--
Evan

by David (not verified)

Look left in the folder icon, and above in the K of the KDE-icon. It is certainly blending, my friend.

by ac (not verified)

Doubtful. Only mentioned to illustrate how far and flexible KDE has come.

by Evan "JabberWok... (not verified)

Look left in the folder icon, and above in the K of the KDE-icon. It is certainly blending, my friend.

In the original one listed in the article, yes. However, if you look at my message, I was talking about the one that was posted here: ftp://ftp.kde.org/pub/kde/Incoming/gnome.png. The K menu does not look at all like it is blending, and the shadow on the KWrite icon is black and harshly aliased.

--
Evan

by Aubanel (not verified)

You could look in the background, maybe

by dingodonkey (not verified)

Very nice... its neat little stuff like that that puts KDE on top. KDE 2.0 is visually looking very, very impressive. At this rate, you can put MS to shame (if you haven't already) by 2.1 or 2.2. Any chance in this making it into 2.0, or is it definitely waiting till 2.1? It would be a nice last minute addition if you ask me....

by Richard Moore (not verified)

It's way too late for 2.0. In addition as the mail says it needs the icons to use the alpha channel in order for it to be useful.

Rich.

by dingodonkey (not verified)

there was always hopin' :)

Regardless, 2.0 is lookin good.

by Tackat (not verified)

> In addition as the mail says it needs the icons to use the alpha channel in order for it to be useful.

They already support the alpha-channel.

Tackat

by Peter Duus (not verified)

How about making the background of Kicker transparent, showing the desktop background?

by David (not verified)

How about using it in konsole!!?

by dingodonkey (not verified)

hmm.... i love that idea

being able to select a pic to use (and adjustable transparency would be GREAT) as the background on the konsole would be good.... or even just transparent flat dull colors

who knows

by Andreas Joseph Krogh (not verified)

Maybe TrollTech should incorporate this into QT?

Maybe I'm stupid(I have no experience with graphical programming), but what makes it "impossible" to implement alpha-channel support in the X11-version of QT when you can do stuff like Rik(and Rasterman) did anyway? I know X doesn't have an alpha-channel, but how is alpha-in-icons possible then? Think of it - if we could have transparent windows(at least those made with QT) that would be very cool:-)
If someone could explain this, I would be - Enlightened:-)

--
Andreas

by Matt Newell (not verified)

X11 gives you access to your window of memory for your application, which is an RGB surface(sometimes greyscale or palletized). You can put whatever colors you want in that window, but there is *NO* support for alpha transparency. However, if you blend two pictures(icons or whatever) and then put it in the window that is just fine. That is what he has done. Since X11 doesn't give you alpha transparency in the actual window, you cant make a see through window(Right now you are saying that I am full of crap because Eterm does). Some programs use a hack to do this by getting the actual background image(I'm not sure how they go about this), and blend it with their window contents which make their window look transparent.

I am not much of an X programmer so whatever I said here take with a grain of salt.

by jliechty (not verified)

IIRC, Konsole can do the transparent background thing too, but one can tell that it isn't real transparency; try moving the Konsole so that it partially overlaps another window. The other window won't show through (at least it didn't the last time I had the transparency turned on).

by Steven Brown (not verified)

The reason it isn't currently possible (without hacking on the X server) is because of the fundamental way windowing systems work. When a window is obscured, the window that is obscured doesn't get asked to repaint its contents. This saves a huge amount of time as you are only drawing what is required. The problem with alpha blending is that the X server would have to understand that if the obscuring window was using alpha blending that the obscured windows should be sent repaint events anyway. There are a lot of design assumptions in X about obscured windows like in this example. Getting true alpha blending to work is not a problem at the Qt/KDE level in other words, it needs to be addressed at the X server level to be done correctly and efficiently. It would make for an interesting project. :)

by MichaelM (not verified)

I think the term 'sexy' springs to mind. Too bad it won't make it into the release =(

by N8 (not verified)

Ok this post is a little off topic but... Ok, its practically impossible to buy a PC graphics card these days 'without' bit-bliting alpha blending etc. So much of KDE/Qt could be made to fly if there was a good was to hit the hardware. 3D is a superset of 2D, OpenGL is a mature HW accelerated standard with all the functionality a 2D GUI could ever need + more. Hardware cards can accelerate even things like blended bitmap scaling. Just the straight forward X approach seems non-sensical these days. I dont know what the best engineering answer is and I not bashing X, just this standard is showing its age now. I realise you guys are working within the limitations of X and doing a very good job. Sorry thats my little rant over and i'm sure its all been said before.

by reihal (not verified)

I guess embedded Qt will make this possible. Using the frame buffer without X. Am I right?

by Kevin Puetz (not verified)

X is getting an alpha channel too... the RENDER extension. Debian is including it in their builds of X4, presumably it will go in wholesale soon.

by Andreas Erhart (not verified)

a little bit off topic but ...

A very interesting project for a future X replacement is berlin.

it's far from being usable though and there is no QT for it: -(

by AC (not verified)

http://www.xfree86.org/~keithp/render/

It's coming for X as well.. :)

by AC (not verified)

Can that be accelerated by an OpenGL/GLX backend ?

by Kevin Puetz (not verified)

no.

it is(or at least can be) accelerated in hardware, but in my understanding of how it works, OpenGL is entirely unsuitable because it doesn't guarentee you an exact rendering.

by Robert Thompson (not verified)

I'm sure you've all seen screenshots (or had the pleasure to use) of Mac OS X. It still has a lot of work to go, but if there's any one word that describes it, that's "beautiful." One of the major reasons for this is the way everything is alpha-blended, transparent, etc, etc. Thanks to this idea, now KDE2 can leap beyond other X Window System apps, and approach this new ideal. Excellent!

By the way, I ported Qt-2.2.0 to Darwin, but KDE still won't compile. I guess Stan Shebs (Apple's compiler guy) still hasn't fixed that C++ bug... oh well