Desaign seperti ini
Terdiri dari
*Menu Strip
*OpenFileDialog
*SaveFileDialog
*PictureBox dan
*Button
ini codingnya :
Public Class Form1
Dim gambar As Bitmap
Private Sub BukaGambarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BukaGambarToolStripMenuItem.Click
OpenFileDialog1.Filter = "Gambar |*jpg|BMP|*.bmp|PNG|*.png"
OpenFileDialog1.ShowDialog()
If OpenFileDialog1.FileName = "" Then Exit Sub
PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
gambar = New Bitmap(PictureBox1.Image)
Me.Text = gambar.Height & "K" & gambar.Width
End Sub
Private Sub SimpanGambar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SimpanGambar.Click
SaveFileDialog1.Filter = "JPG|*.jpg|BMP|*.bmp|PNG|*.png*"
SaveFileDialog1.ShowDialog()
If SaveFileDialog1.FileName = "" Then Exit Sub
If SaveFileDialog1.FilterIndex = 1 Then
gambar.Save(SaveFileDialog1.FileName + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
End If
If SaveFileDialog1.FilterIndex = 2 Then
gambar.Save(SaveFileDialog1.FileName + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp)
End If
If SaveFileDialog1.FilterIndex = 3 Then
gambar.Save(SaveFileDialog1.FileName + ".png", System.Drawing.Imaging.ImageFormat.Png)
End If
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
End
End Sub
End Class
Hasilnya seperti ini
Lalu pilih file , Buka Gambar
Maka akan muncul tampilan seperti ini , dimana kita akan dibawa untuk memilih gamabar yang akan kita simpan.
pilih Open , maka akan muncul seperti tampilan di bawah ini.
Lalu Pilih Simpan Gambar .
Pilihlah format sesuai yang kita inginkan.
Friday, January 9, 2015
Subscribe to:
Posts (Atom)