Blit effects

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?

Right now, you do them yourself on a per-pixel-basis, I believe.On Mon, Mar 17, 2008 at 12:47:17PM -0700, 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?


-bill!
bill at newbreedsoftware.com
http://www.newbreedsoftware.com/

…which sort of defeats the purpose of having a framework for easy access to hardware acceleration. Is this on the list of “stuff that will be in SDL 1.3”? These effects are pretty standard functions which are in all sorts of other graphics frameworks, and I was surprised not to find anything for them in SDL.> ----- Original Message -----

From: nbs@sonic.net (Bill Kendrick)

On Mon, Mar 17, 2008 at 12:47:17PM -0700, 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?

Right now, you do them yourself on a per-pixel-basis, I believe.

SDL’s purpose isn’t to provide easy access to hardware acceleration
(if anything, the current set of “things that are hardware
accelerated” in SDL is quite low, for example alpha blits aren’t). If
you want accelerated graphics in SDL the general consensus is to use
OpenGL for the actual drawing, and SDL for the everything else.On Tue, Mar 18, 2008 at 10:50 AM, Mason Wheeler wrote:

…which sort of defeats the purpose of having a framework for easy access to hardware acceleration. Is this on the list of “stuff that will be > in SDL 1.3”? These effects are pretty standard functions which are in all sorts of other graphics frameworks, and I was surprised not to find > anything for them in SDL.

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