Jason,
What you’re talking about with regard to the outside perimiter of the circle is transparency. To accomplish this, simply load the bitmap into it’s own surface (using SDL_LoadBMP() for example), then call:
int SDL_SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key);
for example:
SDL_SetColorKey(lpMyBitmapSurface, SDL_SRCCOLORKEY, 0x00000000);
In the example above, the color is 0x00000000, or all black. Now, all bits in your bitmap surface that are black will be transparent when you blit it onto another surface. Make use of RGB macros to set the transparency color you wish to use.
You can then set the alpha blending property of a surface using:
int SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha);
See the SDL docs for all the different flags you can use for the above two functions.
Hope this helps!
Jason Clark wrote:
Thanks Milan,
1 & 2) I know that I can manually do it, I just wanted to make sure the
functionality didn’t already exist in some form I wasn’t aware of (I’m
trying to avoid duplicating effort).
3) This I can manually do if I have to but am hoping there is some already
supported functionality. I’ll give an example of what I need to do
I have a 32x32 pixel image with a filled circle in it. The circle is
surrounded by a color that I want to have completely transparent. The circle
itself I want to Alpha blend at say 25%. I know I can do either of these
with SDL, however doing both to the same image is eluding me. If I have to
I’ll write a routine that takes the image and manually adjusts the
individual pixels of the circle and use SDL to give the transparency around
it, but chances are I’m liable to be fairly inefficient at it.
Thanks again,
Jason.> ----- Original Message -----
From: sdl-admin@libsdl.org [mailto:sdl-admin at libsdl.org]On Behalf Of
Milan Babuskov
Sent: Wednesday, October 01, 2003 12:17 AM
To: sdl at libsdl.org
Subject: Re: [SDL] A couple of questions…
Jason Clark wrote:
Before I go running off re-inventing the wheel (my version would
undoubtedly
look remarkably like a square), I wanted to see if any of you have already
developed solutions for them:
- I need to be able to read a source Rect from a bmp and rotate it 90
degrees.
This can be done in less than 10 lines of code. Just write two nested
for loops to copy the pixels to the right place on destination
- Copy one SDL_Surface to another.
This is even easier, one liner.
- take a Rect and apply different levels of alpha, i.e., make one color
fully transparent and then apply a % to the remainder of the image.
Hm, don’t know about this one… what exactly do you want to do?
–
Milan Babuskov
http://njam.sourceforge.net
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search