A project I am currently porting creates alpha masks on the fly to take the
jagged edges off of some of the images it dynamically creates. I know how to
make the grayscale images accordingly, I just am not sure on how to safely
write them to the alpha properties of an SDL surface. Same with reading the
data. Any information on how to access it would be appreciated.
I have to assume that the images you are creating are in some RGB
format, is that correct? If so, you had to create a pixel format
structure (or it got created for you) when you created the SDL surface
for the image. That structure tells you the size and location of each
field in a pixel. To store the alpha values into the alpha field you
have to shift them to the correct location in the pixel and then and or
them into the the pixels. That means you have to read the alpha value,
read the pixel you want to merge it into, shift and or the alpha value
into the pixel, and the write the modified pixel back where it came
OTOH, since you are generating the alpha values and the image pixels,
why not just apply the alpha values while you are generating the image?
You could either just include the alpha with the rest of the RGB data,
or you could scale the RGB values by the alpha as you create the image
and save the step.
Bob PendletonOn Mon, 2005-05-30 at 20:50 -0400, Andy Kellett wrote:
Andy ‘Fish-Guy’ Kellett
URL: http://www.f1-software.com ICQ: 9701389 AOL: FishGuy876
From: Donny Viszneki [mailto:smirk at thebuicksix.com]
Sent: Monday, May 30, 2005 5:04 PM
To: Andy Kellett
Subject: Re: [SDL] Working With Surface Alpha Masks
Just out of curiosity, what do you wish to use this for?
On May 28, 2005, at 5:30 PM, Andy Kellett wrote:
Can anyone point me in the right direction of working with the alpha
masks inside of an alpha-enabled SDL_Surface?
I’m interested in reading/writing my own data from the mask, so any
code examples or links would be nice. I have googled for some help,
but haven’t been able to locate any examples of any use. Ideally I’d
like to be able to read an entire mask, or replace one with my own
code. I don’t need to know how to make a mask, just how to read/write
mask data to and from a surface.
SDL mailing list
SDL at libsdl.org