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

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



ah, I fixed those segfaults in svn.  There were problems with
get_bytesize, and get_alpha too.

I'm not sure why using a bitdepth of 24 doesn't work without
initializing pygame...  So that can still be considered a bug that
needs investigation.


On 8/20/07, Lenard Lindstrom <len-l@xxxxxxxxx> wrote:
> René Dudfield wrote:
> > Thanks Brian.
> >
> > I think there is one issue with raising an error though.  The flags
> > are just 'hints' and not all installations support each flag.
> >
>
> Pygame does the alpha to alpha software surface blits. From what I can
> tell SDL code takes care of other software blits. How SDL deals with
> blits to hardware I did not find out. So only alpha blits to hardware
> would be questionable.
>
> > SRCALPHA is only supported on 32 bit surfaces (I think).
> I thought SRCALPHA was necessary to make surface alpha and colorkey to
> work. But while testing that assumption I found this:
>
>  >python
> Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
> (Intel)] on
> win32
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> import pygame
>  >>> print pygame.__version__
> 1.8.0rc3
>  >>> s = pygame.Surface((100, 100), pygame.SRCALPHA, 24)
>  >>> s.fill((255, 0, 0))
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> pygame.error: display Surface quit
>  >>> s.get_bitsize()
> Fatal Python error: (pygame parachute) Segmentation Fault
>
> This application has requested the Runtime to terminate it in an unusual
> way.
> Please contact the application's support team for more information.
>
> C:\user\projects\Python25
>  >
>
> This also happens after pygame.init() is called. Curiously, if I
> initialize pygame first and let the surface default to 24 bits, my
> display setting, pygame.SRCALPHA is ignored:
>
>  >>> import pygame
>  >>> pygame.init()
> (6, 0)
>  >>> s = pygame.Surface((100, 100), pygame.SRCALPHA)
>  >>> s.get_flags()
> 0
>  >>> s.get_bitsize()
> 24
>  >>> s.fill((255, 0, 0))
> <rect(0, 0, 100, 100)>
>  >>>
>
> And I found that colorkey and surface alpha do work without SRCALPHA.
>
> >  So if the
> > underlying video subsystem decides that it should return 16 bit
> > surfaces (for example), then the SRCALPHA flag should correctly have
> > no effect.
> >
> >
> > On 8/20/07, Brian Fisher <brian@xxxxxxxxxxxxxxxxxxx> wrote:
> >
> >> Being able to have this succeed without error:
> >>    surf = pygame.Surface((100, 100), pygame.SRCALPHA)
> >> and get a surface that doesn't have SRCALPHA set seems like a clear
> >> and obvious bug to me. I'd say the best fix would be to always use
> >> SRCALPHA if requested, and raise an error if the request couldn't be
> >> satisfied. attached is a patch to svn pyame that seems to do that (it
> >> passes the test in svn for this, anyways)
> >>
> >> ------
> >>
> >> ... However I'm also seeing that this:
> >>    surf = pygame.Surface((100, 100), flags=pygame.SRCALPHA, depth=32)
> >> is returning a surface without alpha set. So it seems like the Surface
> >> constructor doesn't support keyword arguments at all.
> >>
> >> I've tested python 2.3 on windows, pygame 1.7 and svn pygame. I've
> >> also tried python 2.5 on macOSX, pygame 1.7
> >>
> >> I have no idea how to fix this, but I've attached a patch to the surface test
> >>
> >>
> >>
>
>
> --
> Lenard Lindstrom
> <len-l@xxxxxxxxx>
>
>