It is currently Wed Sep 08, 2010 6:14 am

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Conversion from RGB to RGBA Surface
PostPosted: Tue Jun 29, 2010 2:31 pm 
User avatar
Joined: Tue Apr 06, 2010 4:54 pm
Posts: 25

Hi all,

I'm trying to create some OpenGL textures from SDL surfaces. So far, I can handle basic loading as well as a texture with colorkey (RGBA images only).

However, RGB images do not respond properly, i.e. the pixels which should be transparent are unchanged. I suspect that this is because the image needs an alpha channel, so I need to convert the image from an RGB surface to an RGBA surface, but I'm not sure how to do this.

I'll post my code if it helps, but basically I'm looping through all the pixels in the surface and setting any, that match the colorkey, to a fully transparent black pixel.

_________________
- NordCoder


Offline
 Profile  
 Post subject: Re: Conversion from RGB to RGBA Surface
PostPosted: Wed Jun 30, 2010 12:00 am 
Joined: Thu Jun 18, 2009 11:47 pm
Posts: 33

Hello NordCoder. I've experienced some trouble with (lack of) alpha channels. I solved it by opening the image in GIMP and then putting an alpha channel to it, then saving it back.

Don't know if it helps, maybe worth a try.

Never tried it coding with SDL.


Offline
 Profile  
 Post subject: Re: Conversion from RGB to RGBA Surface
PostPosted: Wed Jun 30, 2010 5:47 am 
User avatar
Joined: Tue Apr 06, 2010 4:54 pm
Posts: 25

Hi Leonardo!

Manually adding an alpha channel was suggested on some forums, but I would prefer to do it in code instead. It seems that SDL_SetColorKey(...) works on RGB surfaces so there must be some way to do it, possibly SDL_ConvertSurface(...) or SDL_CreateRGBSurface(...).

I'll try to see if those works and if not, then just do it in a image program :)

Thanks for your help!

_________________
- NordCoder


Offline
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


 Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
 
cron