How to Invert an Image in Picturebox using VB.Net

This tutorial is all about How to Invert an Image in Picturebox using VB.Net. In this post i will teach you How to Invert an Image in Picturebox using VB.Net. So let’s get started:

As a continuation of this tutorial. We will use the How to Add Watermark to a Picture using VB.Net.

  • First, Design your Form like this one below.
    Add 2 PictureBox and a Button.

  • After designing the form. Click the Button and add this following codes.

[vbnet]

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim pic As New Bitmap(PictureBox1.Image)
For y As Integer = 0 To pic.Height – 1
For x As Integer = 0 To pic.Width – 1
Dim inv As Color = pic.GetPixel(x, y)
inv = Color.FromArgb(255, 255 – inv.R, 255 – inv.G, 255 – inv.B)
pic.SetPixel(x, y, inv)
PictureBox2.Image = pic
Next x
Next y
End Sub

[/vbnet]

  • Then Click F5 to Run the Program.
    Output:

If you have any comments or suggestions about on How to Invert an Image in Picturebox using VB.Net please feel free to contact our webpage.

Download Source Code! Here

Readers might read also:

Leave a Comment