a.Grayscale/rotate 180
Private Sub grayscale_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles grayscale.Click
Dim rt, pc, pb As Integer
Dim vm, vh, vb As Integer
Dim gambar2 As Bitmap
picture2.Image = picture1.Image
gambar2 = New Bitmap(picture2.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
Next
picture2.Image = gambar2
picture2.Refresh()
End Sub
If gambar IsNot Nothing Then
gambar.RotateFlip(RotateFlipType.Rotate180FlipX)
picture2.Image = gambar
End If
End Sub
b.Contranst/Rotate 90
If picture2.Image Is Nothing Then
MsgBox("WARNING : Tidak ada gambar untuk di konversi!")
Exit Sub
End If
gambar = New Bitmap(picture2.Image)
picture2.Image = gambar
Dim tempbmp As New Bitmap(picture2.Image)
Dim pb As Integer = 1
Dim pc As Integer = 1
Dim Red, Green, Blue As Integer
Dim X, Y As Integer
Dim r As Integer
r = 5
With tempbmp
For X = pb To .Height - pb - 1
For Y = pc To .Width - pc - 1
Red = CInt(.GetPixel(Y, X).R)
Green = CInt(.GetPixel(Y, X).G)
Blue = CInt(.GetPixel(Y, X).B)
'Grey = (Red + Green + Blue) / 3 'konversi warna pada pixel Y,X ke grey
Red = Red * r
Blue = Blue * r
Green = Green * r
If (Red > 255) Then
Red = 255
End If
If (Blue > 255) Then
Blue = 255
End If
If (Green > 255) Then
Green = 255
End If
gambar.SetPixel(Y, X, Color.FromArgb(Red, Green, Blue))
Next
If X Mod 10 = 0 Then
picture2.Invalidate()
picture2.Refresh()
End If
Next
End With
End Sub
Private Sub ToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem2.Click
If gambar IsNot Nothing Then
gambar.RotateFlip(RotateFlipType.Rotate90FlipXY)
picture2.Image = gambar
End If
End Sub
c.Negatif/Rotate 270
Dim pb, pc As Integer
Dim vm, vh, vb As Double
With gambar
For pb = 0 To .Height - 1
For pc = 0 To .Width - 1
vm = 255 - .GetPixel(pc, pb).R
vh = 255 - .GetPixel(pc, pb).G
vb = 255 - .GetPixel(pc, pb).B
If vm <= 0 Then vm = 0
If vb <= 0 Then vb = 0
If vh <= 0 Then vh = 0
.SetPixel(pc, pb, Color.FromArgb(vm, vh, vb))
Next
picture2.Image = gambar
picture2.Refresh()
Next
End With
End Sub
d. Biner
Dim pb, pc As Integer
Dim rata, vm, vh, vb As Double
With gambar
For pb = 0 To .Height - 1
For pc = 0 To .Width - 1
vm = .GetPixel(pc, pb).R
vh = .GetPixel(pc, pb).G
vb = .GetPixel(pc, pb).B
rata = (vm + vh + vb) / 3
If (rata < 128) Then
vm = 0
vh = 0
vb = 0
Else
vm = 255
vh = 255
vb = 255
End If
.SetPixel(pc, pb, Color.FromArgb(vm, vh, vb))
Next
picture2.Image = gambar
picture2.Refresh()
Next
End With
End Sub
Private Sub OpenCitraToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenCitraToolStripMenuItem.Click
OFD.Filter = "BMP|*.bmp|JPG|*.jpg"
OFD.ShowDialog()
If OFD.FileName = "" Then Exit Sub
picture1.Image = Image.FromFile(OFD.FileName)
gambar = New Bitmap(picture1.Image)
'menuutama.MdiParent = Me
'menuutama.Show()
End Sub
e. Brigthness
Private Sub BrigthnessToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BrigthnessToolStripMenuItem.Click
Dim pb, pc As Integer
Dim vm, vh, vb As Double
With gambar
For pb = 0 To .Height - 1
For pc = 0 To .Width - 1
vm = .GetPixel(pc, pb).R + 5
vh = .GetPixel(pc, pb).G + 5
vb = .GetPixel(pc, pb).B + 5
If vm > 255 Then vm = 255
If vb > 255 Then vb = 255
If vh > 255 Then vh = 255
.SetPixel(pc, pb, Color.FromArgb(vm, vh, vb))
Next
picture2.Image = gambar
picture2.Refresh()
Next
End With
End Sub
Private Sub grayscale_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles grayscale.Click
Dim rt, pc, pb As Integer
Dim vm, vh, vb As Integer
Dim gambar2 As Bitmap
picture2.Image = picture1.Image
gambar2 = New Bitmap(picture2.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
Next
picture2.Image = gambar2
picture2.Refresh()
End Sub
If gambar IsNot Nothing Then
gambar.RotateFlip(RotateFlipType.Rotate180FlipX)
picture2.Image = gambar
End If
End Sub
b.Contranst/Rotate 90
If picture2.Image Is Nothing Then
MsgBox("WARNING : Tidak ada gambar untuk di konversi!")
Exit Sub
End If
gambar = New Bitmap(picture2.Image)
picture2.Image = gambar
Dim tempbmp As New Bitmap(picture2.Image)
Dim pb As Integer = 1
Dim pc As Integer = 1
Dim Red, Green, Blue As Integer
Dim X, Y As Integer
Dim r As Integer
r = 5
With tempbmp
For X = pb To .Height - pb - 1
For Y = pc To .Width - pc - 1
Red = CInt(.GetPixel(Y, X).R)
Green = CInt(.GetPixel(Y, X).G)
Blue = CInt(.GetPixel(Y, X).B)
'Grey = (Red + Green + Blue) / 3 'konversi warna pada pixel Y,X ke grey
Red = Red * r
Blue = Blue * r
Green = Green * r
If (Red > 255) Then
Red = 255
End If
If (Blue > 255) Then
Blue = 255
End If
If (Green > 255) Then
Green = 255
End If
gambar.SetPixel(Y, X, Color.FromArgb(Red, Green, Blue))
Next
If X Mod 10 = 0 Then
picture2.Invalidate()
picture2.Refresh()
End If
Next
End With
End Sub
Private Sub ToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem2.Click
If gambar IsNot Nothing Then
gambar.RotateFlip(RotateFlipType.Rotate90FlipXY)
picture2.Image = gambar
End If
End Sub
c.Negatif/Rotate 270
Dim pb, pc As Integer
Dim vm, vh, vb As Double
With gambar
For pb = 0 To .Height - 1
For pc = 0 To .Width - 1
vm = 255 - .GetPixel(pc, pb).R
vh = 255 - .GetPixel(pc, pb).G
vb = 255 - .GetPixel(pc, pb).B
If vm <= 0 Then vm = 0
If vb <= 0 Then vb = 0
If vh <= 0 Then vh = 0
.SetPixel(pc, pb, Color.FromArgb(vm, vh, vb))
Next
picture2.Image = gambar
picture2.Refresh()
Next
End With
End Sub
d. Biner
Dim pb, pc As Integer
Dim rata, vm, vh, vb As Double
With gambar
For pb = 0 To .Height - 1
For pc = 0 To .Width - 1
vm = .GetPixel(pc, pb).R
vh = .GetPixel(pc, pb).G
vb = .GetPixel(pc, pb).B
rata = (vm + vh + vb) / 3
If (rata < 128) Then
vm = 0
vh = 0
vb = 0
Else
vm = 255
vh = 255
vb = 255
End If
.SetPixel(pc, pb, Color.FromArgb(vm, vh, vb))
Next
picture2.Image = gambar
picture2.Refresh()
Next
End With
End Sub
Private Sub OpenCitraToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenCitraToolStripMenuItem.Click
OFD.Filter = "BMP|*.bmp|JPG|*.jpg"
OFD.ShowDialog()
If OFD.FileName = "" Then Exit Sub
picture1.Image = Image.FromFile(OFD.FileName)
gambar = New Bitmap(picture1.Image)
'menuutama.MdiParent = Me
'menuutama.Show()
End Sub
e. Brigthness
Private Sub BrigthnessToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BrigthnessToolStripMenuItem.Click
Dim pb, pc As Integer
Dim vm, vh, vb As Double
With gambar
For pb = 0 To .Height - 1
For pc = 0 To .Width - 1
vm = .GetPixel(pc, pb).R + 5
vh = .GetPixel(pc, pb).G + 5
vb = .GetPixel(pc, pb).B + 5
If vm > 255 Then vm = 255
If vb > 255 Then vb = 255
If vh > 255 Then vh = 255
.SetPixel(pc, pb, Color.FromArgb(vm, vh, vb))
Next
picture2.Image = gambar
picture2.Refresh()
Next
End With
End Sub