Archived

This topic is now archived and is closed to further replies.

FrancoisSoft

Drawing a Transparent Bitmap using Windows API

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites