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

Re: [pygame] Surfaces with Transparent Backgrounds



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