[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 306
  • Last Modified:

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

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
0
stephenwilde
Asked:
stephenwilde
1 Solution
 
Jacques Bourgeois (James Burger)Commented:
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.
0
 
stephenwildeAuthor Commented:
Thank you for the solution, code and explanation.
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now