Setting Transparent Colors for Bitmaps

music7611

Active member
Joined
Jan 24, 2004
Messages
35
I have a Bitmap and I wanted to set the transparent color. I decided to use MakeTransparent(), but it seems that just adds the color to a list of transparent colors. Is there a way to set the one and only transparent color?
 
Yeah that could work except my program has one of those things where you have the little eye dropper on the image and you need to select a color to be transparent. It works just fine when they click once, but when they click on that color then another color, they both become transparent.
 
Oh yikes. Just add a boolean check andsee if youve already made it transparent.... oh wait, then how would you remove the previous transparent color?

Hmm. I guses your only choice is:

Public Sub ChangeColor(mynewcolor as color)
Dim temp as new bitmap(mybitmap.image)
temp.maketransparent(mynewcolor)
mybitmap = new bitmap(temp.image)
mybitmap = temp
End Sub

Since youre not really making a game, i doubt it would make a performance hit in yoru application since youre not rendering objects every frame...etc

-TPG
 
First of all, I am making a game (funny you say so) but this part is only the tool you use to make tilesets. The problem with this is, lets say I have a 256 tile tileset (worst case scenario), then it has to store 512 images. I dont think its worth storing the same image twice for every tile in the game. So, until I can think of something better, the only thing to do is select the transparent color and hope the user can tell whether it works or not.
 
Hmm. Its still only a tool :D, even though its for a game :cool: , I still doubt it would affect your performacnce a lot, except for that one time where it has to update the new color. Youre really not storing 512x512 images, since you store it back into the original bitmap (or array of bitmaps) anyways.

So give it a shot. Yeah it would probably be a performance hit but just for a second or two while it updates(if youre using HUGE amounts of tiles, but your 256x256 scenario would take a lot less time, depending on the size of the image)



-The Pentium Guy
 
Back
Top