|
-
Oct 14th, 2001, 09:04 AM
#1
Thread Starter
New Member
DirectX Colorkey transparencies
I'm currently trying to make an isometric game engine in Visual Basic using DirectDraw 7 for the graphics.
To make a sprite transparent, the colorkey is defined in this way. This makes any parts of the image that are black appear transparent when blitted.
Code:
Dim key As DDCOLORKEY
key.low = 0
key.high = 0
spritesurf.SetColorKey DDCKEY_SRCBLT, key
I however, rather like the color black and would rather have the transparent color be the wretched bright green RGB(0,255,0) or even better yet, I would prefer the transparent color to be determined by the upper left hand corner pixel in the sprite. I can't seem to figure out how to set the keycolor to that green though and any attempts at that other automated trick have failed horribly.
Has anyone ever done something like this with DirectDraw 7? If you have, could you please give me some insight into the matter.
~Stoinker~
-
Oct 16th, 2001, 11:28 AM
#2
Addicted Member
try some thing like this
Code:
ckey.high = vbGreen
ckey.low = vbGreen
-
Oct 16th, 2001, 03:22 PM
#3
Good Ol' Platypus
The good thing is that wretched green is the same in 16- 24- and 32-bit colour... here it is:
Const TransCol = (0 * 0) + (255 * 256) + (0 * 65536)
That's, in a nutshell, what the RGB function does.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Oct 16th, 2001, 07:11 PM
#4
Addicted Member
Try something like this...
VB Code:
Dim tColor As Long
Dim ckey As DDCOLORKEY
ddsd.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH
ddsd.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
Set dds = dd.CreateSurfaceFromFile(Path, ddsd) 'load the surface
tColor = dds.GetLockedPixel(0, 0) 'get the first pixel
ckey.high = tColor
ckey.low = tColor
dds.SetColorKey DDCKEY_SRCBLT, ckey
Let me know if this works!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|