LEADTOOLS Multimedia (Leadtools.Multimedia assembly) Send comments on this topic. | Back to Introduction | Help Version 17.0.3.22
GetStillImage Method
See Also 
Leadtools.Multimedia Namespace > PlayCtrl Class : GetStillImage Method



timeOut
Value containing the maximum time to wait for the image, in milliseconds.
timeOut
Value containing the maximum time to wait for the image, in milliseconds.
Gets a System.Drawing.Image object.

Syntax

Visual Basic (Declaration) 
Public Overridable Function GetStillImage( _
   ByVal timeOut As Integer _
) As Image
Visual Basic (Usage)Copy Code
Dim instance As PlayCtrl
Dim timeOut As Integer
Dim value As Image
 
value = instance.GetStillImage(timeOut)
C# 
public virtual Image GetStillImage( 
   int timeOut
)
C++/CLI 
public:
virtual Image^ GetStillImage( 
   int timeOut
) 

Parameters

timeOut
Value containing the maximum time to wait for the image, in milliseconds.

Return Value

The System.Drawing.Image object

Example

Visual BasicCopy Code
Public _form As PlayCtrlForm = New PlayCtrlForm()
      Public _playctrl As PlayCtrl = Nothing
      Public _result As Boolean = False
      Public _inFile As String = Path.Combine(LEAD_VARS.MediaDir, "PlayCtrl_Source.avi")
      Public _outFile As String = Path.Combine(LEAD_VARS.MediaDir, "PlayCtrl_GetStillImageExample.jpg")
      Public Sub GetStillImageExample()
         ' reference the play control
         _playctrl = _form.PlayCtrl

         Try
            ' set the test timer on our form
            _form.TestTimer.Interval = 2000 ' wait 2 seconds after start
            AddHandler _form.TestTimer.Tick, AddressOf GetStillImage_Helper

            ' set input media file
            _playctrl.SourceFile = _inFile

            ' set the timer on
            _form.TestTimer.Start()
         Catch e1 As Exception
            _result = False
         End Try

         ' we'll loop on the state and pump messages for this example.
         ' but you should not need to if running from a Windows Forms application.
         Do While _playctrl.State = PlayState.Running
            Application.DoEvents()
         Loop

         ' check for the capture file and set the result
         If File.Exists(Path.Combine(Directory.GetCurrentDirectory(), _outFile)) Then
            _result = True
         End If
      End Sub

      Public Sub GetStillImage_Helper(ByVal sender As Object, ByVal e As EventArgs)
         ' get a still image
         Dim image As Image = _playctrl.GetStillImage(-1)
         If Not image Is Nothing Then
            image.Save(_outFile, ImageFormat.Jpeg)
         End If

         ' stop the capture
         _playctrl.Stop()
      End Sub

Public NotInheritable Class LEAD_VARS
   Public Const MediaDir As String = "C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 17\Media"
End Class
C#Copy Code
public PlayCtrlForm _form = new PlayCtrlForm();
      public PlayCtrl _playctrl = null;
      public bool _result = false;
      public string _inFile =Path.Combine(LEAD_VARS.MediaDir,"PlayCtrl_Source.avi");
      public string _outFile =Path.Combine(LEAD_VARS.MediaDir,"PlayCtrl_GetStillImageExample.jpg");
      public void GetStillImageExample()
      {
         // reference the play control
         _playctrl = _form.PlayCtrl;

         try
         {
            // set the test timer on our form
            _form.TestTimer.Interval = 2000; // wait 2 seconds after start
            _form.TestTimer.Tick += GetStillImage_Helper;

            // set input media file
            _playctrl.SourceFile = _inFile;

            // set the timer on
            _form.TestTimer.Start();
         }
         catch (Exception)
         {
            _result = false;
         }

         // we'll loop on the state and pump messages for this example.
         // but you should not need to if running from a Windows Forms application.
         while (_playctrl.State == PlayState.Running)
            Application.DoEvents();

         // check for the capture file and set the result
         if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), _outFile)))
            _result = true;
      }

      public void GetStillImage_Helper(object sender, EventArgs e)
      {
         // get a still image
         Image image = _playctrl.GetStillImage(-1);
         if (image != null)
            image.Save(_outFile, ImageFormat.Jpeg);

         // stop the capture
         _playctrl.Stop();
      }

static class LEAD_VARS
{
   public const string MediaDir = @"C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 17\Media";
}

Remarks

If TimeOut is -1, the method's time-out interval never elapses. If the method fails, an error is raised. For more information, refer to the Error Codes.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7

See Also