16bpp, Visual Basic
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
Rick_Dangerous
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
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
============================Daniel Netz, Sentinel Design"I'm not stupid, I'm from Sweden" - Unknown
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
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
"- To begin with, said the Cat, a dog's not mad. You grant that? - I suppose so, said Alice. - Well, then, - the Cat went on - you see, a dog growls when it's angry, and wags its tail when it's pleased. Now I growl when I'm pleased, and wag my tail when I'm angry. Therefore I'm mad."
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement