-
transparentcy directx7
hey everyone,
ive just started using directx7. ive been blt'ing pics in a fullscreen environment. i was wondering how i could for example, have a background image taking up the whole screen then have another image over the top of it with transparentcies as so i can see through to the background image...if that made sense...
any help would be muchly appreciated
thanks dudes
tim:D
-
just to add to that. in other words how do i get an image to have transparentcies? would i have to set one colour to be transparent or something?..
-
What you do is use the Colourkey. More can be found at http://www.directx4vb.com/; there's a whole tutorial (I think) dedicated to it.
-
thanks dude,
i read the tutorial, its pretty confusing and in the end doesnt really address the issue of making something 'transparent'. also i read:
'So now you can key out any color in 16-bit, and not just black, white, and magenta.'
black white or magnetta or anything would be cool...i just need a colour to be transparent. im still stumped on HOW to do it... mabe it was in the tutorial, but i didnt find anything.. :confused:
i dunno, im just confused.
thanks anyways
tim:D
-
If I remember correctly you do something like this:
1. Create a colourkey object (should be in that tutorial).
2. Set it's .low and .high both to 0 (for BLACK).
3. Use the Surface's method to set this colourkey.
4. Blit it with the colourkey flag on.
-
awsome, thanks heaps dude:D
-
ive done this code here but it doesnt seem to be working...
i used another tut as a guide, its not very clear either...
Set SURF_tsetup = Nothing
ddsd_tsetup.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH
ddsd_tsetup.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
ddsd_tsetup.lWidth = 90
ddsd_tsetup.lHeight = 30
SURF_tsetup.GetPixelFormat pf
CKey.low = 0 'black
CKey.high = 0
SURF_tsetup.SetColorKey DDCKEY_SRCBLT, CKey
Set SURF_tsetup = dd.CreateSurfaceFromFile(App.Path & "\image\tsetup.bmp", ddsd_tsetup)
then when im blt'ing:
ddrval = backbuffer.BltFast(0, 0, SURF_tsetup, RECT_tsetup, DDBLTFAST_SRCCOLORKEY)
i dont know if this is right but it isnt working.... :confused:
thanks anyways
tim:D
-
Try calling the SetColorKey function after you create the surface. Also, you can specify the color key in the surface description before calling the create surface function.
-
thanks Machaira, i tried the first sentence and that didnt work... and i dont really know what your trying to say in the 2nd sentence... also i know which lines it is thats screwing it up,
when i commented out:
SURF_tsetup.GetPixelFormat pf
CKey.low = 0 'black
CKey.high = 0
SURF_tsetup.SetColorKey DDCKEY_SRCBLT, CKey
it seemed to work, but without my transparent image...
im stumped
thanks anyway for the help people
tim:D
-
ok, problem fixed. turns out i didnt have this line here..
Dim CKey As DDCOLORKEY
duh..
and i didnt need that 'SURF_tsetup.GetPixelFormat pf' line either, no idea what it does, but its gone...
but yea thanks for all the help anyways Sastraxi and Machaira
later
tim:D
-
A good reason to always use Option Explicit in all of your form's and modules.