Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Emagen

Transparent color

This topic is 6934 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

Hi everybody- I running a program using 16 bit color and when I set the transparency for a bitmap to green using RGB(0,256,0), the green is still showing. Why is that? Thanks

Share this post


Link to post
Share on other sites
Advertisement
If you want transparency you''ll have to add alpha values to each pixel. (I don''t know if I understood your question right)

Visit our homepage: www.rarebyte.de.st

GA

Share this post


Link to post
Share on other sites
Try RGB(0, 255, 0) and you should be ok. The max value that you can store in 8 bits is 255 even though you can store 256 different values (0-255)

Hope that helps.

Share this post


Link to post
Share on other sites
I don''t know how you try to set it but in 16-bit values aren''t represented in whole bytes, they use 5-bit each.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Windows .bmp files cannot have 16 bpp, they are 8bpp or 24bpp. therefore rgb(0,255,0) in your 24bpp bmp will be (0,31,0) in 16bpp, but there is a complication. Depending on whether your video card uses 555 or 565 for 16 bit color. You can work out the code for pure 16 bit green by bitwise shifting the green part (31) left by 5(for 555) or 6(for 565) so hopefully if you try the numbers 992(31 * 2^5) or 1984(31 * 2^6) instead of the RGB(0,255,0) you shouldn''t see any pure green.

Share this post


Link to post
Share on other sites
Are you using DirectX, thats the only way i know how to do it, sorry. If you are, look at this code:

DWORD KeyColor;
DDPIXELFORMAT ddpf;

g_pDDSPrimary->GetPixelFormat(&ddpf); /*g_pDDSPrimary is my primary surface*/

KeyColor = ddpf.dwGBitMask; /*dwGBitMask makes it so pure green is the transparent color*/

DDCOLORKEY key;
key.dwColorSpaceLowValue = KeyColor; // sets low value
key.dwColorSpaceHighValue = KeyColor; // sets high value

/*Now, after you load your bitmaps into a surface, put this (before you blit)*/

Whatever_your_tile_surface_is->SetColorKey(DDCKEY_SRCBLT, &key);


I hope that helped

email: chickawow@netzero.net

annex software: http://annexsoftware.cjb.net

Share this post


Link to post
Share on other sites
quote:
Original post by mkoday

Are you using DirectX, thats the only way i know how to do it, sorry. If you are, look at this code:

DWORD KeyColor;
DDPIXELFORMAT ddpf;

g_pDDSPrimary->GetPixelFormat(&ddpf); /*g_pDDSPrimary is my primary surface*/

KeyColor = ddpf.dwGBitMask; /*dwGBitMask makes it so pure green is the transparent color*/

DDCOLORKEY key;
key.dwColorSpaceLowValue = KeyColor; // sets low value
key.dwColorSpaceHighValue = KeyColor; // sets high value

/*Now, after you load your bitmaps into a surface, put this (before you blit)*/

Whatever_your_tile_surface_is->SetColorKey(DDCKEY_SRCBLT, &key);


I hope that helped

email: chickawow@netzero.net

annex software: http://annexsoftware.cjb.net


Oh, i forgot to add - the DDPIXELFORMAT finds if the video card is 5/5/5 or 5/6/5 16-bit pixel format.



email: chickawow@netzero.net

annex software: http://annexsoftware.cjb.net

Share this post


Link to post
Share on other sites

  • 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!