Ugh... Qt4 porting

Ingo Klöcker kloecker at
Mon May 16 16:00:28 BST 2005

On Monday 16 May 2005 15:06, Lars Knoll wrote:
> On Monday 16 May 2005 14:55, Mosfet wrote:
> > >Lars wrote:
> > >> I'm also curious about what they are going to do with the new
> > >> Premultiplied format. As far as I can tell it's a 32bpp format
> > >> with the source part of the alpha already calculated. Good if
> > >> your going to alphablend the image a lot, bad if you want to
> > >> modify the original color channels.
> > >
> > >The image paint engine uses it. All drawing operations are a lot
> > > faster when using premultiplied alpha. It's also the format used
> > > by RENDER, so it matches fine there as well.
> > >
> > >And I don't see why you shouldn't be able to modify the color
> > > channels in a premultiplied image more or less the same way then
> > > in a non premultiplied one.
> >
> > Because a pixel's RGB values aren't the actual RGB values, they are
> > averaged with the alpha value. So if your doing something like
> > interpolating a color you'd be interpolating with the wrong color,
> > no?
> As long as you don't take the premulitplication into account, yes.
> But it's trivial to do it right.
> > Even
> > simple things like the gray level would be wrong. A red value of 25
> > may actually be 100 but with 1/4th the opacity. Most effects won't
> > work properly with this.
> The math behind is trivial: Instead of the value being R directly,
> it's A*R. As long as you know it's premultiplied it should be trivial
> to adjust your code to do the same effect.

The problem is that the precision of the premultiplied values is less 
than the precision of the non-premultiplied values due to integer 
arithmetic being used. In general
  ( A*R ) / A != R
So you can't recover the original values from the premultiplied values. 
Now if you do several iterations of this then the precision loss might 
increase dramatically 
And this is far from being trivial math.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <>

More information about the kde-core-devel mailing list