RE: [pygame] Alpha channels and per pixel alpha

2009-06-11 Thread Bjorn Samuelsson

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

2009-06-11 Thread René Dudfield
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

2009-06-11 Thread Lenard Lindstrom

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!





[pygame] Re: Problem with display.update(rectangle_list)

2009-06-11 Thread Michael Leach
Lenard, what you suggested worked perfectly. If I'd have paid more
attention when learning about blitting I'd have known that!

Thanks to everyone for your help :)