How to Invert an Image in Picturebox using VB.Net

0
99

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.
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. Dim pic As New Bitmap(PictureBox1.Image)
  3. For y As Integer = 0 To pic.Height - 1
  4. For x As Integer = 0 To pic.Width - 1
  5. Dim inv As Color = pic.GetPixel(x, y)
  6. inv = Color.FromArgb(255, 255 - inv.R, 255 - inv.G, 255 - inv.B)
  7. pic.SetPixel(x, y, inv)
  8. PictureBox2.Image = pic
  9. Next x
  10. Next y
  11. End Sub
  • 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 Code Here

 

 

Readers might read also:

 

 

Facebook Comments
(Visited 111 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here