Archived

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

Drawing a Transparent Bitmap using Windows API

This topic is 5516 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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