[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pygame] Image alpha control?



I'm trying to do some alpha-based image manipulations. The initial image is a 
font.render()'ed text surface, and it's easy to deal with, because I just use 
set_alpha(255) on it and I can blit it to my window surface and the black 
doesn't blot out existing imagery. If I flip(), it's ok too. If I 
subsurface(), all's fine. But if I try to create a new surface with the same 
properties as the text surface, I have no luck. Sorry, but I just can't seem 
to fathom the correct set of arguments to the Surface constructor. A "dump" 
of information from the text surface gives:

>>> level = 212
>>> surf = font.render(message, 0, (level, level, level)).convert(32)
>>> print 'surf bit', surf.get_bitsize()
surf bit 32
>>> print 'surf alp', surf.get_alpha()
surf alp None
>>> print 'surf flg', surf.get_flags()
surf flg 4096
>>> print 'surf cky', surf.get_colorkey()
surf cky (43, 43, 43, 255)

First up, what's with that flag? The only matching values I can find in the 
locals are:

>>> import pygame.locals
>>> for key in pygame.locals.__dict__.keys():
...  if pygame.locals.__dict__[key] == 4096:
...   print key
... 
KMOD_NUM
SRCCOLORKEY

???

Anyway, so I try to emulate this, but I fail (src here is the same as surf 
above):

>>> dst = pygame.surface.Surface(newsize, SRCCOLORKEY, src)
>>> print 'src bit', src.get_bitsize()
dst bit 32
>>> print 'src alp', src.get_alpha()
dst alp None
>>> print 'src flg', src.get_flags()
dst flg 0
>>> print 'src cky', src.get_colorkey()
dst cky None

and, needless to say, the final blit to the window surface results in large 
gobs of black being blitted on, which I don't want...


   Richard, who is probably on the completely wrong track...
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org