[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Alpha blending
From:       Rik Hemsley <rik () kde ! org>
Date:       2000-10-02 3:08:33
[Download RAW message or body]

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).

Fast functions aside, of course this would be configurable and probably off
by default. I asked someone to try my function on a K6/233 and the speed
goes from ~0.17ms to ~1ms, which is clearly not going to be fast enough
for even slower machines (thanks to that person on IRC !)

Now, my implementation could be improved somewhat. I had a chat with Dirk
and it seems likely we can use KPixmap in some way - it seems to have access
to the XImage held by QPixmap. I'm not clear on how we would do this yet,
but I'm sure I'll figure it out.

Using blending for e.g. toolbar icons would actually be comparatively easy
and source compatible, assuming that developers use KAction when writing
their apps (KAction takes a string as a parameter for the icon - you don't
mess about with QPixmaps IIRC.)

Anyway, enough talk. I'm tired and I'm sure a screenshot is in order ;)

http://www.geoid.clara.net/kicker_alpha_test.png

Apologies for the hideous background tile, but I needed something to
illustrate the point.

Rik - wondering if tackat will a) kill me when I suggest we make new versions
of all hicolour icons to support transparency or b) be so happy that this is
possible that the amount of work is somehow irrelevant ;)

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic