[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Surfaces with Transparent Backgrounds
Lenard: his problems was that he was blitting that per-pixel alpha
surface onto a newly created surface which also had to be per-pixel
alpha, and wasn't sure how to create that. But he figured it out :)
Pymike, that's one way to do it, another way would be to use
subsurfaces. They are a bit nicer because you don't have to go
through the hassle of making a separate surface for each frame. I
think they might take less memory as well.
On Thu, Aug 20, 2009 at 8:47 PM, Lenard Lindstrom<len-l@xxxxxxxxx> wrote:
> Hi pymike,
>
> I don't understand what you are doing here. If you load an image with
> per-pixel alpha, the returned surface will also have per-pixel alpha. All
> convert_alpha() may do here is improve performance by formating the surface
> to match the display. Of course this is with Pygame 1.9.1. Earlier Pygames
> may have a problem with 32bit to 32bit surface blits.
>
> Lenard Lindstrom
>
> pymike wrote:
>>
>> Aha! Figured it out!
>>
>> def load_strip(filename, width):
>> imgs = []
>> img = load_image(filename)
>> for x in range(img.get_width()/width):
>> * i = pygame.Surface((width, img.get_height())).convert_alpha()
>> i = i.convert_alpha()
>> i.fill((255,255,255,0))*
>> i.blit(img, (-x*width, 0))
>> imgs.append(i)
>> return imgs
>>
>> Everything's working awesome now.
>>
>> --
>> - pymike
>
>