🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
transparency in SDL
i have a small bitmap image, 29x29, of a circle ball. i want to know how to make the area outside the ball transparent so you cant see it when moving across the differrent colored background.
any help at all is greatly appreciated
Paint the background of the image in a specific color (e.g. magenta) and
should work (0x00ff00ff is the color that will not be drawn).
ball_surface = SDL_LoadBMP("ball.bmp");SDL_SetColorKey( ball_surface, SDL_SRCCOLORKEY, 0x00ff00ff );
should work (0x00ff00ff is the color that will not be drawn).
Or use SDL_image and save your images as png files with alpha channel.
http://www.libsdl.org/projects/SDL_image/
http://www.libsdl.org/projects/SDL_image/
Here's an easier way:
SDL_Surface *Foo = SDL_LoadBMP("Foo.bmp");
SDL_SetColorKey(Foo, SDL_SRCCOLORKEY, SDL_MapRGB(Foo->format, Red, Green, Blue));
where you replace Red, Green and Blue with the appropiate RGB value of the transparent pixel in the image.
SDL_Surface *Foo = SDL_LoadBMP("Foo.bmp");
SDL_SetColorKey(Foo, SDL_SRCCOLORKEY, SDL_MapRGB(Foo->format, Red, Green, Blue));
where you replace Red, Green and Blue with the appropiate RGB value of the transparent pixel in the image.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement