Does GDI supports semi-transparency?

Posted on 2009-04-18
Medium Priority
Last Modified: 2013-11-20
I'm using visual c++ 2005 with MFC.

I would like to draw a shape, a bitmap etc in half transparancy, i.e. in such a way that we should still be able to see whatever is beneath the shape.
Does GDI supports semi-transparency (real-time alpha blending)?

Question by:netformx
  • 2
  • 2
LVL 86

Accepted Solution

jkr earned 2000 total points
ID: 24175966
>>Does GDI supports semi-transparency (real-time alpha blending)?

Yes. The API you need is 'SetLayeredWindowAttributes()' (http://msdn.microsoft.com/en-us/library/ms633540(VS.85).aspx). See e.g.

http://www.codeproject.com/KB/winsdk/trans.aspx ("Transparency without Source Code")
http://www.codeproject.com/KB/dialog/wintrans1.aspx ("Making any application transparent in Windows 2000/XP")

Author Comment

ID: 24176060
Not sure this is what I was looking for.
How would you suggest to draw a semi-transparnt shape on top of other opaque shapes?
Should I create a differnt window for the semi-transparent shape and then use API function SetLayeredWindowAttributes?

Thanks in advance.
LVL 86

Expert Comment

ID: 24176257
If your focus is transparent bitmaps or regions, you might be better off with http://www.codeproject.com/KB/graphics/transbitmapmask.aspx ("Drawing Transparent Bitmap with ease with on the fly masks in MFC") or a ready-made control like http://www.codeproject.com/KB/static/LayeredBitmapCtrl1.aspx ("CLayeredBitmapCtrl")

Author Comment

ID: 24177874
both examples refer to full-transparency (i.e. bitmaps that are partialy opaque and partialy fully-transparent using a 1/0 mask).
I know this is feasible but my question refers to semi-transparency. See attached example.


Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month14 days, 21 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question