[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

PATCH BUG: Re: [pygame] alpha blend bug



Thanks!

It's applied in cvs.  I've also added a tests/blit_test.py which tests
some of the blits.
Also... in cvs are some new blitting modes.  add/sub/mult/min/max


On 4/25/06, Lenard Lindstrom <len-l@xxxxxxxxx> wrote:
> Hello everyone. First I would like to say that pygame is one of the
> best integrated Python packages I've seen so far; very slick. Anyway,
> down to business.
>
> While blitting from a surface with per-pixel alpha to a surface also
> with per-pixel alpha I found a bug when source alpha is 255. Each
> calculated color value is one less than that of the source. I have
> attached a program that illustrates the problem.
>
> I have also included a patch for alphablit.c in CVS which hopefully
> solves the problem. The C expression used is based on the formula:
>
> blend(s, sA, d) = ( (256 - sA)*d + (sA + 1)*s) / 256
>
> I have checked the expression to confirm the following:
>
> blend(s, 0, d) = d
> blend(s, 255, d) = s
> blend(0, sA, 0) = 0
> blend(255, sA, 255) = 255
> blend(s, sA, d) <= 255
>
> I am using pygame 1.7.1 with both Python 2.3 and 2.4 on Windows.
>
> Lenard Lindstrom
> <len-l@xxxxxxxxx>
>
>
>
> The following section of this message contains a file attachment
> prepared for transmission using the Internet MIME message format.
> If you are using Pegasus Mail, or any other MIME-compliant system,
> you should be able to save it or view it from within your mailer.
> If you cannot, please ask your system administrator for assistance.
>
>    ---- File information -----------
>      File:  blit.py
>      Date:  23 Apr 2006, 21:03
>      Size:  1056 bytes.
>      Type:  Text
>
>
> The following section of this message contains a file attachment
> prepared for transmission using the Internet MIME message format.
> If you are using Pegasus Mail, or any other MIME-compliant system,
> you should be able to save it or view it from within your mailer.
> If you cannot, please ask your system administrator for assistance.
>
>    ---- File information -----------
>      File:  alphablend.patch
>      Date:  24 Apr 2006, 16:37
>      Size:  885 bytes.
>      Type:  Text
>
>
>
>