SDL Bmp transparency

Started by
12 comments, last by Pulse_Phalanx 19 years, 11 months ago
hey run, how do you go about telling SDL which part of the image to blit at which transparency? like, i dont understand how you got the border of the text box to be more transclucent then the inside of the box. do you do this in an image editing program like paint shop pro ? or do you do this with the SDL code ? if so, how do you tell it "only the border of the image?"
FTA, my 2D futuristic action MMORPG
Advertisement
Well, the problem I had involved the fact I was building the window in an offscreen surface, so the alpha channel was lost in the process. But typically, you''d create the window in an image-editing program such as, say, Paintshop Pro, give it an alpha channel, save it as PNG, and then let SDL do the rest.
ahhhh... so you DO do the alpha part inside psp... i figured that had to be how people did it, couldnt imagine you telling the code each pixel individually to blend... how did you figure out how to do that in PSP anyway? maybe a small description would help me =) thanks
FTA, my 2D futuristic action MMORPG
Well, it''s just that... y''know... natively, the PNG format allows for the use of an alpha channel so... y''know... it''s kinda intuitive to use it for this sort of thing.

It IS possible to manually set the alpha channel. However, since it would involve per-pixel rendering (well, setting...), it''s best to do it at load-time and not at run-time unless you have very small sprites or images. Or you can set the surface''s alpha to whatever you feel''s appropriate if you only need one level of transluscency (such as say... 50%).

With PSP, there''s a way to alter the alpha channel directly (check the menus; I forgot the name). You can just "draw" your transluscency and save the image as a PNG. Since PNGs contain an alpha channel, once you load it into a surface it''ll automatically fill in the surface alpha channel with the PNG''s alpha channel and make it all nice and ready for blitting.

Of course, you need to load the PNG yourself or use a library that does that, but that shouldn''t be a problem.

This topic is closed to new replies.

Advertisement