Anda di halaman 1dari 8

Program Pengolahan Citra Didalam Menu

Dengan Menggunakan Visual Basic.Net


2008

Keterangan :
1) Form 1 (Form Login)

2) Form 2 (Form Menu)

3) Form 3 (Form Pengolahan Citra)

Baiklah Sobat Saya Sekalian Langsung Saja Kita Membuat Form Login Dengan Mendisain
Form Seperti Gambar Di Bawah Ini :
# Listing Program :
1). Klik Double Bebas Pada Form Dan Isikan Printah
Public Class Form1

Private Sub Form2_Load(Byval Sender As System.Object,


Byval E As System.Eventargs) Handles Mybase.Load
Password.Passwordchar = "*"
End Sub
2) Klik Double Pada Button Ok Dan Isikan Printah
Private Sub Button2_Click(Byval Sender As System.Object, Byval
E As System.Eventargs) Handles Button2.Click
If User.Text = "" Or Password.Text = "" Then
Msgbox("Maaf, Username Dan Password Belum Di
Input!!")
User.Focus()
Elseif User.Text = "Awal" And Password.Text = "123"
Then
Msgbox("Welcome To Menu Utama :-)")
Form2.Show()
Me.Hide()
Else
Msgbox("Maaf, Username Dan Password Salah!")
User.Text = ""
Password.Text = ""
User.Focus()
End If
End Sub

3)Klik Double Pada Textbox Password Untuk Menggunakan Keypress


Caranya Dengan Mengubah Textchanged Menjadi Keypress,Dan
Isikan Printah
Private Sub Password_Keypress(Byval Sender As Object, Byval E
As System.Windows.Forms.Keypresseventargs) Handles
Password.Keypress
If Asc(E.Keychar) = 13 Then
If User.Text = "Awal" And Password.Text = "123"
Then
Msgbox("Welcome :-)")
Form3.Show()
Me.Hide()
Else
Msgbox("Sorry :-( Password And Username No
Valid Tryagain!!")
User.Text = ""
Password.Text = ""
End If
End If
End Sub
4) Klik Double Pada Button Keluar Isikan Printah
Private Sub Button1_Click(Byval Sender As System.Object, Byval
E As System.Eventargs) Handles Button1.Click
Me.Close()
End Sub
End Class

Selanjutnya Sobat Membuat Form Menu Dengan Gambar Di Bawah Ini :

# Listing Program :
1). Membuat Menu File Kita Harus Menambahkan Menustrip Pada Kotak Toolbox
Dan Isikan Kolom
1) File
2) Pegolahan Citra
3) Keluar

Lebih Jelas Lihat Gambar Di Bawah Ini :

2) Selanjutnya Klik Double Menu Pencitraan Dan Isikan Printah


Public Class Form2

Private Sub Pencitraantoolstripmenuitem_Click(Byval Sender


As System.Object, Byval E As System.Eventargs) Handles
Pencitraantoolstripmenuitem.Click
Form3.Mdiparent = Me
Form3.Show()
End Sub
4) Selanjutnya Klik Double Menu Keluar Dan Isikan Printah
Private Sub Keluartoolstripmenuitem_Click(Byval Sender As
System.Object, Byval E As System.Eventargs) Handles
Keluartoolstripmenuitem.Click
End
End Sub
End Class

Setelah Selesai Mendisain Kedua Form Tersebut Dan Yang Terahir


Kita Membuat Form Pengolahan Citra Seperti Gambar Di Bawah Ini
:

# Listing Program :
1).Cara Memasukkan Gambar Di Dalam Picturebox Ialah
- Kotak Properties-Pilih Image
- Cukup Satu Picturebox Saja Yang Di Isi..Okeyy :-D
2). Isikan Printah Di Dalam Button –Hijau :
Private Sub Button1_Click(Byval Sender As System.Object, Byval
E As System.Eventargs) Handles Button1.Click
Dim Pb, Pc As Integer
Dim 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 - 10
Vh = Gambar2.Getpixel(Pc, Pb).G
Vb = Gambar2.Getpixel(Pc, Pb).B
If Vm <= 0 Then Vm = 0
Gambar2.Setpixel(Pc, Pb, Color.Fromargb(Vm,
Vh, Vb))
Next
Picturebox2.Image = Gambar2
Picturebox2.Refresh()
Next
End Sub
3). Isikan Printah Di Dalam Button +Hijau :
Private Sub Button2_Click(Byval Sender As System.Object, Byval
E As System.Eventargs) Handles Button2.Click
Dim Pb, Pc As Integer
Dim 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 + 10
Vh = Gambar2.Getpixel(Pc, Pb).G
Vb = Gambar2.Getpixel(Pc, Pb).B
If Vm >= 255 Then Vm = 255
Gambar2.Setpixel(Pc, Pb, Color.Fromargb(Vm,
Vh, Vb))
Next
Picturebox2.Image = Gambar2
Picturebox2.Refresh()
Next
End Sub

4). Isikan Printah Di Dalam Button Grayscale :


Public Class Form3
Dim Gambar2 As Bitmap

Private Sub Button3_Click(Byval Sender As System.Object,


Byval E As System.Eventargs) Handles Button3.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

5). Isikan Printah Di Dalam Button -Merah :


Private Sub Button4_Click(Byval Sender As System.Object, Byval
E As System.Eventargs) Handles Button4.Click
Dim Pb, Pc As Integer
Dim 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 + 5
Vh = Gambar2.Getpixel(Pc, Pb).G + 5
Vb = Gambar2.Getpixel(Pc, Pb).B + 5
If Vm >= 255 Then Vm = 255
If Vb >= 255 Then Vb = 255
If Vh >= 255 Then Vh = 255
Gambar2.Setpixel(Pc, Pb, Color.Fromargb(Vm,
Vh, Vb))
Next
Picturebox2.Image = Gambar2
Picturebox2.Refresh()
Next
End Sub
6). Isikan Printah Di Dalam Button +Merah :
Private Sub Button5_Click(Byval Sender As System.Object, Byval
E As System.Eventargs) Handles Button5.Click
Dim Pb, Pc As Integer
Dim 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 - 5
Vh = Gambar2.Getpixel(Pc, Pb).G - 5
Vb = Gambar2.Getpixel(Pc, Pb).B - 5
If Vm <= 0 Then Vm = 0
If Vb <= 0 Then Vb = 0
If Vh <= 0 Then Vh = 0
Gambar2.Setpixel(Pc, Pb, Color.Fromargb(Vm,
Vh, Vb))
Next
Picturebox2.Image = Gambar2
Picturebox2.Refresh()
Next
End Sub
7). Isikan Printah Di Dalam Button Rotate :
Private Sub Button6_Click(Byval Sender As System.Object, Byval
E As System.Eventargs) Handles Button6.Click
Dim Pb, Pc As Integer
Dim Vm, Vh, Vb As Double
Gambar2 = New Bitmap(Picturebox2.Image)
Dim Gambar3 As Bitmap = New Bitmap(Picturebox1.Image)
For Pb = Gambar2.Height - 1 To 0 Step -1
For Pc = Gambar2.Width - 1 To 0 Step -1
Vm = Gambar2.Getpixel(Pc, Pb).R
Vh = Gambar2.Getpixel(Pc, Pb).G
Vb = Gambar2.Getpixel(Pc, Pb).B
Gambar3.Setpixel(Gambar2.Width - 1 - Pc,
Gambar2.Height - 1 - Pb, Color.Fromargb(Vm, Vh, Vb))
Next
Picturebox2.Image = Gambar3
Picturebox2.Refresh()
Next
End Sub

8). Isikan Printah Di Dalam Button -Britness :

Private Sub Button7_Click(Byval Sender As System.Object,


Byval E As System.Eventargs) Handles Button7.Click
Dim Pb, Pc As Integer
Dim 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 - 10
Vb = Gambar2.Getpixel(Pc, Pb).B
If Vh <= 0 Then Vh = 0
Gambar2.Setpixel(Pc, Pb, Color.Fromargb(Vm,
Vh, Vb))
Next
Picturebox2.Image = Gambar2
Picturebox2.Refresh()
Next
End Sub
8). Isikan Printah Di Dalam Button +Britness :
Private Sub Button8_Click(Byval Sender As System.Object, Byval
E As System.Eventargs) Handles Button8.Click
Dim Pb, Pc As Integer
Dim 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 + 10
Vb = Gambar2.Getpixel(Pc, Pb).B
If Vh >= 255 Then Vh = 255
Gambar2.Setpixel(Pc, Pb, Color.Fromargb(Vm,
Vh, Vb))
Next
Picturebox2.Image = Gambar2
Picturebox2.Refresh()
Next
End Sub
9). Isikan Printah Di Dalam Button Negativ :
Private Sub Button9_Click(Byval Sender As System.Object, Byval
E As System.Eventargs) Handles Button9.Click
Dim Pb, Pc As Integer
Dim 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 = 255 - Gambar2.Getpixel(Pc, Pb).R
Vh = 255 - Gambar2.Getpixel(Pc, Pb).G
Vb = 255 - Gambar2.Getpixel(Pc, Pb).B
If Vm <= 0 Then Vm = 0
If Vb <= 0 Then Vb = 0
If Vh <= 0 Then Vh = 0
Gambar2.Setpixel(Pc, Pb, Color.Fromargb(Vm,
Vh, Vb))
Next
Picturebox2.Image = Gambar2
Picturebox2.Refresh()
Next
End Sub

10). Isikan Printah Di Dalam Button Selesai :


Private Sub Button10_Click(Byval Sender As System.Object,
Byval E As System.Eventargs) Handles Button10.Click
End
End Sub
End Class