[SDL] Blit effects

Marcus von Appen mva at sysfault.org
Tue Mar 18 12:11:14 PDT 2008


On, Mon Mar 17, 2008, Mason Wheeler wrote:

> When blitting an image, how do you do special effects?  For example,
> it's easy to do a direct copy, an alpha-blended copy or a color-keyed
> copy, but what if I wanted to use effects such as Add, Multiply,
> Maximum, etc?  How do I set those up?

We realized this for the pygame library, which does its job well enough
at the moment.

In short: we prepare a SDL_BlitInfo that holds the source and
destination, their clipping areas, sizes, etc., then walk over the
pixels arrays for both, the destination and source surface, calculate
the new RGB(A) values for the destination surface using the different
algorithms and set the new pixel value in the destination surface.

If you want to know more about how we did that, grab yourself a SVN copy
of pygame (http://www.pygame.org) and take a look at alphablit.c and
surface.h for the relevant loops and macros.

Regards
Marcus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20080318/6b3526a5/attachment.pgp 


More information about the SDL mailing list