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



fileName
A string containing the name of the file in which to save the bitmap.
format
Value that represents the output file format. For a list of possible values, refer to StillFormatType enumeration values.
quality
Value that represents the compression quality. This is used only when the format parameter is StillFormatType.CMP. For a list of possible values, refer to the StillQuality enumeration values.
flags
Reserved for future use. Pass 0.
timeOut
The timeout period in milliseconds. The method will fail if it was not able to take a sample in the specified time. Use –1 to wait indefinitely until a sample is snapped.
fileName
A string containing the name of the file in which to save the bitmap.
format
Value that represents the output file format. For a list of possible values, refer to StillFormatType enumeration values.
quality
Value that represents the compression quality. This is used only when the format parameter is StillFormatType.CMP. For a list of possible values, refer to the StillQuality enumeration values.
flags
Reserved for future use. Pass 0.
timeOut
The timeout period in milliseconds. The method will fail if it was not able to take a sample in the specified time. Use –1 to wait indefinitely until a sample is snapped.
Saves a snapshot from the running stream to a file as a bitmap.

Syntax

Visual Basic (Declaration) 
Public Overridable Sub SaveStillBitmap( _
   ByVal fileName As String, _
   ByVal format As StillFormatType, _
   ByVal quality As StillQuality, _
   ByVal flags As Integer, _
   ByVal timeOut As Integer _
) 
Visual Basic (Usage)Copy Code
Dim instance As CaptureCtrl
Dim fileName As String
Dim format As StillFormatType
Dim quality As StillQuality
Dim flags As Integer
Dim timeOut As Integer
 
instance.SaveStillBitmap(fileName, format, quality, flags, timeOut)
C# 
public virtual void SaveStillBitmap( 
   string fileName,
   StillFormatType format,
   StillQuality quality,
   int flags,
   int timeOut
)
C++/CLI 
public:
virtual void SaveStillBitmap( 
   String^ fileName,
   StillFormatType format,
   StillQuality quality,
   int flags,
   int timeOut
) 

Parameters

fileName
A string containing the name of the file in which to save the bitmap.
format
Value that represents the output file format. For a list of possible values, refer to StillFormatType enumeration values.
quality
Value that represents the compression quality. This is used only when the format parameter is StillFormatType.CMP. For a list of possible values, refer to the StillQuality enumeration values.
flags
Reserved for future use. Pass 0.
timeOut
The timeout period in milliseconds. The method will fail if it was not able to take a sample in the specified time. Use –1 to wait indefinitely until a sample is snapped.

Example

Visual BasicCopy Code
Public _form As CaptureCtrlForm = New CaptureCtrlForm()
      Public _capturectrl As CaptureCtrl = Nothing
      Public _result As Boolean = False

      Public Sub SaveStillBitmapExample()
         ' reference the capture control
         _capturectrl = _form.CaptureCtrl

         ' output file
         Dim jpgFile As String = Path.Combine(LEAD_VARS.MediaDir, "CaptureCtrl_SaveStillBitmap.jpg")

         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 image to a jpeg file (note the quality factor can be a positive integer value cast as StillQuality)
            _capturectrl.SaveStillBitmap(jpgFile, StillFormatType.JPEG444, CType(9, StillQuality), 0, -1)

            ' stop the capture
            _capturectrl.StopCapture()

            ' check for the capture file and set the result
            If File.Exists(jpgFile) 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:\Program Files (x86)\LEAD Technologies\LEADTOOLS 17\Media"
End Class
C#Copy Code
public CaptureCtrlForm _form = new CaptureCtrlForm();
      public CaptureCtrl _capturectrl = null;
      public bool _result = false;

      public void SaveStillBitmapExample()
      {
         // reference the capture control
         _capturectrl = _form.CaptureCtrl;

         // output file
         string jpgFile = Path.Combine(LEAD_VARS.MediaDir,"CaptureCtrl_SaveStillBitmap.jpg");

         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 image to a jpeg file (note the quality factor can be a positive integer value cast as StillQuality)
            _capturectrl.SaveStillBitmap(jpgFile, StillFormatType.JPEG444, (StillQuality)9, 0, -1);

            // stop the capture
            _capturectrl.StopCapture();

            // check for the capture file and set the result
            if (File.Exists(jpgFile))
               _result = true;
         }
         catch (Exception)
         {
            _result = false;
         }
      }

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

Remarks

Saves a snapshot from the running stream to a file as a bitmap. This method blocks (does not return) until the timeout occurs or the sample is snapped. The following methods can also be used to obtain still images: GetStillDIB, GetStillImage, and SaveStillDIB.

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