Jump to content
  • Advertisement
Sign in to follow this  
Caroline_M

Transparency Question

This topic is 4858 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'm writing a simple RPG Maker. I have a tool to edit the map etc which is written in C# using Windows Forms and the client application that run the resulting game is in C++ using SDL. I downloaded a bunch of graphics from Reiners Tilesets to use to make a sample map and at first I thought I was going to have to implement something to allow me to set the transparent colour of each tile individually as most of his sets use a slightly different colour. In the C# application, I'm using the MakeTransparent() method of the Drawing.Bitmap class and that method has a default version that doesn't take a colour. I tried it out and suddenly 95% of all the images were perfectly displayed with transparency working correctly. So how does the function know which colour in the image is the transparent one? Is there something coded into the image data? I'd like to use this feature because it means that I don't have to worry about transparency but there are few files that are still showing with their background colour despite being from the same set from which most are fine. In the client I use SDL_SetColorKey on my images but that doesn't seem to have any default version which means I need to specify the colour. Am I missing something here? I really don't understand where this transparency information is coming from and how I can put it to use. Thanks, Caroline M.

Share this post


Link to post
Share on other sites
Advertisement
It depends on the format of the images in question.

GIF images use a special entry in the palette which determines which colour is transparent.

PNG images can have an 8-bit alpha channel which dictates how opaque each pixel is. This allows you to blend layers with more control than just on/off functionality.

For any other image it was my understanding that the MakeTransparent function uses the first pixel in the image as the transparent colour. However, I can't find that in MSDN so I may have read it somewhere promulgating false information.

Share this post


Link to post
Share on other sites
Ahh thanks for the info. I managed to dig deeper into the MakeTransparent function and it uses the bottom-left pixel as the transparent one. Upon examing the results I am getting that would indeed seem to be the case. Heh, and I thought there was some weird magic going on behind the scenes!

Thanks,

Caroline M.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!