Picture Taker with many Features
Posted: Sun Dec 27, 2009 2:36 am
This is my first Visual Basic tutorial, so i hope you like it omg;
I'm going to show you how to make a Picture taker like this:
![Image]()
Now, the first thing you might think is, "wow.. that sucks", well this it has many features as i said...
http://i700.photobucket.com/albums/ww4/ ... howxxl.png
Anyways here is the tutorial:
FORM 1
What you need:
*4 Buttons - name "B1 = "Capture Screen" - B2 = "Save Image" - B3 = "Watch Picture" - B4 = "New Picture".
*Picture box [Just hide it somewhere]
Full Code:
Button 1:
NOW form 2:
What you need:
*3 Buttons - Name: [B1 = "Open Image Folder" - B2 = "Open Single Image" - B3 = "Picture Resize".
*Label
*List box
*Picture box
Full code:
Button 1:
FORM 3:
What you need:
*Picture Box
*4 Text Box
*2 Group Box
*2 Checkbox
*1 Button named "Resize Image"
*Combo Box
FULL CODE:
Thanks for reading clapper;
Here you can download the Project :
I'm going to show you how to make a Picture taker like this:

Now, the first thing you might think is, "wow.. that sucks", well this it has many features as i said...
http://i700.photobucket.com/albums/ww4/ ... howxxl.png
Anyways here is the tutorial:
FORM 1
What you need:
*4 Buttons - name "B1 = "Capture Screen" - B2 = "Save Image" - B3 = "Watch Picture" - B4 = "New Picture".
*Picture box [Just hide it somewhere]
Full Code:
Code: Select all
OR THE SAME ONLY SINGLED:Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim bounds As Rectangle
Dim screenshot As System.Drawing.Bitmap
Dim graph As Graphics
bounds = Screen.PrimaryScreen.Bounds
screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
graph = Graphics.FromImage(screenshot)
graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
PictureBox1.Image = screenshot
Do Until Me.Height = 136
Me.Height = Me.Height + 1
Loop
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim savefiledialog1 As New SaveFileDialog
Try
savefiledialog1.Title = "Save Captured Image"
savefiledialog1.FileName = "Screenshot Image 1"
savefiledialog1.Filter = "All Type Of Image Files|*.*|Joint Photographic Experts Group [JPEG]|*.jpg|Bitmap [BMP|*.bmp|Tagged Image File Format [TIFF]|*.tiff|Portable Network Graphics [PNG]|*.png"
If savefiledialog1.ShowDialog() = DialogResult.OK Then
PictureBox1.Image.Save(savefiledialog1.FileName, System.Drawing.Imaging.ImageFormat.Bmp)
End If
Catch ex As Exception
End Try
Do Until Me.Height = 136
Me.Height = Me.Height + 1
Loop
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Form2.Show()
Do Until Me.Height = 85
Me.Height = Me.Height - 1
Loop
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Do Until Me.Height = 59
Me.Height = Me.Height - 1
Loop
End Sub
End Class
Button 1:
Code: Select all
Button 2:
Dim bounds As Rectangle
Dim screenshot As System.Drawing.Bitmap
Dim graph As Graphics
bounds = Screen.PrimaryScreen.Bounds
screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
graph = Graphics.FromImage(screenshot)
graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
PictureBox1.Image = screenshot
Do Until Me.Height = 136
Me.Height = Me.Height + 1
Loop
Code: Select all
Button 3:
Dim savefiledialog1 As New SaveFileDialog
Try
savefiledialog1.Title = "Save Captured Image"
savefiledialog1.FileName = "Screenshot Image 1"
savefiledialog1.Filter = "All Type Of Image Files|*.*|Joint Photographic Experts Group [JPEG]|*.jpg|Bitmap [BMP|*.bmp|Tagged Image File Format [TIFF]|*.tiff|Portable Network Graphics [PNG]|*.png"
If savefiledialog1.ShowDialog() = DialogResult.OK Then
PictureBox1.Image.Save(savefiledialog1.FileName, System.Drawing.Imaging.ImageFormat.Bmp)
End If
Catch ex As Exception
End Try
Do Until Me.Height = 136
Me.Height = Me.Height + 1
Loop
Code: Select all
Button 4:
Form2.Show()
Do Until Me.Height = 85
Me.Height = Me.Height - 1
Loop
Code: Select all
Do Until Me.Height = 59
Me.Height = Me.Height - 1
Loop
NOW form 2:
What you need:
*3 Buttons - Name: [B1 = "Open Image Folder" - B2 = "Open Single Image" - B3 = "Picture Resize".
*Label
*List box
*Picture box
Full code:
Code: Select all
OR THE SAME ONLY SINGLED: Public Class Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
FolderBrowserDialog1.ShowDialog()
Dim fold As New IO.DirectoryInfo(FolderBrowserDialog1.SelectedPath)
Dim foldi As IO.FileInfo() = fold.GetFiles("*.jpg")
Dim foldg As IO.FileInfo
Label1.Text = FolderBrowserDialog1.SelectedPath
ListBox1.Items.Clear()
For Each foldg In foldi
ListBox1.Items.Add(foldg)
Next
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
OpenFileDialog1.FileName = "Select a Image file"
OpenFileDialog1.Filter = "All Type Of Image Files|*.*|Joint Photographic Experts Group [JPEG]|*.jpg|Bitmap [BMP|*.bmp|Tagged Image File Format [TIFF]|*.tiff|Portable Network Graphics [PNG]|*.png"
If (OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK) Then
PictureBox1.Image = System.Drawing.Image.FromFile(OpenFileDialog1.FileName)
PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
End If
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim Pfolder
Dim Pname
Try
Pfolder = Label1.Text
Pname = ListBox1.SelectedItem.ToString
PictureBox1.Image = System.Drawing.Image.FromFile(Pfolder + "\" + Pname)
PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
Catch ex As Exception
MsgBox("You have to select an Image Folder first")
End Try
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Form3.Show()
End Sub
End Class
Button 1:
Code: Select all
Button 2:
FolderBrowserDialog1.ShowDialog()
Dim fold As New IO.DirectoryInfo(FolderBrowserDialog1.SelectedPath)
Dim foldi As IO.FileInfo() = fold.GetFiles("*.jpg")
Dim foldg As IO.FileInfo
Label1.Text = FolderBrowserDialog1.SelectedPath
ListBox1.Items.Clear()
For Each foldg In foldi
ListBox1.Items.Add(foldg)
Next
Code: Select all
Listbox1:
OpenFileDialog1.FileName = "Select a Image file"
OpenFileDialog1.Filter = "All Type Of Image Files|*.*|Joint Photographic Experts Group [JPEG]|*.jpg|Bitmap [BMP|*.bmp|Tagged Image File Format [TIFF]|*.tiff|Portable Network Graphics [PNG]|*.png"
If (OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK) Then
PictureBox1.Image = System.Drawing.Image.FromFile(OpenFileDialog1.FileName)
PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
End If
Code: Select all
Button 3:
Dim Pfolder
Dim Pname
Try
Pfolder = Label1.Text
Pname = ListBox1.SelectedItem.ToString
PictureBox1.Image = System.Drawing.Image.FromFile(Pfolder + "\" + Pname)
PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
Catch ex As Exception
MsgBox("You have to select an Image Folder first")
End Try
Code: Select all
Form3.Show()
FORM 3:
What you need:
*Picture Box
*4 Text Box
*2 Group Box
*2 Checkbox
*1 Button named "Resize Image"
*Combo Box
FULL CODE:
Code: Select all
Public Class Form3
Dim hhound() As String
Dim int As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PictureBox1.AllowDrop = True
End Sub
Private Sub PictureBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragDrop
Try
Dim hhound() As String
Dim int As String
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
hhound = e.Data.GetData(DataFormats.FileDrop)
int = hhound(0)
PictureBox1.Image = Image.FromFile(int)
PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
TextBox3.Text = PictureBox1.Image.Width
TextBox4.Text = PictureBox1.Image.Height
End If
Catch
MsgBox("Cannot copy your picture")
End Try
End Sub
Private Sub PictureBox1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragEnter
e.Effect = e.AllowedEffect
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim str As String
Dim savefiledialog1 As New SaveFileDialog()
Dim bm As New Bitmap(PictureBox1.Image)
Dim x As Int32 = TextBox1.Text
Dim y As Int32 = TextBox2.Text
str = ComboBox1.SelectedItem
Dim width As Integer = Val(x)
Dim height As Integer = Val(y)
Dim thumb As New Bitmap(width, height)
Dim g As Graphics = Graphics.FromImage(thumb)
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(bm, New Rectangle(0, 0, width, height), New Rectangle(0, 0, bm.Width, bm.Height), GraphicsUnit.Pixel)
g.Dispose()
savefiledialog1.Filter = str + "|*." + str
savefiledialog1.ShowDialog()
If str = "Wmf" Then
thumb.Save(savefiledialog1.FileName, System.Drawing.Imaging.ImageFormat.Wmf)
bm.Dispose()
thumb.Dispose()
ElseIf str = "gif" Then
thumb.Save(savefiledialog1.FileName, System.Drawing.Imaging.ImageFormat.Gif)
bm.Dispose()
thumb.Dispose()
ElseIf str = "exif" Then
thumb.Save(savefiledialog1.FileName, System.Drawing.Imaging.ImageFormat.Exif)
bm.Dispose()
thumb.Dispose()
ElseIf str = "jpeg" Then
thumb.Save(savefiledialog1.FileName, System.Drawing.Imaging.ImageFormat.Jpeg)
bm.Dispose()
thumb.Dispose()
ElseIf str = "tiff" Then
thumb.Save(savefiledialog1.FileName, System.Drawing.Imaging.ImageFormat.Tiff)
bm.Dispose()
thumb.Dispose()
ElseIf str = "Bmp" Then
thumb.Save(savefiledialog1.FileName, System.Drawing.Imaging.ImageFormat.Bmp)
bm.Dispose()
thumb.Dispose()
ElseIf str = "png" Then
thumb.Save(savefiledialog1.FileName, System.Drawing.Imaging.ImageFormat.Png)
bm.Dispose()
thumb.Dispose()
End If
MsgBox("Resize successfully!")
If CheckBox2.Checked = True Then
Me.Close()
End If
Catch
MsgBox("Cannot convert your picture")
End Try
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
Me.TopMost = True
Else
Me.TopMost = False
End If
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
End Sub
End Class
Thanks for reading clapper;
Here you can download the Project :