Jump to content
  • Advertisement

Archived

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

FrancoisSoft

Drawing a Transparent Bitmap using Windows API

This topic is 5795 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

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
Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!