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

Re: [pygame] Per Pixel Alpha



Alright, I didn't realize things had changed with Pygame 1.8. Checking the 1.8 source I see that the video depth is used if no depth is provided. If Pygame is uninitialized the depth defaults to 32. For a SRCALPHA surface a ValueError is raised if the depth isn't 16 or 32. What I have noticed is that omitting depth for a SRCAPLHA surface is common practice. It must work on most machines. But it is problematic with 1.8 when one's video depth is 24.

Lenard

Brian Fisher wrote:
For whoever is curious, the bug in 1.7 that is avoided by specifying the bit-depth doesn't necessarily have anything to do with what the bit depth is - Ian's posted sample was using a 32-bit surface on my machine. The problem was that the flags you passed were simply ignored when bit depth wasn't specified. I think there was another seperate problem that if you specifically requested 24-bit and SRCALPHA you wouldn't get alpha-blending either.

I think 1.8 changes things so that the flags are no longer ignored when using a default bit-depth solving the first issue - also I think it throws an exception if SRCALPHA is requested for a 24-bit (whether explicitly asked for or not) thereby addressing the second issue.

On Feb 8, 2008 10:45 AM, Lenard Lindstrom <len-l@xxxxxxxxx <mailto:len-l@xxxxxxxxx>> wrote:

    It is a commonly held misconception that any surface created with a
    SRCALPHA automatically has 32 bit pixels. This is wrong. The
    pixels size
    defaults to that of the display. To ensure per-pixel alpha always
    provide the pixel size argument. I have had to patch several packages
    because of this oversight.

    --
    Lenard Lindstrom
    <len-l@xxxxxxxxx <mailto:len-l@xxxxxxxxx>>




--
Lenard Lindstrom
<len-l@xxxxxxxxx>