Results 1 to 4 of 4

Thread: DirectX Colorkey transparencies

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    15

    Question 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~

  2. #2
    Addicted Member
    Join Date
    Jan 2001
    Location
    Little Rock, Ar
    Posts
    151
    try some thing like this
    Code:
    ckey.high = vbGreen
    ckey.low = vbGreen

  3. #3
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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)

  4. #4
    Addicted Member
    Join Date
    Jan 2001
    Location
    Little Rock, Ar
    Posts
    151
    Try something like this...

    VB Code:
    1. Dim tColor As Long
    2.     Dim ckey As DDCOLORKEY
    3.     ddsd.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH
    4.     ddsd.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
    5.     Set dds = dd.CreateSurfaceFromFile(Path, ddsd) 'load the surface
    6.     tColor = dds.GetLockedPixel(0, 0) 'get the first pixel
    7.     ckey.high = tColor
    8.     ckey.low = tColor
    9.     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
  •  



Click Here to Expand Forum to Full Width