Jump to content
  • Advertisement


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


16bpp, Visual Basic

This topic is 6823 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 I''m having problem with setting my transparent color. I have set up a resolution of 640x480x16, and I have bitmaps saved as 24bit. My transparent color is RGB(255,0,255) but it doesn''t work in 16bit mode, only in 32... I have seen several examples on how to do this in C++, but none on how to do it in VB. I have tried with GetPixelFormat and ColorGetBlue etc. Maybe I did it the wrong way. Can someone pls help me? Thanks, //Rickard

Share this post

Link to post
Share on other sites
As you probably know, the RGB values are not the same in different screenmodes. I always use RGB(0,0,0) as colorkey value, most people say it''s no good since you might wanna use that color, but you can use RGB(5,5,5) and up and it looks the same as pure black.

If you want to use something else than that, make sure you haven''t any values closer than 5 from the colorkey value.

Daniel Netz, Sentinel Design
"I'm not stupid, I'm from Sweden" - Unknown

Share this post

Link to post
Share on other sites
The RGB function only return 24 bit color values, that's why you're code is not functioning. You have to write code to match the color to the pixelformat of the surface. Here's a function you can use to determine the equivalent value for the colorkey you want:

Function DDColorMatch(DDSurf As DirectDrawSurface7, DDSurfDesc As DDSURFACEDESC2, RGBColor As Long) As Long
Dim Pixel As Long
Dim SurfaceHdc As Long
Dim rctLock As RECT
Dim bytLock() As Byte

SurfaceHdc = DDSurf.GetDC()

Pixel = GetPixel(SurfaceHdc, 0, 0)
SetPixel SurfaceHdc, 0, 0, RGBColor

DDSurf.ReleaseDC SurfaceHdc

With rctLock
.Top = 0
.Left = 0
.Bottom = 0
.Right = 0
End With

DDSurf.Lock rctLock, DDSurfDesc, DDLOCK_WAIT, 0

DDColorMatch = DDSurf.GetLockedPixel(0, 0)

DDSurf.Unlock rctLock

SurfaceHdc = DDSurf.GetDC()
SetPixel SurfaceHdc, 0, 0, Pixel
DDSurf.ReleaseDC SurfaceHdc

End Function

All you have to do is to pass a surface, its descriptor and the RGB value for the color and it will return the equivalent color value for the pixelformat you are using. If you try RGB(255,0,255) you will get 65319 as the return value...

If you have any doubt, feel free to contact me...

André Luiz Silva
"There is no knowledge that is not power"

Edited by - Andre Luiz Silva on 3/13/00 7:37:05 AM

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!