Alpha manipulation or RGB only blit

I am wondering if anyone out there got an idea or technique on how to blit
only the alpha channel to a RGBA surface or the other way around, only blit
the RGB channels and leave the target surface’s Alpha values untouched. The
closest I’ve come to is to use color key but that’s not very effective and
can’t handle antialise.

thanks,

joel…

I am wondering if anyone out there got an idea or technique on how to blit
only the alpha channel to a RGBA surface or the other way around, only
blit
the RGB channels and leave the target surface’s Alpha values untouched.
The
closest I’ve come to is to use color key but that’s not very effective and
can’t handle antialise.

thanks,

joel…

Joel,

If you’re working with OpenGL’s feature set (within SDL) you can use
glColorMask( r, b, g, alpha ) to enable/disable writing to the various frame
buffer color components. That’s where the r, g, b, and alpha parameters are
booleans…

If you’re not rendering via OpenGL, you could try the glSDL variant and
see if glColorMask() works within that framework… otherwise someone else
will have to step in with a suggestion.

-Blake

----- Original Message -----
From: jchen@interval.com (Joel Chen)
Sent: Friday, June 28, 2002 4:50 PM
Subject: [SDL] alpha manipulation or RGB only blit

Joel Chen wrote:

I am wondering if anyone out there got an idea or technique on how to blit
only the alpha channel to a RGBA surface or the other way around, only blit
the RGB channels and leave the target surface’s Alpha values untouched. The
closest I’ve come to is to use color key but that’s not very effective and
can’t handle antialise.

SDL_BlitSurface doesn’t touch the destination surface alpha channel…at least when SRC_ALPHA is on…

I made a blitter that copies alpha values after a normal blit, so that I can compose surfaces that have src_alpha on…

if interested I can show you the routine.–
-==-
Jon Atkins
http://jonatkins.org/

I’ve looked over the SDL_SetAlpha and SDL_BlitSurface documents a few times
and tried a few combinations myself and I didn’t see any method to achieve
that. Of course I am very interested to see your routine.

thanks,

joel…> -----Original Message-----

From: Jonathan Atkins [mailto:jcatki at jcatki.no-ip.org]
Sent: Friday, June 28, 2002 6:38 PM
To: sdl at libsdl.org
Subject: Re: [SDL] alpha manipulation or RGB only blit

Joel Chen wrote:

I am wondering if anyone out there got an idea or technique
on how to blit
only the alpha channel to a RGBA surface or the other way
around, only blit
the RGB channels and leave the target surface’s Alpha
values untouched. The
closest I’ve come to is to use color key but that’s not
very effective and
can’t handle antialise.

SDL_BlitSurface doesn’t touch the destination surface alpha
channel…at least when SRC_ALPHA is on…

I made a blitter that copies alpha values after a normal
blit, so that I can compose surfaces that have src_alpha on…

if interested I can show you the routine.


-==-
Jon Atkins
http://jonatkins.org/


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

By the way, is your source surface 24bit RGB? I know that RGBA->RGBA leaves
the target alpha alone.

joel…> -----Original Message-----

From: Jonathan Atkins [mailto:jcatki at jcatki.no-ip.org]
Sent: Friday, June 28, 2002 6:38 PM
To: sdl at libsdl.org
Subject: Re: [SDL] alpha manipulation or RGB only blit

Joel Chen wrote:

I am wondering if anyone out there got an idea or technique
on how to blit
only the alpha channel to a RGBA surface or the other way
around, only blit
the RGB channels and leave the target surface’s Alpha
values untouched. The
closest I’ve come to is to use color key but that’s not
very effective and
can’t handle antialise.

SDL_BlitSurface doesn’t touch the destination surface alpha
channel…at least when SRC_ALPHA is on…

I made a blitter that copies alpha values after a normal
blit, so that I can compose surfaces that have src_alpha on…

if interested I can show you the routine.


-==-
Jon Atkins
http://jonatkins.org/


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

Joel Chen wrote:

By the way, is your source surface 24bit RGB? I know that RGBA->RGBA leaves
the target alpha alone.

ah, my source is no 24bit…that would be useless in my program…

what I do is blit the lower alpha values myself after a normal blit…
perhaps if you look at code it may spark an idea for a solution for you.

get http://jcatki.no-ip.org/JAI-1.0.0.tar.gz
and look at the JAI_BlitSurfaceAlpha routine in the JAI.c
it basically ends up doing a get pixel for the alpha on both surfaces, and then sets the higher value in the destination.–
-==-
Jon Atkins
http://jonatkins.org/