Results 1 to 19 of 19

Thread: How do i save pictures from a picturebox that update every 2 sec from a a screenshot

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2011
    Posts
    29

    Unhappy How do i save pictures from a picturebox that update every 2 sec from a a screenshot

    pretty much what i said. here is some of the code that i have:
    Code:
    Public Function CaptureImage(ByVal X As Integer, ByVal Y As Integer, ByVal Width As Integer, ByVal Height As Integer) As Bitmap
            Dim JPEG As New Bitmap(Width, Height)
            Dim G As Graphics = Graphics.FromImage(JPEG)
            G.CopyFromScreen(New Point(X, Y), New Point(0, 0), JPEG.Size)
            G.Dispose() : Return JPEG
        End Function
    
    '-------------- 
    
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    '--------------
    ' "screenshot" is the picturebox on form 3 
    Form3.screenshot.Image = CaptureImage(Form4.Location.X, Form4.Location.Y, Form4.ClientSize.Width, Form4.ClientSize.Height)
    End Sub
    when the timer hits a 2 second interval the picturebox on form 3 gets a new image from the screen shot that form 4 takes off of form4's area. i want the user to select a folder with the "folder browser dialog" and i want each frame capture to be saved to the folder (every 2 seconds) that the user chooses as "1.jpg, 2.jpg, 3.jpg" etc could you please give me a good idea and some code on how to do this thank you. p.s if you need a better idea or more code examples on what I'm trying to say, just ask. thanks again

  2. #2
    Lively Member Doraemon's Avatar
    Join Date
    Jul 2011
    Posts
    67

    Re: How do i save pictures from a picturebox that update every 2 sec from a a screens

    try something like this: x = x + 1

  3. #3
    Lively Member Doraemon's Avatar
    Join Date
    Jul 2011
    Posts
    67

    Re: How do i save pictures from a picturebox that update every 2 sec from a a screens

    screenshot.Save([type where should it be saved's folder])
    * i will give u the full code, just give me few minutes

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Nov 2011
    Posts
    29

    Re: How do i save pictures from a picturebox that update every 2 sec from a a screens

    thank you Doraemon i'll be waiting

  5. #5
    Lively Member Doraemon's Avatar
    Join Date
    Jul 2011
    Posts
    67

    Re: How do i save pictures from a picturebox that update every 2 sec from a a screens

    create a control "folderbrowsedialog"
    create a button named "button1", when you clicked on it, it will show up a folderbrowsedialog

    Code:
    Public Class form3
        Dim x As Integer
        Public Function CaptureImage(ByVal X As Integer, ByVal Y As Integer, ByVal Width As Integer, ByVal Height As Integer) As Bitmap
            Dim JPEG As New Bitmap(Width, Height)
            Dim G As Graphics = Graphics.FromImage(JPEG)
            G.CopyFromScreen(New Point(X, Y), New Point(0, 0), JPEG.Size)
            G.Dispose() : Return JPEG
        End Function
    
        '-------------- 
    
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            '--------------
            ' "screenshot" is the picturebox on form 3 
            Me.screenshot.Image = CaptureImage(form4.Location.X, form4.Location.Y, form4.ClientSize.Width, form4.ClientSize.Height)
            x = x + 1
            screenshot.Image.Save(FolderBrowserDialog1.SelectedPath & "\" & x & ".jpg")
        End Sub
    
        Private Sub form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            form4.Show()
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            FolderBrowserDialog1.ShowDialog()
            Timer1.Start()
        End Sub
    End Class
    rate me so i doesn't only have
    i need

    XD
    Last edited by Doraemon; Nov 21st, 2011 at 08:14 AM.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Nov 2011
    Posts
    29

    Re: How do i save pictures from a picturebox that update every 2 sec from a a screens

    Thank you so much !! i've been making this program for about a week and this is the main feature and you just helped me figure it out... THANK YOU . how do you add friends on this forum you defiantly one of mine?

  7. #7
    Lively Member Doraemon's Avatar
    Join Date
    Jul 2011
    Posts
    67

    Re: How do i save pictures from a picturebox that update every 2 sec from a a screens

    I am not pro at VB.net, this is my first time helping other, i am too happy to saw you done it

    1. click on this:
    http://www.vbforums.com/profile.php?...riend&u=138364

    2. click on this (rate me):
    http://www.vbforums.com/reputation.php?p=4095477
    (if not working, click on "Rate this post")

    3. you should make atleast 10 posts so your posts doesn't need vertification by moderators

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Nov 2011
    Posts
    29

    Re: How do i save pictures from a picturebox that update every 2 sec from a a screens

    Done and Done & good idea i didn't even know that

  9. #9
    Lively Member Doraemon's Avatar
    Join Date
    Jul 2011
    Posts
    67

    Re: How do i save pictures from a picturebox that update every 2 sec from a a screens

    do you rated me? i still only have 5 point only

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Nov 2011
    Posts
    29

    Re: How do i save pictures from a picturebox that update every 2 sec from a a screens

    i tried the link but this time ill click "rate this post"... did you accept my friend request ?

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Nov 2011
    Posts
    29

    Re: How do i save pictures from a picturebox that update every 2 sec from a a screens

    yeah i clicked "rate this post" and it said "you can not give reputation to the same post twice" ??

  12. #12
    Lively Member Doraemon's Avatar
    Join Date
    Jul 2011
    Posts
    67

    Re: How do i save pictures from a picturebox that update every 2 sec from a a screens

    then you give rate on all my post hahaha XD
    addon, i had already added you
    addon 2, you had reached 10 post!

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Nov 2011
    Posts
    29

    Re: How do i save pictures from a picturebox that update every 2 sec from a a screens

    lol awsome, here's another question I want to basically want to stop the screenshot's of wm player when the video stops or even when the progress that i have gets to the end which it is coded to sync with the duration of the video. any idea on how to do that ?? this is what i have for the progressbar

    vb Code:
    1. 'Form 1
    2.     Private Sub AxWindowsMediaPlayer1_PlayStateChange(ByVal sender As System.Object, _
    3. ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) Handles AxWindowsMediaPlayer1.PlayStateChange
    4.         If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPlaying Then
    5.             Form3.ProgressBar1.Maximum = CInt(AxWindowsMediaPlayer1.Ctlcontrols.currentItem.duration)
    6.             Form3.Timer1.Start()
    7.         ElseIf AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPaused Then
    8.             Form3.Timer1.Stop()
    9.         ElseIf AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped Then
    10.             Form3.Timer1.Stop()
    11.             Form3.ProgressBar1.Value = 0
    12.         End If
    13. End Sub
    14.  
    15. 'Form 3 (with progress bar and picturebox)
    16.  
    17. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    18.  
    19.         If Form1.AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPlaying Then
    20.             ProgressBar1.Value = CInt(Form1.AxWindowsMediaPlayer1.Ctlcontrols.currentPosition)
    21.         End If
    22.  
    23. End Sub

    Thanks =)

  14. #14
    Lively Member Doraemon's Avatar
    Join Date
    Jul 2011
    Posts
    67

    Re: How do i save pictures from a picturebox that update every 2 sec from a a screens

    can you create a new thread? addon, i still not understand what you saying, say more clearer?

  15. #15

    Thread Starter
    Junior Member
    Join Date
    Nov 2011
    Posts
    29

    Re: How do i save pictures from a picturebox that update every 2 sec from a a screens

    okay so what the program does is it takes a screenshot of the axwindowsmediaplayer plug-in every 2 seconds with a invisible form over the windows media player plug-in it then shows it on a picturebox and saves it to a jpeg every 2 seconds (which you helped me with :P) what i want it to do though is when the video stops playing i want it to stop making jpegs.

  16. #16
    Lively Member Doraemon's Avatar
    Join Date
    Jul 2011
    Posts
    67

    Re: How do i save pictures from a picturebox that update every 2 sec from a a screens

    you can make it by comparing the difference between the image, code i will make it too ==, few minutes is required
    or i can do it by another way... wait is still need ==

    i had just reviewed your code, this should already does what it should does:
    ElseIf AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped Then
    Form3.Timer1.Stop()
    if you really want me to edit whole project, please send me your project file
    Last edited by Doraemon; Nov 21st, 2011 at 09:16 AM.

  17. #17

    Thread Starter
    Junior Member
    Join Date
    Nov 2011
    Posts
    29

    Re: How do i save pictures from a picturebox that update every 2 sec from a a screens

    Thanks man

  18. #18

    Thread Starter
    Junior Member
    Join Date
    Nov 2011
    Posts
    29

    Re: How do i save pictures from a picturebox that update every 2 sec from a a screens

    k obviously your preoccupied with something else now lol, i have to go to sleep now anyway it's 1:50 am in my time zone and i have to get up for school a 7:50 am so don't know how i'm gonna do that :S but it was a nice talk and i got some good expertise from you my friend. anyways signing off now... ill talk to you tomorrow and once again thank you so much for your help

  19. #19
    Lively Member Doraemon's Avatar
    Join Date
    Jul 2011
    Posts
    67

    Re: How do i save pictures from a picturebox that update every 2 sec from a a screens

    ok, good night~

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width