DirectX:DirectDraw:Tutorials:VB:DX7:Easy Transparency
From GPWiki(Redirected from VB:DX7 Easy Transparency)
The wiki is now hosted by GameDev.NET at wiki.gamedev.net. All gpwiki.org content has been moved to the new server. However, the GPWiki forums are still active! Come say hello. [edit] Direct Draw Colour Transparency Made EasyWhatever the mind can conceive and believe it can achieve. Now, at some stage you've wanted to make something in DirectDraw transparent, normally, you'd have to make sure that something easy to colour key, like black, was your transparent colour, even getting magenta as your transparent colour is a pain. But, there is an easier way, where you let DirectDraw do the dirty work for you. There are two ways of implementing this solution: Then once you've done either of these two things you just add this code in: Dim ccGeneric As DDCOLORKEY, rectEmpty as RECT 'Set the colour key msurfNPC(i).Lock rectEmpty, ddsdGeneric, DDLOCK_WAIT, 0 'replace x,y with pixel co-ordinates of a pixel containing 'the colour you want to make transparent ccGeneric.high = msurfNPC(i).GetLockedPixel(X,Y) ccGeneric.low = ccGeneric.high msurfNPC(i).Unlock rectEmpty msurfNPC(i).SetColorKey DDCKEY_SRCBLT, ccGeneric I really like this way because it will work no matter what bit-depth the program is running at, and no matter what type of graphics card your user has (some graphics cards have strange colour modes) --IGTHORN |


