Delphi/Lazarus: Write text with transparent background on canvas
Tutorial by Guest | Last update on 2021-06-13 | Created on 2014-06-01
Using the function Canvas.TextOut(X, Y, 'Text') I can write an arbitrary text onto the canvas of a bitmap (TBitmap) or a form without any problems.
However, the problem is, that there is automatically drawn a colored background behind the text. It is looking like as if the text was written into a box which is hiding the real background of the canvas.
I can adjust the color for this background using the property Canvas.Brush.Color, but there are enough situations in which this is not suitable. For example whenever I want to write some text on an image or any color gradient. In all of those cases, the colored background is looking very unprofessional.
Therefore, is there any possibility to output the text with a transparent background onto of the canvas?
About the Author
The author has not added a profile short description yet.
Show Profile
Related Topics
jQuery: Send HTML5 Canvas to Server via Ajax
Tutorial | 0 Comments
Send HTML5 Canvas as Image to Server
Tutorial | 0 Comments
HTML5 Canvas: Beginner Tutorial Chapter 1 - Introduction and Basics
Tutorial | 0 Comments
HTML5 Canvas: Beginner Tutorial Chapter 4 - Write Text on Canvas
Tutorial | 0 Comments
HTML5 Canvas: Beginner Tutorial Chapter 3 - Rectangles and Circles
Tutorial | 0 Comments
How to resize Image before Upload in Browser
Tutorial | 13 Comments
HTML5 Canvas: Beginner Tutorial Chapter 2 - Drawing Lines
Tutorial | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
If you want to write the text with a transparent background, you can set the Brush-Style to bsClear before:
With this, you should be able to write your text without any problems on backgrounds that are not consisting of only one color.
Last update on 2021-06-13 | Created on 2014-06-01