Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Setting a Mask Colour


Harris6310
 Share

Recommended Posts

I was wondering how I could set the transparency mask colour to just plain white instead of the top left pixel. I found the right sub-routine, how would I change it?

```
' This sub gets the mask color from the surface loaded from a bitmap image
Public Sub SetMaskColorFromPixel(ByRef TheSurface As DirectDrawSurface7, ByVal x As Long, ByVal y As Long)
Dim TmpR As RECT
Dim TmpDDSD As DDSURFACEDESC2
Dim TmpColorKey As DDCOLORKEY

    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    With TmpR
        .Left = x
        .top = y
        .Right = x
        .Bottom = y
    End With

    TheSurface.Lock TmpR, TmpDDSD, DDLOCK_WAIT Or DDLOCK_READONLY, 0

    With TmpColorKey
        .Low = TheSurface.GetLockedPixel(x, y)
        .High = .Low
    End With

    TheSurface.SetColorKey DDCKEY_SRCBLT, TmpColorKey
    TheSurface.Unlock TmpR

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "SetMaskColorFromPixel", "modDirectDraw7", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub

```
Link to comment
Share on other sites

@Noth:

> Change
> ```
> With TmpColorKey
>         .Low = TheSurface.GetLockedPixel(x, y)
>         .High = .Low
>     End With
>
> ```
> To
> ```
> With TmpColorKey
>         .Low = RGB(255, 255, 255)
>         .High = .Low
>     End With
>
> ```

That simple, eh? Thanks for your help.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...