Friday, 3 April 2015

Aplikasi Pengolahan Citra Menggunakan VB.NET 2010

Aplikasi Pengolahan Citra Menggunakan VB.NET 2010

sekedar berbagi!!

Pada Postingan yang jarang ini, saya akan berbagi contoh sederhana program pengolahan citra menggunakan Visual Basic 2010, Langsung saja di lihat Previewnya,
Tampilan untuk 1 jenis warna
Tampilan untuk mencampur warna


dalam program ini disediakan beberapa jenis warna(Red, Green, Blue dan Campuran RGB) Pilihannya disediakan dalam bentuk ComboBox, dalam mengoprasikannya program ini cukup menggeser HSScrollbar ke kiri dan kekanan atau manual menggunakan textbox.

Tools yang digunakan adalah :

1. TextBox (4 buah)
2. GroupBox (3Buah) "Optional"
3. ComboBox
4. Label
5. Button
6. Panel
7. HSscrollBarr (4 Buah)

dibawah ini adalah scripts yang saya gunakan,



Public Class Form_RGB

    Dim CRed, CGreen, CBlue As Integer

    Private Sub Form_RGB_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Call listWarna()
        Call hideItem()
        Call bersih()
    End Sub

    Sub listWarna()
        cbwarna.Items.Add("Red")
        cbwarna.Items.Add("Green")
        cbwarna.Items.Add("Blue")
        cbwarna.Items.Add("All Color(RGB)")
    End Sub

    Sub bersih()
        txtnilai.Text = 0
        cbwarna.Text = "Red"
        txtnilai1.Text = 0
        txtnilai2.Text = 0
        txtrgb.Text = 0
        Panelwarna.BackColor = Color.Transparent
    End Sub

    Sub bersih2()
        txtnilai.Text = 0
        txtnilai1.Text = 0
        txtnilai2.Text = 0
        txtrgb.Text = 0
        Panelwarna.BackColor = Color.Transparent
    End Sub

    Sub merah()
        CRed = Val(txtnilai.Text)
        Panelwarna.BackColor = Color.FromArgb(CRed, 0, 0)
    End Sub

    Sub hijau()
        CGreen = Val(txtnilai.Text)
        Panelwarna.BackColor = Color.FromArgb(0, CGreen, 0)
    End Sub

    Sub biru()
        CBlue = Val(txtnilai.Text)
        Panelwarna.BackColor = Color.FromArgb(0, 0, CBlue)
    End Sub

    Sub CRGB()
        CRed = Val(txtnilai.Text)
        CGreen = Val(txtnilai1.Text)
        CBlue = Val(txtnilai2.Text)
        Panelwarna.BackColor = Color.FromArgb(CRed, CGreen, CBlue)
    End Sub
 
    Sub process()
        Try
            If cbwarna.Text = "Red" Then
                Call merah()
            ElseIf cbwarna.Text = "Green" Then
                Call hijau()
            ElseIf cbwarna.Text = "Blue" Then
                Call biru()
            Else : Call CRGB()

            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub btlihat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btlihat.Click
        Call process()
    End Sub

    Private Sub btreset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btreset.Click
        Call bersih2()
    End Sub

    Private Sub btkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btkeluar.Click
        Me.Close()
    End Sub

    Sub hideItem()
        Label2.Text = "Nilai Warna"
        Label3.Hide()
        Label4.Hide()
        Label5.Hide()
        txtnilai1.Hide()
        txtnilai2.Hide()
        txtrgb.Hide()
        HScrollBar2.Hide()
        HScrollBar3.Hide()
        HScrollBar4.Hide()
        GroupBox1.Width = 235
        GroupBox1.Height = 80
    End Sub

    Sub showItem()
        Label2.Text = "Nilai Warna Merah"
        Label3.Visible = True
        Label4.Visible = True
        Label5.Visible = True
        txtnilai1.Visible = True
        txtnilai2.Visible = True
        txtrgb.Visible = True
        HScrollBar2.Visible = True
        HScrollBar3.Visible = True
        HScrollBar4.Visible = True
        GroupBox1.Width = 235
        GroupBox1.Height = 159
    End Sub

    Private Sub cbwarna_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbwarna.SelectedIndexChanged
        If cbwarna.Text = "All Color(RGB)" Then
            Call showItem()
        Else : hideItem()
        End If
        Call bersih2()
    End Sub

    Private Sub txtnilai_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtnilai.Click
        txtnilai.SelectAll()
    End Sub
  
    Private Sub txtnilai_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtnilai.TextChanged
        Call nilai()
        Call process()
    End Sub

    Private Sub txtnilai1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtnilai1.Click
        txtnilai1.SelectAll()
    End Sub

    Private Sub txtnilai2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtnilai2.Click
        txtnilai2.SelectAll()
    End Sub
  
    Private Sub HScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar1.Scroll
        txtnilai.Text = HScrollBar1.Value
    End Sub

    Private Sub HScrollBar2_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar2.Scroll
        txtnilai1.Text = HScrollBar2.Value
    End Sub

    Private Sub HScrollBar3_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar3.Scroll
        txtnilai2.Text = HScrollBar3.Value

    End Sub

    Private Sub HScrollBar4_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar4.Scroll
        txtrgb.Text = HScrollBar4.Value
    End Sub

    Sub nilai()
        HScrollBar1.Value = Val(txtnilai.Text)
        HScrollBar2.Value = Val(txtnilai1.Text)
        HScrollBar3.Value = Val(txtnilai2.Text)
        HScrollBar4.Value = Val(txtrgb.Text)
    End Sub
  
    Private Sub txtnilai1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtnilai1.TextChanged
        Call nilai()
        Call process()
    End Sub

    Private Sub txtnilai2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtnilai2.TextChanged
        Call nilai()
        Call process()
    End Sub

    Private Sub txtrgb_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtrgb.Click
        txtrgb.SelectAll()
    End Sub

    Private Sub txtrgb_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtrgb.TextChanged
        txtnilai.Text = txtrgb.Text
        txtnilai1.Text = txtrgb.Text
        txtnilai2.Text = txtrgb.Text
        Call nilai()
        Call process()
    End Sub

End Class

Untuk lebih jelas bisa download aplikasinya disini atau disini

Semoga bermanfaat!!!

No comments:

Post a Comment