bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Alpha compositing in gnustep-back


From: Jeff Teunissen
Subject: Re: Alpha compositing in gnustep-back
Date: Sun, 14 Jul 2002 03:33:40 -0400

Adam Fedor wrote:

> Thanks. I added this.
> 
> Jeff Teunissen wrote:
> > XGBitmap's _pixmap_combine_alpha() and _bitmap_combine_alpha()
> > functions don't quite work right. Specifically, the colors are all
> > wrong.
> >
> > For some reason, the colors seem to be scaled by the value of alpha
> > (127/127/127/127 becomes 63/63/63/127 somewhere). In my spare time,
> > I've been working on them to make them generate correct output.
> 
> Well, colors are supposed to be scaled by alpha. Thats how alpha works.

Actually, changing the alpha on a pixel should never change the values of
that pixel's component colors -- only how they are drawn. Alpha is solely
a measure of opacity, not of color value.

For example, compositing a white pixel onto a white background (regardless
of alpha) should always result in a white pixel. If the source pixels are
scaled by alpha, then the lower alpha is (to an extent -- as alpha
approaches 1/3, the pixel begins to grow lighter), the darker the result
will be.

Final output should combine the original source pixel values with the
destination, according to alpha and the fraction of the source/dest pixels
that contribute to the result -- dependant on composition algorithm, of
course.

> But perhaps when you combine two colors together they need to be
> unscaled.

It's the combining that should change what the colors are. Until that
point, colors ought to be invariant.

> > As part of trying to understand the functions, I partially rewrote the
> > fast paths for them. The code is shorter, but it may be slower since
> > the math is done in floating point.
> 
> It's about 10% slower in my tests. But that may not be accurate.

The salient change can be applied to the original code, with some small
changes. My rewrite of that particular code was so that I could easily
show correctness.

-- 
| Jeff Teunissen  -=-  Pres., Dusk To Dawn Computing  -=-  deek @ d2dc.net
| GPG: 1024D/9840105A   7102 808A 7733 C2F3 097B  161B 9222 DAB8 9840 105A
| Core developer, The QuakeForge Project        http://www.quakeforge.net/
| Specializing in Debian GNU/Linux              http://www.d2dc.net/~deek/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]