|
Setting Transparent Color |
emoremor
Member #2,667
August 2002
|
Hi, I have a question - I noticed that the default transparent color for bitmap blitting is 255,0,255 (some sort of pink) but I have always used 0,0,0 - black. Is there a way to instruct the library to use black as transparent? I have a lot of bitmaps that I am reusing in rewrites of my games porting them to allegro and I am kind of tired of doing transparent color replacement??? Thanks for the info |
kdevil
Member #1,075
March 2001
|
I assume you're using some color depth other than 8-bit. I don't think there's a way to change that transparent color. You're probably better off just writing a small program that does the color replacement for you. ----- |
gnolam
Member #2,030
March 2002
|
Short answer: no, not unless you're using 8-bit mode (in which case palette entry 0 is always used, regardless of its color). -- |
Kitty Cat
Member #2,815
October 2002
|
No, you can't change the transparent color. However, if you're not using 8bpp, you can do a little post-loading picture editing so you won't have to change your bitmaps, but they'll behave the same: This will make any magenta pixels in the bitmap one bit darker(hardly noticeable) so they won't get masked, and make black the magic pink color Allegro wants. -- |
emoremor
Member #2,667
August 2002
|
Thanks everyone for your answers. This clarifies it completely. Yes, I am using 16-bit. I tried 32-bit but the whole game slowed down to a halt. It seems that for 32-bit depth I should be using VRAM. I just did not want to use it in case some potential users did not have it. But I guess, nowadays, it may be rare for people not to have it. Anyway, I can switch the colors quickly with PSP. It's just that I thought it would have been easy to do with Allegro. It's not a hard thing to do. I am not sure I understand why the library does not support selecting the transparent color... |
Ceniza
Member #2,027
March 2002
|
Because it is possible:
I only needed to change it for bmp and it also worked fine for bmp2. I tested it with an image in which I drew with the wrongly called magic pink color (it's light magenta) and also with black and it works as you want it to: black becomes the mask color and light magenta is just another color. Possible problem: compatibility. I tested it in an XP machine. |
Chris Katko
Member #1,881
January 2002
|
Quote: Anyway, I can switch the colors quickly with PSP. It's just that I thought it would have been easy to do with Allegro. It's not a hard thing to do. I am not sure I understand why the library does not support selecting the transparent color... It's not "a hard thing to do" to convert it to whatever is nessecary yourself. Which is the same end result as having it set-able. They even gave you the code to do so. Cutting the work you have to do virtually down to a "cut and paste." So could Allegro support changing the transparency color? Yes. Would it be worth the effort of recoding every single function that takes that into account? Probably not. Also, you now have a speed loss, because your using a variable in RAM, instead of a hard-coded constant. And PSP? I assume you mean paintshop pro. Which is a professional graphics editor. Not a game programming library. So certain features are expected in graphics editors. Lastly, your need falls under the "utility" category and therefor not nessecary the "game programming library" category. Hence, why I really doubt you'll find that in OpenGL, SDL, DirectX, etc as well. I really hope I'm not coming off too harse. -----sig: |
Korval
Member #1,538
September 2001
|
Quote: So could Allegro support changing the transparency color? Yes. Maybe for memory bitmaps, but hardware accelerated video blits may be another matter. If FF00FF is hardcoded as the mask color in the hardware, then there is nothing you can do to change it. Granted, most modern color keying hardware does allow you to select it, but it is not impossible to find hardware that doesn't allow for selecting the color key. |
spellcaster
Member #1,493
September 2001
|
I know that this is Bob's normal explanation, but what cards actually do this? Most APIs let you set a mask color or a mask color range. Maybe we should allow to change the color, but have a checking function that tells you if it's save or not. That checking function could create a vid bitmap set it to a non pink trans colro, do a blit and read back from the vid bitmap. -- |
emoremor
Member #2,667
August 2002
|
Etwinox: That's fine. It is not that big of a deal. The issue was to reuse my existing artwork without doing color replacements. In the future, I don't mind one or another color key. I use PSP as a graphic package, of course, to replace color because I can do it pretty fast and I don't need to modify my code (although I can see from the previous example that I could do that too...) Having said that, if you use DirectX you can easily specify the color key in code by setting one simple flag. That's what lead me to ask whether Allegro provided for a simple flag to set the key. |
|