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

Re: [pygame] Transparent Images - Example of Problem



With respect to tring to blit transparent images to a master image,
and then bliting the master:

On 6/21/06, Kris Schnee <kschnee@xxxxxxxxxx> wrote:
On a related note, I'm having trouble displaying images that _are_
transparent, transparently in Pygame. I load them using convert_alpha(),
but then it gets tricky. I have objects that do something like this:

def Redraw(self):
        ## Only called when "dirty"
        self.image.fill((0,0,0)) ## Clear my internal drawing surface
        self.image.blit(SOME_GRAPHICS,(0,0)) ## Put graphics on it
def Display(self):
        ## Called whenever parent surface is "dirty"
        self.screen.blit(self.image) ## Blit my finished image to the screen
(or other parent surface)

I don't think pygame supports this properly (often called
"compositing") mainly because SDL doesn't support this. It doesn't
have any blit mode that reads the destination alpha and then writes
the correct combined alpha (probably because it's slow). It either
copies the alpha from the source, or leaves the original alpha in the
dest

someone asked about this before on the mailing list:
http://aspn.activestate.com/ASPN/Mail/Message/2915624

So if you want to composite stuff with alpha, you'll need to use some
other routines other than pygame blit