Sign in to follow this  

Alpha Channels not working!

This topic is 4203 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been trying to get transparency in my graphics for a few days now, and it's just not working. I am loading my pictures into my game through SDL and C++. I am using photoshop to make my graphics, and decided to use the alpha channels to get my transparency instead of using colorkeys. I've read numerous tutorials on how this is done but I still get a white background. Here are some pictures of what I'm talking about: 1)Program running: http://img528.imageshack.us/img528/5301/program6jb.png 2)Shows the layers in PS: http://img112.imageshack.us/img112/7412/layers8kx.png 3)Shows the channels and alpha layer: http://img112.imageshack.us/img112/9789/channels1mm.png

Share this post


Link to post
Share on other sites
Quote:
Original post by Sentralia
I've been trying to get transparency in my graphics for a few days now, and it's just not working. I am loading my pictures into my game through SDL and C++. I am using photoshop to make my graphics, and decided to use the alpha channels to get my transparency instead of using colorkeys. I've read numerous tutorials on how this is done but I still get a white background. Here are some pictures of what I'm talking about:

1)Program running: http://img528.imageshack.us/img528/5301/program6jb.png

2)Shows the layers in PS: http://img112.imageshack.us/img112/7412/layers8kx.png

3)Shows the channels and alpha layer: http://img112.imageshack.us/img112/9789/channels1mm.png

are you saving the image as 32 bit?

Share this post


Link to post
Share on other sites
Quote:
Original post by Sentralia
Yes, it's a 32bit TGA. I have CS2, so I assume that TGA problem is fixed.

well, my only other suggestion is try it without using a transparency background since there is no reason for it anyway and may be interfering with the alpha channel.
other thing is that if you're programing your game yourself make sure your code is good, try a texture you know that works in it to see if it is your code.

Share this post


Link to post
Share on other sites
Yeah, it's definitely in the code. I just loaded the image into flash, and the background was transparent. I'll post the code, which was taken from Lazy Foo's Blitting tutorial:

This is my load.cpp

#include "load.h"

SDL_Surface *load_image( std::string filename )
{
SDL_Surface* loadedImage = NULL;
SDL_Surface* optimizedImage = NULL;
loadedImage = IMG_Load( filename.c_str() );

if( loadedImage != NULL )
{
optimizedImage = SDL_DisplayFormat( loadedImage );
SDL_FreeSurface( loadedImage );
}



return optimizedImage;

}
void apply_surface(int x, int y, SDL_Surface* source, SDL_Surface* destination)
{
SDL_Rect offset;
offset.x = x;
offset.y = y;
SDL_BlitSurface( source, NULL, destination, &offset );
}


In my main.cpp I have the BPP set to 32. Check lazyfooproductions.com and check the blitting tutorial, this is where i got the code from.

Share this post


Link to post
Share on other sites

This topic is 4203 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this