SaveStillDIB Method

Summary
Saves a snapshot from the running stream to a file as a device-independent bitmap(DIB).
Syntax
C#
VB
C++
public virtual void SaveStillDIB( 
   string fileName, 
   int timeOut 
) 
Public Overridable Sub SaveStillDIB( _ 
   ByVal fileName As String, _ 
   ByVal timeOut As Integer _ 
)  
public: 
virtual void SaveStillDIB(  
   String^ fileName, 
   int timeOut 
)  

Parameters

fileName
A string that represents the filename to which to save the DIB.

timeOut
The timeout period in milliseconds. This method fails if it is not able to take the DIB in the specified time. Use -1 to wait infinitely until a DIB is snapped.

Remarks

Saves a snapshot, as a DIB, from the running stream to the specified filename. This method will not return until the specified timeout occurs or the DIB is snapped.

Example
C#
VB
using Leadtools; 
using Leadtools.Multimedia; 
using LeadtoolsMultimediaExamples.Fixtures; 
 
public CaptureCtrlForm _form = new CaptureCtrlForm(); 
public CaptureCtrl _capturectrl = null; 
 
public bool _result = false; 
string _dibFile = Path.Combine(LEAD_VARS.MediaDir, "CaptureCtrl_SaveStillDIB.dib"); 
 
public void SaveStillDIBExample() 
{ 
   // reference the capture control 
   _capturectrl = _form.CaptureCtrl; 
 
   try 
   { 
      // select a video capture device 
      if (_capturectrl.VideoDevices["USB"] == null) 
         throw new Exception("No USB video device available"); 
 
      _capturectrl.VideoDevices["USB"].Selected = true; 
 
      // set a video compressor for the capture file 
      _capturectrl.VideoCompressors.Mpeg4.Selected = true; 
 
      // start the capture 
      _capturectrl.StartCapture(CaptureMode.Still); 
 
      // save the still DIB to a file 
      _capturectrl.SaveStillDIB(_dibFile, -1); 
 
      // stop the capture 
      _capturectrl.StopCapture(); 
 
      // check for the capture file and set the result 
      if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), _dibFile))) 
         _result = true; 
   } 
   catch (Exception) 
   { 
      _result = false; 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string MediaDir = @"C:\LEADTOOLS21\Media"; 
} 
Imports Leadtools 
Imports Leadtools.Multimedia 
Imports LeadtoolsMultimediaExamples.Fixtures 
 
Public _form As CaptureCtrlForm = New CaptureCtrlForm() 
Public _capturectrl As CaptureCtrl = Nothing 
 
Public _result As Boolean = False 
Private _dibFile As String = Path.Combine(LEAD_VARS.MediaDir, "CaptureCtrl_SaveStillDIB.dib") 
 
Public Sub SaveStillDIBExample() 
   ' reference the capture control 
   _capturectrl = _form.CaptureCtrl 
 
   Try 
      ' select a video capture device 
      If _capturectrl.VideoDevices("USB") Is Nothing Then 
         Throw New Exception("No USB video device available") 
      End If 
 
      _capturectrl.VideoDevices("USB").Selected = True 
 
      ' set a video compressor for the capture file 
      _capturectrl.VideoCompressors.Mpeg4.Selected = True 
 
      ' start the capture 
      _capturectrl.StartCapture(CaptureMode.Still) 
 
      ' save the still DIB to a file 
      _capturectrl.SaveStillDIB(_dibFile, -1) 
 
      ' stop the capture 
      _capturectrl.StopCapture() 
 
      ' check for the capture file and set the result 
      If File.Exists(Path.Combine(Directory.GetCurrentDirectory(), _dibFile)) Then 
         _result = True 
      End If 
   Catch e1 As Exception 
      _result = False 
   End Try 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
   Public Const MediaDir As String = "C:\LEADTOOLS21\Media" 
End Class 
Requirements

Target Platforms

Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Multimedia Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.