Picture Taker with many Features

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
11 posts Page 1 of 2
Contributors
User avatar
RunarM
Hardcore Programmer
Hardcore Programmer
Posts: 508
Joined: Wed Nov 18, 2009 11:33 pm

Picture Taker with many Features
RunarM
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:
Code: Select all
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
OR THE SAME ONLY SINGLED:

Button 1:
Code: Select all
        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
Button 2:
Code: Select all
        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
Button 3:
Code: Select all
        Form2.Show()
        Do Until Me.Height = 85
            Me.Height = Me.Height - 1
        Loop
Button 4:
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
 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 
OR THE SAME ONLY SINGLED:

Button 1:
Code: Select all
        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
Button 2:
Code: Select all
 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
Listbox1:
Code: Select all
        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
Button 3:
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 :
You do not have the required permissions to view the files attached to this post.
Last edited by RunarM on Thu Jan 07, 2010 4:04 am, edited 2 times in total.
Just another day in my life.
http://www.codexvideos.com
User avatar
Toxikr3
Dedicated Member
Dedicated Member
Posts: 69
Joined: Tue Dec 08, 2009 12:49 am

oh DANG.

Thats nice! Good job!
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Hello RunarM,

Great job on this one I like the simple interface.

Keep it up cooll;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
RunarM
Hardcore Programmer
Hardcore Programmer
Posts: 508
Joined: Wed Nov 18, 2009 11:33 pm

Re: Picture Taker with many Features
RunarM
Anyone else liked it =)?
Just another day in my life.
http://www.codexvideos.com
User avatar
Usman55
VIP - Site Partner
VIP - Site Partner
Posts: 2821
Joined: Thu Dec 24, 2009 7:52 pm

Well, this is very nice and I hope that you add more features in it!
Thanks!
Image
User avatar
RunarM
Hardcore Programmer
Hardcore Programmer
Posts: 508
Joined: Wed Nov 18, 2009 11:33 pm

Re: Picture Taker with many Features
RunarM
lmao;
Last edited by RunarM on Mon Jan 11, 2010 4:39 pm, edited 2 times in total.
Just another day in my life.
http://www.codexvideos.com
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

Hi
Very nice cooll;
I like the simplicity of it, and it works really well cooll;

Well Done

Chris
Image
User avatar
Livengood
Serious Programmer
Serious Programmer
Posts: 445
Joined: Tue Feb 16, 2010 6:24 am

Very nice :D, nice tutorial there :D
Image
User avatar
Agust1337
Coding God
Coding God
Posts: 2456
Joined: Fri Feb 19, 2010 8:18 pm

LOL your first tutorial :D? Gratzie, but anyways, it looks nice ;) Really good and explained tutorial cooll;
Top-notch casual Dating
User avatar
NecroPhis
VIP - Donator
VIP - Donator
Posts: 345
Joined: Sun Aug 08, 2010 1:14 pm

omg nice tutorial :O keep it up
Image
11 posts Page 1 of 2
Return to “Tutorials”