Results 1 to 11 of 11

Thread: transparentcy directx7

  1. #1

    Thread Starter
    Junior Member timmy's Avatar
    Join Date
    Nov 2001
    Location
    qld aus
    Posts
    23

    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

  2. #2

    Thread Starter
    Junior Member timmy's Avatar
    Join Date
    Nov 2001
    Location
    qld aus
    Posts
    23
    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?..

  3. #3
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  4. #4

    Thread Starter
    Junior Member timmy's Avatar
    Join Date
    Nov 2001
    Location
    qld aus
    Posts
    23
    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..

    i dunno, im just confused.

    thanks anyways
    tim

  5. #5
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  6. #6

    Thread Starter
    Junior Member timmy's Avatar
    Join Date
    Nov 2001
    Location
    qld aus
    Posts
    23
    awsome, thanks heaps dude

  7. #7

    Thread Starter
    Junior Member timmy's Avatar
    Join Date
    Nov 2001
    Location
    qld aus
    Posts
    23
    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....

    thanks anyways
    tim

  8. #8
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    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.

  9. #9

    Thread Starter
    Junior Member timmy's Avatar
    Join Date
    Nov 2001
    Location
    qld aus
    Posts
    23
    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

  10. #10

    Thread Starter
    Junior Member timmy's Avatar
    Join Date
    Nov 2001
    Location
    qld aus
    Posts
    23
    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

  11. #11
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    A good reason to always use Option Explicit in all of your form's and modules.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width