Re: [pygame] Surfaces with Transparent Backgrounds

2009-08-21 Thread Rolf Sievers
Hi, I don't know Pygame that well and have never used subsurfaces but it it looks kinda interesting. Would you do the subsurface approach in the following way? def load_strip(filename, width): imgs = [] img = load_image(filename) for x in range(img.get_width()/width): i =

[pygame] Surfaces with Transparent Backgrounds

2009-08-20 Thread pymike
Hi, I have a function that loads image stripshttp://pymike.pynguins.com/downloads/player-run.pngand returns the images in lists. To do this, I create new surfaces and blit the strips to them at an offset. My question is: Is there a way to create surfaces with transparent backgrounds? The images

Re: [pygame] Surfaces with Transparent Backgrounds

2009-08-20 Thread Henrique Nakashima
Transparency is often a problem because image editors and viewers not always display the same sorts of transparency. To create a transparent background, load it from an image with transparency. Png supports it, but not all png editors do. I managed to get transparency done by using GIMP

Re: [pygame] Surfaces with Transparent Backgrounds

2009-08-20 Thread pymike
I *did* create the images with Gimp, and they do have transparent backgrounds. (Did you view the image link I posted?) I have used colorkeys in the past, but the problem here is that there are semi-transparent (not fully opaque) pixels in the images (again see the image I linked to), and when you

Re: [pygame] Surfaces with Transparent Backgrounds

2009-08-20 Thread Ian Mallett
You need to convert the surface i with .convert_alpha(), as well.

Re: [pygame] Surfaces with Transparent Backgrounds

2009-08-20 Thread pymike
On Thu, Aug 20, 2009 at 10:15 PM, Ian Mallett geometr...@gmail.com wrote: You need to convert the surface i with .convert_alpha(), as well. i = pygame.Surface((width, img.get_height())).convert_alpha() ...I still get a black background. -- - pymike

Re: [pygame] Surfaces with Transparent Backgrounds

2009-08-20 Thread pymike
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,

Re: [pygame] Surfaces with Transparent Backgrounds

2009-08-20 Thread Henrique Nakashima
Aha. There might be something weird about the image as well, because when I used another one with a transparent background it worked as well - without modifications to the code. Despite that, I couldn't find anything strange in the png. On Fri, Aug 21, 2009 at 00:23, pymike pymik...@gmail.com

Re: [pygame] Surfaces with Transparent Backgrounds

2009-08-20 Thread Lenard Lindstrom
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.