LEADTOOLS WIA (Leadtools.Wia assembly)
LEAD Technologies, Inc

IsVideoPreviewAvailable Method

Example 





Determines whether there is an available video preview.
Syntax
public bool IsVideoPreviewAvailable()
'Declaration
 
Public Function IsVideoPreviewAvailable() As Boolean
'Usage
 
Dim instance As WiaSession
Dim value As Boolean
 
value = instance.IsVideoPreviewAvailable()
public bool IsVideoPreviewAvailable()
 function Leadtools.Wia.WiaSession.IsVideoPreviewAvailable()
public:
bool IsVideoPreviewAvailable(); 

Return Value

true if the video preview is started; otherwise, false.
Remarks
This function is used to determine whether the video preview has started. Start the video preview by calling the WiaSession.StartVideoPreview method.
Example
 
Public Sub IsVideoPreviewAvailableExample(ByVal parent As IWin32Window)
   If (Not WiaSession.IsAvailable(WiaVersion.Version1)) Then
      MessageBox.Show("WIA version 1.0 not installed.")
      Return
   End If

   Dim session As WiaSession = New WiaSession()
   session.Startup(WiaVersion.Version1)

   Dim res As DialogResult = session.SelectDeviceDlg(parent, WiaDeviceType.StreamingVideo, WiaSelectSourceFlags.NoDefault)
   If res <> DialogResult.OK Then
      MessageBox.Show("Error selecting WIA device.")
      session.Shutdown()
      Return
   End If

   ' start the video preview
   wiaSession.StartVideoPreview(parent, False)

   ' determine whether a video preview is available
   Dim available As Boolean = wiaSession.IsVideoPreviewAvailable()
   If (Not available) Then
      MessageBox.Show("No streaming video available.")
      wiaSession.EndVideoPreview()
      wiaSession.Shutdown()
      Return
   End If

   'Resize the video preview area to fit the parent window.
   'I am calling this resize function here only for demonstration purposes, but you
   'should call it in your window resize event.
   wiaSession.ResizeVideoPreview(True)

   ' acquire an image from the video source.
   Dim takenPictureFileName As String = wiaSession.AcquireImageFromVideo()

   Dim strMsg As String = String.Format("Acquired image was saved to the following path:\n{0}", takenPictureFileName)
   MessageBox.Show(strMsg)

   wiaSession.EndVideoPreview()
   session.Shutdown()
End Sub
public void IsVideoPreviewAvailableExample(IWin32Window parent)
{
   if (!WiaSession.IsAvailable(WiaVersion.Version1))
   {
      MessageBox.Show("WIA version 1.0 not installed.");
      return;
   }

   WiaSession wiaSession = new WiaSession();
   wiaSession.Startup(WiaVersion.Version1);

   DialogResult res = wiaSession.SelectDeviceDlg(parent, WiaDeviceType.StreamingVideo, WiaSelectSourceFlags.NoDefault);
   if (res != DialogResult.OK)
   {
      MessageBox.Show("Error selecting WIA device.");
      wiaSession.Shutdown();
      return;
   }

   // start the video preview
   wiaSession.StartVideoPreview(parent, false);

   // determine whether a video preview is available
   bool available = wiaSession.IsVideoPreviewAvailable();
   if(!available)
   {
      MessageBox.Show("No streaming video available.");
      wiaSession.EndVideoPreview();
      wiaSession.Shutdown();
      return;
   }

   // Resize the video preview area to fit the parent window.
   // I am calling this resize function here only for demonstration purposes, but you
   // should call it in your window resize event.
   wiaSession.ResizeVideoPreview(true);

   // acquire an image from the video source.
   string takenPictureFileName = wiaSession.AcquireImageFromVideo();

   string strMsg = String.Format("Acquired image was saved to the following path:\n{0}", takenPictureFileName);
   MessageBox.Show(strMsg);

   wiaSession.EndVideoPreview();
   wiaSession.Shutdown();
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

WiaSession Class
WiaSession Members
Startup Method
Shutdown Method
SelectDevice Method
SelectDeviceDlg Method
StartVideoPreview Method
ResizeVideoPreview Method
AcquireImageFromVideo Method
EndVideoPreview Method

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.