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

Re: [pygame] Per Pixel Alpha



Like I said in my previous email, If you try that code again with latest, it won't throw the exception but will give you a 32-bit surface.

On Feb 9, 2008 10:52 AM, Lenard Lindstrom <len-l@xxxxxxxxx> wrote:
Brian Fisher wrote:
> On Feb 8, 2008 8:20 PM, Lenard Lindstrom <len-l@xxxxxxxxx
> <mailto:len-l@xxxxxxxxx>> wrote:
>
>     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.
>
> I think you're right. svn pygame now gives you a 32-bit surface if the
> video depth is 24, you asked for SRCALPHA and didn't specify a
> bitdepth. It still throws an exception if people explicitly ask for a
> 24-bit surface with SRCALPHA though.
For SRCALPHA Pygame 1.8 uses the video depth if present and raises an
error if the depth is not 16 or 32. So, for 1.8, always provide a depth
when creating a SRCALPHA surface. The following was done on Windows,
where video information is available before display.set_mode() is called.

 >>> from pygame import *
 >>> init()
(6, 0)
 >>> version.ver
'1.8.0rc3'
 >>> Surface((10,10), SRCALPHA)
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
ValueError: no standard masks exist for given bitdepth with alpha
 >>> display.Info().bitsize
24
 >>> screen = display.set_mode((100, 50))
 >>> display.Info().bitsize
24
 >>> Surface((10,10),SRCALPHA)
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
ValueError: no standard masks exist for given bitdepth with alpha
 >>> Surface((10,10),SRCALPHA,32)
<Surface(10x10x32 SW)>

--
Lenard Lindstrom
<len-l@xxxxxxxxx>