how to overlay text colour and image colour to create overlay combined colour

Posted on 2014-08-20
Last Modified: 2014-08-21
When combining a text overpay on an existing image in .net c# with graphic.draw method
how do you add text on top of the image that when the text overlaps the image it creates a font colour
which is a combination colour of the underlaying image and the font colour

so if image was black and text on top was white the overlaying area of text on top of image would be grey!

thanks for your help
Question by:stephenwilde
    LVL 40

    Accepted Solution

    Create a SolidBrush that has transparency and use it as the Brush in you draw:
    Dim myBrush As SolidBrush = New SolidBrush(Color.FromArgb(200, Color.White))
    e.Graphics.FillRectangle(Brushes.Black, New Rectangle(20, 20, 20, 20))
    e.Graphics.DrawString("Test", New Font("Arial", 20, FontStyle.Bold), myBrush, New Point(10, 10))

    Open in new window

    The first parameter of FromArgb controls the transparency. It can be a value between 0 and 250. 0 is completely transparent, 255 is completely opaque.

    Author Closing Comment

    Thank you for the solution, code and explanation.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    755 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now