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

Re: [pygame] [BUG] SRCALPHA - unexpected behaviour.



Actually in this case the surface depth should be a required argument. The surface depth is not guaranteed to be 32 bits. My display is set at 24 bits, and so that is the default depth for any new surface on my machine. If you want per-pixel alpha then is must be explicitly specified.


René Dudfield wrote:
After a chat on irc today, this unexpected behaviour popped up again.
It's bit me a few times, as well as people in irc.


import pygame
surf = pygame.Surface((100, 100), pygame.SRCALPHA)
flags = surf.get_flags()
depth = surf.get_bitsize()
assert(depth == 32)
assert(flags & pygame.SRCALPHA == pygame.SRCALPHA)

You would expect that surface to have the SRCALPHA flag if the surface
was 32bit right?

It doesn't at the moment.  But is there a good reason why it does not?

I can understand that if the surface returned was 16bit, or 8bit that
the SRCALPHA flag is not set.  However if it's 32bit, then I think it
probably should be set.

What do you think?  Is there something we're missing?

Can you see something breaking if I change this?  So that if SRCALPHA
is specified, and the bitsize is 32, then use the SRCALPHA flag.  If
someone specifies the SRCALPHA flag I think they expect it to be used
- especially if the surface is 32 bit anyway.