public void ResizeVideoPreview(
bool stretchToFitParent
)
stretchToFitParent
Specifies whether the video display is stretched to fit the parent window. Possible values are:
Value |
Meaning |
true | Stretch the video preview to fit the parent window. |
false | Video is displayed in a supported resolution smaller than the parent window. |
This function will start the video stream preview in the window or the control specified through the owner parameter.
This function will internally set the image directory of the captured still images to the device's default path unless you changed the destination images directory property yourself as mentioned in the WiaSession.AcquireImageFromVideo documentation.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Wia;
public void IsVideoPreviewAvailableExample(IntPtr parent)
{
if (!WiaSession.IsAvailable(WiaVersion.Version1))
{
Console.WriteLine("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)
{
Console.WriteLine("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)
{
Console.WriteLine("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);
Console.WriteLine(strMsg);
wiaSession.EndVideoPreview();
wiaSession.Shutdown();
}