Adding Watermark to your PictureBox

Watermark is a faint picture or mark made in some paper during manufacture, which is visible when held against the light and typically identifies the maker, it a special design contained in electronic documents, pictures, music etc that is used to stop people from copying them. In this tutorial, we will make a watermark program created in VB.NET! Follow the following steps: 1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application. 2. Next, add one PictureBox named PictureBox1 and upload your desired image. Add a TextBox named TextBox1 so that the text that we have inputted from out TextBox will be displayed as our watermark in the PictureBox. Then add a Button named Button1. Design your layout like the image below: design 4. Now, put this code in Button1_Click. This will trigger to put the text you have inputted in your TextBox to be displayed in your PictureBox.
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. Dim font As New Font("Arial", 36, FontStyle.Italic)
  3. Dim brush As New SolidBrush(Color.FromArgb(64, 192, 255, 255))
  4. brush.Color = Color.FromArgb(128, 0, 0, 0)
  5. PictureBox1.CreateGraphics.DrawString(TextBox1.Text, font, brush, 15, 135)
  6. End Sub

Explanation:

We initialized variable font that contains a font type of Arial, font size of 36, and font style of italic. We used the SolidBrush class that passed its value into variable brush. This SolidBrush class defines a brush of a single color. Brushes are used to fill graphics shapes, such as rectangles, ellipses, pies, polygons, and paths. This class cannot be inherited. Then we have this color from our RGB color of (128, 0, 0, 0). Then, it will create a watermark image with the use of our code  PictureBox1.CreateGraphics.DrawString(TextBox1.Text, font, brush, 15, 135) as it draws the string in our inputted textbox, the font we have initialized and its brush, the left location of 15, and the top location of 135.

Output:

output Download the source code below and try it! :) For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below. Best Regards,

Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
Mobile: 09079373999
Telephone: 826-9296
E-mail:[email protected]

Visit and like my page on Facebook at: Bermz ISware Solutions

Subscribe at my YouTube Channel at: SerBermz

Add new comment