Hi, Daniel Egger <egger@xxxxxxx> writes: > Am 04 Sep 2001 15:51:34 +0200 schrieb Sven Neumann: > > > you certainly can process several 8 bit channels in one operation without > > special support from the processor and I would like to contribute such > > code to The GIMP > > Uii, now I'm curious. If you group an RGBA pixel together in a word and > want to add another one what would the code look like so it does proper > saturation instead of smearing between the channels? you need to do some masking and shifting. Well, you asked for it, here's the code we use in DirectFB to blend 'color' with opacity 'a' to destination pixel 'd' (RGB32). This code handles the red and blue channels in one multiplication. The operation you asked for could be handled in a similar fashion with two multiplications instead of four. Of course such optimizations need to be properly benchmarked to see if they make sense. __u32 __rb = (((color.r)<<16) | (color.b)); __u32 __g = ((color.g)<<8); switch (a) {\ case 0xff: *(d) = (0xff000000 | __rb | __g); \ case 0: break; \ default: {\ __u32 pixel = *(d);\ __u16 s = (a)+1;\ register __u32 t1,t2; \ t1 = (pixel&0x00ff00ff); t2 = (pixel&0x0000ff00); \ pixel = ((((__rb-t1)*s+(t1<<8)) & 0xff00ff00) + \ ((( __g-t2)*s+(t2<<8)) & 0x00ff0000)) >> 8; \ *(d) = pixel;\ }\ } if you think this looks ugly, you should have a look at the same function for RGB16 and RGB15 ;-) Salut, Sven