Results 1 to 4 of 4

Thread: Choosing DX transparency color?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2001
    Posts
    421

    Choosing DX transparency color?

    How can I pick the color I want to be transparent in my sprites besides black? I've seen people that have white backgrounds, and they must have chosen white as their transparent color. It has something to do with .low and .high so what do I set them as? Thanks.
    [vbcode]
    ' comment
    Rem remark
    [/vbcode]

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    In 8, 24 and 32 bit colour mode, set them to RGB(255, 255, 255), which is pure white. In 16 bit I'm not sure what you're supposed to set it to...
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    I think the easy way to do this across all color modes is to get the value of the pixel located at 0, 0 once you load one of your images and use the returned value as your color key.

    VB Code:
    1. '...............................................................
    2. Dim ck as DDCOLORKEY, lngTransCol as Long
    3.  
    4. ' create surface and load picture that uses desired trans. color
    5. Set surfOut = DD7.CreateSurfaceFromFile(pFile, ddsd)
    6.  
    7. lngTransCol = GetPixelColor(surfOut, 0, 0)
    8.  
    9. ck.low = lngTransCol
    10. ck.high = lngTransCol
    11.  
    12. '......................................................
    13.  
    14. Public Function GetPixelColor(pSurf As DirectDrawSurface7, pX As Integer, pY As Integer) As Long
    15. Dim rEmpty As RECT
    16. Dim ddsd As DDSURFACEDESC2
    17.  
    18.     pSurf.GetSurfaceDesc ddsd
    19.  
    20.     ' lock the surface to gain direct access to memory
    21.     pSurf.Lock rEmpty, ddsd, DDLOCK_WAIT, vbNull
    22.    
    23.     ' get the color value of the pixel
    24.     GetPixelColor = pSurf.GetLockedPixel(pX, pY)
    25.    
    26.     pSurf.Unlock rEmpty
    27.  
    28. End Function
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2001
    Posts
    421
    It worked, thanks guys.
    [vbcode]
    ' comment
    Rem remark
    [/vbcode]

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