Skip to main content
GameDev.net gamedev.net
🔒 Locked

Drawing a Transparent Bitmap using Windows API

Started by FrancoisSoft Nov 5, 2002 at 3:16 PM 5 replies 3.4k views
Original Post
FrancoisSoft
FrancoisSoft
How do you draw a transparent bitmap using Windows API or some other API? I mean I want the bitmap to overlap another one but I want the bitmap to be "clear" so that I can see through it.
PiXeLatiOn
PiXeLatiOn
Using win32 api , you would use Bitblt , using a graphics API , there is much to cover
-Da Mr.RaSt3RiZah-
krez
krez
there is a technique called "masking", which blits a "mask" (black and white version of the image), and then the image itself... this gives the effect you want.
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
FrancoisSoft
FrancoisSoft
Can you explain more about this masking in terms of code. Please tell me what function I would call and what parameters I would pass to it.
krez
krez
well, although my memory sucks, i''ll try:

look up BitBlt() on MSDN or a win32 API help file or something, it will explain the arguments to pass to the function, and what they do.

now, what you need to get a transparent sprite is the image (any transparent part must be black for this method to work) and a copy of the image that is black and white. anything you want to be drawn from this image, you make black; any parts that should be transparent you make white.

now, you bitblt the mask (black and white image) wherever you want the sprite, using the AND raster-op (these are explained in the documents); this "cuts out" a hole for your non-transparent parts without harming the rest of the background. then, you bitblt the color image directly over that with the OR raster-op; this combines the image with the background.

HTH.
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.