Ugh... Qt4 porting
lars at trolltech.com
Mon May 16 14:06:59 BST 2005
On Monday 16 May 2005 14:55, Mosfet wrote:
> Hi Lars! You guys really need to start CCing me. I'm not on the list so am
> cutting and pasting responses from the mailing list archive ;-)
How am I supposed to know?
> >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.
> 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.
> >> Right now I just return if I get one of these.
> >QImage has a convertToFormat() method you could use: Convert to a format
> > you can handle, and convert back at the end. Not fast, but maybe better
> > than just not doing anything.
> We promote images to 32bpp when we have to but generally do not do things
> that require a lot of conversion, for example we don't do effects on 1bpp
> images by promoting them. I guess it would depend on how often it is used.
> Doing so will kill performance, and in such cases the approach has been
> that it's better to warn the developer.
I guess that's up to the guy implementing the stuff.
Anyway, the only formats that will matter for image effects in the long run
are ARGB and ARGB_premultiplied. Premultiplied is as I said a great format,
as all compositing operations (ie. also all painting) are a factor of 4
More information about the kde-core-devel