Public Class Form1
Dim gambar2 As Bitmap
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PictureBox2.Image = PictureBox1.Image
End Sub
Private Sub btngrayscale_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btngrayscale.Click
Dim Pb, Pc As Integer
Dim Rt, vM, vH, vB As Double
gambar2 = New Bitmap(PictureBox2.Image)
For Pb = 0 To gambar2.Height - 1
For Pc = 0 To gambar2.Width - 1
vM = gambar2.GetPixel(Pc, Pb).R
vH = gambar2.GetPixel(Pc, Pb).G
vB = gambar2.GetPixel(Pc, Pb).B
Rt = (vM + vH + vB) / 3
gambar2.SetPixel(Pc, Pb, Color.FromArgb(Rt, Rt, Rt))
Next
PictureBox2.Image = gambar2
PictureBox2.Refresh()
Next
End Sub
End Class
Dim gambar2 As Bitmap
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PictureBox2.Image = PictureBox1.Image
End Sub
Private Sub btngrayscale_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btngrayscale.Click
Dim Pb, Pc As Integer
Dim Rt, vM, vH, vB As Double
gambar2 = New Bitmap(PictureBox2.Image)
For Pb = 0 To gambar2.Height - 1
For Pc = 0 To gambar2.Width - 1
vM = gambar2.GetPixel(Pc, Pb).R
vH = gambar2.GetPixel(Pc, Pb).G
vB = gambar2.GetPixel(Pc, Pb).B
Rt = (vM + vH + vB) / 3
gambar2.SetPixel(Pc, Pb, Color.FromArgb(Rt, Rt, Rt))
Next
PictureBox2.Image = gambar2
PictureBox2.Refresh()
Next
End Sub
End Class