How to Create a Video in windows form application?? (with pic, maybe flv)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sword117
    New Member
    • Jun 2010
    • 35

    How to Create a Video in windows form application?? (with pic, maybe flv)

    im trying to use frames to create a video in the windows form application everything works if the first FOR is <10, if is > to 10 an error appears saying "FileNotFoundEx ception was unhandled". i need serious help, and if there is a way to use another type of extension(examp le:flv,wmv,tiff ) please help me too with that. thanks ;)

    Code:
     Image[] images = new Image[2003];
                for (int i = 1; i < 2004; i++)
                {
                    images[i] = Image.FromFile(@"C:\New folder (6)\000" + i +".jpg");
                    this.BackgroundImage = images[i];
                }
  • hype261
    New Member
    • Apr 2010
    • 207

    #2
    Originally posted by sword117
    im trying to use frames to create a video in the windows form application everything works if the first FOR is <10, if is > to 10 an error appears saying "FileNotFoundEx ception was unhandled". i need serious help, and if there is a way to use another type of extension(examp le:flv,wmv,tiff ) please help me too with that. thanks ;)

    Code:
     Image[] images = new Image[2003];
                for (int i = 1; i < 2004; i++)
                {
                    images[i] = Image.FromFile(@"C:\New folder (6)\000" + i +".jpg");
                    this.BackgroundImage = images[i];
                }
    The reason an exception is being thrown is because the app can't find a file named 00010.jpg. I would look to ensure that file exists. You should also surround your code with a try catch block so the exception can be properly handled.
    Code:
    try
    {
    //your code here
    }
    catch(FileNotFoundException ex)
    {
    //do something here ie report problem to user
    }
    Also I would have reservations about your code functioning at all. I am not sure, but I don't believe a repaint event will occur and you will only see the first and last image as the background image.

    Also you should have some sort of timer to dictate how long each image stays on the screen. 30 frames a second is pretty standard.

    Comment

    • sword117
      New Member
      • Jun 2010
      • 35

      #3
      Originally posted by hype261
      The reason an exception is being thrown is because the app can't find a file named 00010.jpg. I would look to ensure that file exists. You should also surround your code with a try catch block so the exception can be properly handled.
      Code:
      try
      {
      //your code here
      }
      catch(FileNotFoundException ex)
      {
      //do something here ie report problem to user
      }
      Also I would have reservations about your code functioning at all. I am not sure, but I don't believe a repaint event will occur and you will only see the first and last image as the background image.

      Also you should have some sort of timer to dictate how long each image stays on the screen. 30 frames a second is pretty standard.
      try
      Code:
                  {
                      Image[] images = new Image[2003];
                      for (int i = 1; i < 10; i++)
                      {
                          images[i] = Image.FromFile(@"C:\Users\Sword Master\Desktop\New folder (6)\PS3 Background Waves Attempt HD (08-07-2010 23-45-07)\PS3 Background Waves Attempt HD 000" + i + ".jpg");
                          this.BackgroundImage = images[i];
                      }
                  }
                  catch (Exception f)
                  {
                      MessageBox.Show("error {0}", f.StackTrace);
                  }
      you were right xD and thank you for your help =). how do i do that timer to 30 frames per second? i use the timer from toolbox? and use the timer1_tick? =)
      Last edited by Niheel; Jul 9 '10, 07:27 PM. Reason: please use code tags to display code :)

      Comment

      • hype261
        New Member
        • Apr 2010
        • 207

        #4
        Originally posted by sword117
        try
        Code:
                    {
                        Image[] images = new Image[2003];
                        for (int i = 1; i < 10; i++)
                        {
                            images[i] = Image.FromFile(@"C:\Users\Sword Master\Desktop\New folder (6)\PS3 Background Waves Attempt HD (08-07-2010 23-45-07)\PS3 Background Waves Attempt HD 000" + i + ".jpg");
                            this.BackgroundImage = images[i];
                        }
                    }
                    catch (Exception f)
                    {
                        MessageBox.Show("error {0}", f.StackTrace);
                    }
        you were right xD and thank you for your help =). how do i do that timer to 30 frames per second? i use the timer from toolbox? and use the timer1_tick? =)
        Here is the link to MSDN on the Timer class. It will give a more complete explanation than I can give.

        Implements a timer that raises an event at user-defined intervals. This timer is optimized for use in Windows Forms applications and must be used in a window.


        btw was I incorrect about the paint event does it display each image as you are cycling through them?

        This thread should really be moved to C# programming forum.
        Last edited by hype261; Jul 9 '10, 08:14 PM. Reason: Updated URL

        Comment

        • sword117
          New Member
          • Jun 2010
          • 35

          #5
          Originally posted by hype261
          Here is the link to MSDN on the Timer class. It will give a more complete explanation than I can give.

          Implements a timer that raises an event at user-defined intervals. This timer is optimized for use in Windows Forms applications and must be used in a window.


          btw was I incorrect about the paint event does it display each image as you are cycling through them?

          This thread should really be moved to C# programming forum.
          no, it only displays the 1ยบ and the last img. you are correct it has to be in form_paint =)

          Comment

          • sword117
            New Member
            • Jun 2010
            • 35

            #6
            Originally posted by hype261
            Here is the link to MSDN on the Timer class. It will give a more complete explanation than I can give.

            Implements a timer that raises an event at user-defined intervals. This timer is optimized for use in Windows Forms applications and must be used in a window.


            btw was I incorrect about the paint event does it display each image as you are cycling through them?

            This thread should really be moved to C# programming forum.
            i moved the forum to the c# forum=)
            Last edited by Niheel; Jul 9 '10, 11:03 PM. Reason: it's already in C#

            Comment

            Working...