SDL_ttf to alpha surface

Hi

I need to put a surface returned from SDL_ttf with alpha into a larger
surface which contains its own alpha channel…actually it’s just blank. I
use this to simply scroll some text across the screen. I know there are
other ways to do it and I have actually done it another way, but I would like
to know if it is possible for future reference.

I tried for ages but couldn’t get it to work. Either ended up with just
black box, nothing at all or blobs where the text should be on a black box.
Grrr. How do others do this?

Thanks, Paul.

I’ve had to do something like this before as well. The way I ended up
doing it was to lock both surfaces and go pixel by pixel mapping one
onto the other.

You can use some logic for combining the two alpha values from the two
surfaces intelligently, I don’t think that any specific behaviour is
defined for a case like this. My guess would be that you’d want to use
the alpha value from the TTF font surface if the destination was fully
transparent, and if the destination had a value, do some kind of merger
between the two, or maybe always arbitrarily take the TTF surfaces
values.

Rember when you do this though to LOCK THE SURFACES. If you don’t it
might appear to work on your system, but explode on another. That and
use the masks and bpp, pitch etc. Described in the format structure of
the surface. Don’t just hack it.

Id’ post the code I used, but I’m at work, so I got’st no access or
time.

Sorry.On Thu, 2002-04-04 at 04:19, Paul wrote:

Hi

I need to put a surface returned from SDL_ttf with alpha into a larger
surface which contains its own alpha channel…actually it’s just blank. I
use this to simply scroll some text across the screen. I know there are
other ways to do it and I have actually done it another way, but I would like
to know if it is possible for future reference.

I tried for ages but couldn’t get it to work. Either ended up with just
black box, nothing at all or blobs where the text should be on a black box.
Grrr. How do others do this?

Thanks, Paul.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

End of Rant.

Jimmy
Jimmy’s World (http://www.jimmysworld.org)
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: This is a digitally signed message part
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020404/754d2e60/attachment.pgp