SaveStillBitmap Method

Summary
Saves a snapshot from the running stream to a file as a bitmap.
Syntax
C#
C++/CLI
public virtual void SaveStillBitmap( 
   string fileName, 
   StillFormatType format, 
   int quality, 
   int flags, 
   int timeOut 
) 
public: 
virtual void SaveStillBitmap(  
   String^ fileName, 
   StillFormatType format, 
   int quality, 
   int flags, 
   int timeOut 
)  

Parameters

fileName
A string containing the name of the file in which to save the bitmap.

format
A StillFormatType value that represents the output file format.

quality
Value that represents the compression quality. For a list of possible values, refer to Compression Quality Factors.

If the StillFormatType parameter is equal to StillFormatType.CMP, the StillQuality enumeration values can be used.

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.

Remarks

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

.

Example
C#
using Leadtools; 
using Leadtools.MediaFoundation; 
using LeadtoolsMediaFoundationExamples.Fixtures; 
 
 
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; 
 
      // start the capture 
      _capturectrl.StartCapture(CaptureMode.Still); 
 
      // save the still image to a jpeg file 
      _capturectrl.SaveStillBitmap(jpgFile, StillFormatType.JPEG444, (int)StillQuality.MC, 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:\LEADTOOLS22\Media"; 
} 
Requirements

Target Platforms

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

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