[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Blitting to alpha channel or using another image's alpha channel
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] Blitting to alpha channel or using another image's alpha channel
- From: "René Dudfield" <renesd@xxxxxxxxx>
- Date: Fri, 19 Dec 2008 14:04:23 +1100
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Thu, 18 Dec 2008 22:04:26 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=nP3aukkAHyWMTaII89EpJjlR0oD7T1Jx6wVNxwDdQdU=; b=bwba/n2ICmUBvWCinSZJB9j/Up/zuc3RQUNy0DgcvoR2awvY5tKxI77CqSHmTYRpf3 R1XedtBTC9FUZ4PfhwiSzrOtNMNb/7HsyVJQpnaWkIo3JcxSbsmCWIQho8zwrzfhwhxi ItWYhwFjN7WgnnFays8npiGewOH66tmLaAI/o=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=tLYppzYl0i+nxWHTtx7A6YgZZERwhdFMB92lsYUMZx3ZawNWmeZd1kJ0bgXTmSc4YN IBcySPIKJ4Dms3anbtcMPiAbIiBq6TKqXTKBtcwhTI5XT13f3atDUSpyeyAcdcs3IAay aNx9QCUh/8ZtCyeLlkt0BU3wTLGCwpW1srBHo=
- In-reply-to: <13e3f9930812181854o1fc9cd54m5ae60aaa9edcea7f@xxxxxxxxxxxxxx>
- References: <13e3f9930812181854o1fc9cd54m5ae60aaa9edcea7f@xxxxxxxxxxxxxx>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
hi,
I think you can do this with Surface.set_masks() and surface.set_shifts.
Get the r,g,b,a masks, and shifts, then change them so that only the a
part is valid any more.
Then, I think you could blit the A from one surface to another.
cheers,
On Fri, Dec 19, 2008 at 1:54 PM, Weeble <clockworksaint@xxxxxxxxx> wrote:
> Can somebody suggest how to do this? I want to render parts of an
> image based on a dynamically generated mask. Right now I'm doing this
> by drawing the mask in black and white on another surface, then
> iterating over every pixel and changing the alpha value of the source
> image to match the red value of the corresponding pixel in the mask
> surface, then finally blitting this onto the target surface. This
> seems a bit convoluted and I get the feeling there's probably a more
> efficient way to do it. Is there a way either to 1. blit an 8-bit
> greyscale image directly into the alpha channel of an image, or 2.
> directly blit image A onto image B using image C as the alpha channel?
>