RE: [pygame] Alpha channels and per pixel alpha
Here's the image and code: def load_alpha_image(name): fullname = os.path.join('Images', name) try: image = pygame.image.load(fullname).convert_alpha() except pygame.error, message: print 'Cannot load image:', fullname raise SystemExit, message return image Date: Wed, 10 Jun 2009 15:56:10 -0700 Subject: Re: [pygame] Alpha channels and per pixel alpha From: br...@hamsterrepublic.com To: pygame-users@seul.org It would help to see your code and have an example image attached, cause loading .png's with alpha and blitting with transparency works fine for me without any trouble or special stuff. On Wed, Jun 10, 2009 at 2:11 PM, Bjorn Samuelsson bjorn_...@hotmail.com wrote: Hey all, I'm trying to make a small 2d game and I'm wondering how you would go about to load a png-image with an alpha channel and keep it's alpha values? I have confirmed the images alpha channel but when i load it in pygame it's alpha values are always 255. I've tried Surface.convert_alpha but that doesn't make a difference. At the moment I've resorted to saving my alpha channels separate and loading both image and alpha channel so that i can call Surface.set_at to change the image's per pixel alpha value. But that solution seems less than optimal so i figured i would ask you guys. regards Björn ps. I apologize if this topic has been discussed at length already but i've been looking around and i just can't seem to find a simple solution. ds. Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! Try it! _ Windows Live™: Keep your life in sync. Check it out! http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t1_allup_explore_012009attachment: default_alpha2.png
Re: [pygame] Alpha channels and per pixel alpha
works here import pygame import os def load_alpha_image(name): #fullname = os.path.join( 'Images', name) fullname = 'default_alpha2.png' try: image = pygame.image.load(fullname).convert_alpha() except pygame.error, message: print 'Cannot load image:', fullname raise SystemExit, message return image screen = pygame.display.set_mode((22,22,)) i = load_alpha_image('s') print i.get_at((0,0)) Results in (0,0,0,0) which is correct for the image given. What do you get? On Thu, Jun 11, 2009 at 4:39 PM, Bjorn Samuelssonbjorn_...@hotmail.com wrote: Here's the image and code: def load_alpha_image(name): fullname = os.path.join( 'Images', name) try: image = pygame.image.load(fullname).convert_alpha() except pygame.error, message: print 'Cannot load image:', fullname raise SystemExit, message return image Date: Wed, 10 Jun 2009 15:56:10 -0700 Subject: Re: [pygame] Alpha channels and per pixel alpha From: br...@hamsterrepublic.com To: pygame-users@seul.org It would help to see your code and have an example image attached, cause loading .png's with alpha and blitting with transparency works fine for me without any trouble or special stuff. On Wed, Jun 10, 2009 at 2:11 PM, Bjorn Samuelsson bjorn_...@hotmail.com wrote: Hey all, I'm trying to make a small 2d game and I'm wondering how you would go about to load a png-image with an alpha channel and keep it's alpha values? I have confirmed the images alpha channel but when i load it in pygame it's alpha values are always 255. I've tried Surface.convert_alpha but that doesn't make a difference. At the moment I've resorted to saving my alpha channels separate and loading both image and alpha channel so that i can call Surface.set_at to change the image's per pixel alpha value. But that solution seems less than optimal so i figured i would ask you guys. regards Björn ps. I apologize if this topic has been discussed at length already but i've been looking around and i just can't seem to find a simple solution. ds. Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! Try it! Windows Live™: Keep your life in sync. Check it out!
Re: [pygame] Alpha channels and per pixel alpha
Hi René, Did anyone ask Bjorn what Pygame version is used? Many blit bugs were fixed for Pygame 1.9.0. Lenard Did anyone as René Dudfield wrote: works here import pygame import os def load_alpha_image(name): #fullname = os.path.join( 'Images', name) fullname = 'default_alpha2.png' try: image = pygame.image.load(fullname).convert_alpha() except pygame.error, message: print 'Cannot load image:', fullname raise SystemExit, message return image screen = pygame.display.set_mode((22,22,)) i = load_alpha_image('s') print i.get_at((0,0)) Results in (0,0,0,0) which is correct for the image given. What do you get? On Thu, Jun 11, 2009 at 4:39 PM, Bjorn Samuelssonbjorn_...@hotmail.com wrote: Here's the image and code: def load_alpha_image(name): fullname = os.path.join( 'Images', name) try: image = pygame.image.load(fullname).convert_alpha() except pygame.error, message: print 'Cannot load image:', fullname raise SystemExit, message return image Date: Wed, 10 Jun 2009 15:56:10 -0700 Subject: Re: [pygame] Alpha channels and per pixel alpha From: br...@hamsterrepublic.com To: pygame-users@seul.org It would help to see your code and have an example image attached, cause loading .png's with alpha and blitting with transparency works fine for me without any trouble or special stuff. On Wed, Jun 10, 2009 at 2:11 PM, Bjorn Samuelsson bjorn_...@hotmail.com wrote: Hey all, I'm trying to make a small 2d game and I'm wondering how you would go about to load a png-image with an alpha channel and keep it's alpha values? I have confirmed the images alpha channel but when i load it in pygame it's alpha values are always 255. I've tried Surface.convert_alpha but that doesn't make a difference. At the moment I've resorted to saving my alpha channels separate and loading both image and alpha channel so that i can call Surface.set_at to change the image's per pixel alpha value. But that solution seems less than optimal so i figured i would ask you guys. regards Björn ps. I apologize if this topic has been discussed at length already but i've been looking around and i just can't seem to find a simple solution. ds. Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! Try it! Windows Live™: Keep your life in sync. Check it out!
Re: [pygame] Alpha channels and per pixel alpha
The way to do it is with .convert_alpha() Check that your images really do have an alpha channel.
Re: [pygame] Alpha channels and per pixel alpha
It would help to see your code and have an example image attached, cause loading .png's with alpha and blitting with transparency works fine for me without any trouble or special stuff. On Wed, Jun 10, 2009 at 2:11 PM, Bjorn Samuelsson bjorn_...@hotmail.comwrote: Hey all, I'm trying to make a small 2d game and I'm wondering how you would go about to load a png-image with an alpha channel and keep it's alpha values? I have confirmed the images alpha channel but when i load it in pygame it's alpha values are always 255. I've tried Surface.convert_alpha but that doesn't make a difference. At the moment I've resorted to saving my alpha channels separate and loading both image and alpha channel so that i can call Surface.set_at to change the image's per pixel alpha value. But that solution seems less than optimal so i figured i would ask you guys. regards Björn ps. I apologize if this topic has been discussed at length already but i've been looking around and i just can't seem to find a simple solution. ds. -- Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! Try it!http://spaces.live.com/spacesapi.aspx?wx_action=createwx_url=/friends.aspxmkt=en-us
RE: [pygame] Alpha channels and per pixel alpha
Ok. Could you possibly give me some short instructions on how to make a simple image with alpha channel so maybe I can see what I'm doing wrong. This is how i do it: take a regular image in photoshop, add an alpha channel, save as a SuperPNG with the alpha channels box checked. I'm not really sure how to check if I have a working alpha channel or not. But when i reopen the image in photoshop the alpha channel is still there. I also tried a small application that gives out information about a given png-file and it said that the image is 32-bit RGB+alpha, non-interlaced. From: geometr...@gmail.com Date: Wed, 10 Jun 2009 14:48:58 -0700 Subject: Re: [pygame] Alpha channels and per pixel alpha To: pygame-users@seul.org The way to do it is with .convert_alpha() Check that your images really do have an alpha channel. _ More than messages–check out the rest of the Windows Live™. http://www.microsoft.com/windows/windowslive/
Re: [pygame] Alpha channels and per pixel alpha
try this: image = pygame.image.load(image.png).convert_alpha() screen.blit(image, (0,0)) See if it is alpha or not... :) On Wed, Jun 10, 2009 at 6:03 PM, Bjorn Samuelsson bjorn_...@hotmail.comwrote: Ok. Could you possibly give me some short instructions on how to make a simple image with alpha channel so maybe I can see what I'm doing wrong. This is how i do it: take a regular image in photoshop, add an alpha channel, save as a SuperPNG with the alpha channels box checked. I'm not really sure how to check if I have a working alpha channel or not. But when i reopen the image in photoshop the alpha channel is still there. I also tried a small application that gives out information about a given png-file and it said that the image is 32-bit RGB+alpha, non-interlaced. -- From: geometr...@gmail.com Date: Wed, 10 Jun 2009 14:48:58 -0700 Subject: Re: [pygame] Alpha channels and per pixel alpha To: pygame-users@seul.org The way to do it is with .convert_alpha() Check that your images really do have an alpha channel. -- check out the rest of the Windows Live™. More than mail–Windows Live™ goes way beyond your inbox. More than messageshttp://www.microsoft.com/windows/windowslive/
Re: [pygame] Alpha channels and per pixel alpha
Right, a surface created from an image with an alpha channel will have per-pixel alpha. If it doesn't then the image may have a blanket alpha or a colorkey instead. Lenard Brian Fisher wrote: It would help to see your code and have an example image attached, cause loading .png's with alpha and blitting with transparency works fine for me without any trouble or special stuff. On Wed, Jun 10, 2009 at 2:11 PM, Bjorn Samuelsson bjorn_...@hotmail.com mailto:bjorn_...@hotmail.com wrote: Hey all, I'm trying to make a small 2d game and I'm wondering how you would go about to load a png-image with an alpha channel and keep it's alpha values? I have confirmed the images alpha channel but when i load it in pygame it's alpha values are always 255. I've tried Surface.convert_alpha but that doesn't make a difference. At the moment I've resorted to saving my alpha channels separate and loading both image and alpha channel so that i can call Surface.set_at to change the image's per pixel alpha value. But that solution seems less than optimal so i figured i would ask you guys. regards Björn ps. I apologize if this topic has been discussed at length already but i've been looking around and i just can't seem to find a simple solution. ds. Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! Try it! http://spaces.live.com/spacesapi.aspx?wx_action=createwx_url=/friends.aspxmkt=en-us
RE: [pygame] Alpha channels and per pixel alpha
What are you trying to do with the alpha channel? Just a transparent background? Are you drawing something on the alpha channel in photoshop? Just adding one doesn't really do anything, the alpha channel has to have , pixel data too, just like the rgb channels. If I want to make a jpg transparent in parts I usually just unlock the background layer and then erasing it or magic wanding it or quick masking or however you want to make something transparenty-like will work. Make sure you see the checker-box pattern to know its transparent, if its still white or a color its not transparent. Then just save it as a normal png, I don't know what a superpng is. --- On Wed, 6/10/09, Bjorn Samuelsson bjorn_...@hotmail.com wrote: From: Bjorn Samuelsson bjorn_...@hotmail.com Subject: RE: [pygame] Alpha channels and per pixel alpha To: pygame-users@seul.org Date: Wednesday, June 10, 2009, 6:03 PM #yiv1831619233 .hmmessage P { margin:0px;padding:0px;} #yiv1831619233 { font-size:10pt;font-family:Verdana;} Ok. Could you possibly give me some short instructions on how to make a simple image with alpha channel so maybe I can see what I'm doing wrong. This is how i do it: take a regular image in photoshop, add an alpha channel, save as a SuperPNG with the alpha channels box checked. I'm not really sure how to check if I have a working alpha channel or not. But when i reopen the image in photoshop the alpha channel is still there. I also tried a small application that gives out information about a given png-file and it said that the image is 32-bit RGB+alpha, non-interlaced. From: geometr...@gmail.com Date: Wed, 10 Jun 2009 14:48:58 -0700 Subject: Re: [pygame] Alpha channels and per pixel alpha To: pygame-users@seul.org The way to do it is with .convert_alpha() Check that your images really do have an alpha channel. check out the rest of the Windows Live™. More than mail–Windows Live™ goes way beyond your inbox. More than messages