locked
Load image and video files RRS feed

  • Question

  • Hi,

     

    I want to load image to a pictureBox. i created a pictureBox in a form but i can´t make the load using 'pictureBox.load()'!!    I get this error:

    Error 10 'System.Windows.Forms.PictureBox' does not contain a definition for 'Load' 

     

    Could you help me,please and explain what i have to do?

     

    And about movie files?how can i load and play a movie file in my project?

     

    Thank you

    Sunday, April 6, 2008 3:09 PM

Answers

  • First, you have to load the image you want into memory, this can be done in one line, or two, for example:

    Image MyImage = Image.FromFile("c:\\SomeFileToLoad.jpg");

    Next, you set the .Image property of the picturebox, like:

    picturebox.Image = MyImage;

    Or this can all be done in one line, like:

    picturebox.Image = Image.FromFile("c:\\SomeFileToLoad.jpg");

    Movie files are a bit more difficult, and you may want to practice basic programming a little more first. Loading a movie file consists of hosting a player that can play the file, and using its API to load and start the file. The Windows Media player has a great API for this, as well as some lower level (aka harder) stuff built into windows. I think though, and don't take this personally, that you need to learn how to debug and how to look up topics in the help files, your problem could have easily been solved if you studied the Image object (and even the PictureBox control) a little in the help files. They give great examples of how to use the controls there. If you need help with it, just hit F1 and type in what you would like help with.




    Sunday, April 6, 2008 3:48 PM

All replies

  • First, you have to load the image you want into memory, this can be done in one line, or two, for example:

    Image MyImage = Image.FromFile("c:\\SomeFileToLoad.jpg");

    Next, you set the .Image property of the picturebox, like:

    picturebox.Image = MyImage;

    Or this can all be done in one line, like:

    picturebox.Image = Image.FromFile("c:\\SomeFileToLoad.jpg");

    Movie files are a bit more difficult, and you may want to practice basic programming a little more first. Loading a movie file consists of hosting a player that can play the file, and using its API to load and start the file. The Windows Media player has a great API for this, as well as some lower level (aka harder) stuff built into windows. I think though, and don't take this personally, that you need to learn how to debug and how to look up topics in the help files, your problem could have easily been solved if you studied the Image object (and even the PictureBox control) a little in the help files. They give great examples of how to use the controls there. If you need help with it, just hit F1 and type in what you would like help with.




    Sunday, April 6, 2008 3:48 PM
  •  

    Thanks for your help!!

     

    But i still have problems! now,i get this error:Error 10 'System.Drawing.Image' does not contain a definition for 'FromFile' !!

    There are missing any library?Coul you help me again?

     

     

    About the movies files,i used System.Diagnostics.Process but i can´t open .flv or.avi files with WMP. Is there any other option to open these kind of files? WMP just read .mp3,.wma and.wmv?

     

    Thanks

     


     

    Tuesday, April 15, 2008 11:31 AM