Error processing SSI file
LEADTOOLS Multimedia (Leadtools.MediaFoundation assembly)

Show in webframe

SaveStillBitmap Method (ConvertCtrl)






A string containing the name of the file to which to save the bitmap.
A StillFormatType Value that represents the output file format.
Value that represents the compression quality. For a list of possible values, refer to Compression Quality Factors. For the StillFormatType.CMP file format only, you can use the StillQuality enumeration values.
Reserved for future use. Pass 0.
The timeout period in milliseconds. The method fails if it is not able to take a sample within the specified time period. Use -1 to wait indefinitely until a sample is captured.
Saves a snapshot from the running stream to a file as a bitmap.
Syntax
public virtual void SaveStillBitmap( 
   string fileName,
   StillFormatType format,
   int quality,
   int flags,
   int timeOut
)
'Declaration
 
Public Overridable Sub SaveStillBitmap( _
   ByVal fileName As String, _
   ByVal format As StillFormatType, _
   ByVal quality As Integer, _
   ByVal flags As Integer, _
   ByVal timeOut As Integer _
) 
'Usage
 
Dim instance As ConvertCtrl
Dim fileName As String
Dim format As StillFormatType
Dim quality As Integer
Dim flags As Integer
Dim timeOut As Integer
 
instance.SaveStillBitmap(fileName, format, quality, flags, 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 to 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. For the StillFormatType.CMP file format only, you can use the StillQuality enumeration values.
flags
Reserved for future use. Pass 0.
timeOut
The timeout period in milliseconds. The method fails if it is not able to take a sample within the specified time period. Use -1 to wait indefinitely until a sample is captured.
Remarks
This method does not return until the timeout occurs or the sample is captured.
Example
Copy Code  
Imports Leadtools
Imports Leadtools.MediaFoundation
Imports LeadtoolsMediaFoundationExamples.Fixtures

Public _result As Boolean = False
Public _form As ConvertCtrlForm = New ConvertCtrlForm()
Public _convertctrl As ConvertCtrl = Nothing
Public _bmpFile As String = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_SaveStillBitmap.bmp")
Public Sub SaveStillBitmapExample()
   ' input and output file names
   Dim inFile As String = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_Source.avi")
   Dim outFile As String = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_SaveStillBitmapExample.wmv")

   Try
      ' reference the convert control
      _convertctrl = _form.ConvertCtrl

      ' set a timer on the form to make the still bitmap
      _form.TestTimer.Interval = 5000
      AddHandler _form.TestTimer.Tick, AddressOf SaveStillBitmap_Helper

      ' select WMV target format
      _convertctrl.TargetFormat = TargetFormatType.WMV

      ' select video and audio target formats for the output
      Dim index As Integer = -1
      Dim trgvideoformats As TargetVideoFormats = _convertctrl.TargetFormats(_convertctrl.TargetFormat).VideoFormats
      index = trgvideoformats.IndexOf("{33564D57-0000-0010-8000-00AA00389B71}") ' Windows Media Video 9 (WMV)
      trgvideoformats.Selection = index
      Dim trgaudioformats As TargetAudioFormats = _convertctrl.TargetFormats(_convertctrl.TargetFormat).AudioFormats
      index = trgaudioformats.IndexOf("{00000161-0000-0010-8000-00AA00389B71}") ' Windows Media Audio (WMA)
      trgaudioformats.Selection = index

      ' set the source and target files
      _convertctrl.SourceFile = inFile
      _convertctrl.TargetFile = outFile

      ' convert it now!
      _convertctrl.StartConvert()

      ' now start the test timer for the still capture
      _form.TestTimer.Start()
   Catch e1 As Exception
      _result = False
   End Try

   ' we'll loop on the state and pump messages for this example.
   ' but you should not need to if running from a Windows Forms application.
   Do While _convertctrl.State = ConvertState.Running
      Application.DoEvents()
   Loop
End Sub

Public Sub SaveStillBitmap_Helper(ByVal sender As Object, ByVal e As EventArgs)
   ' cancel the timer
   _form.TestTimer.Stop()

   ' try to simulate an error condition
   _convertctrl.SaveStillBitmap(_bmpFile, StillFormatType.BMP, 0, 0, -1)

   ' check for the capture file and set the result
   If File.Exists(Path.Combine(Directory.GetCurrentDirectory(), _bmpFile)) Then
      _result = True
   End If
End Sub

Public NotInheritable Class LEAD_VARS
Public Const MediaDir As String = "C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 19\Media"
End Class
using Leadtools;
using Leadtools.MediaFoundation;
using LeadtoolsMediaFoundationExamples.Fixtures;

public bool _result = false;
public ConvertCtrlForm _form = new ConvertCtrlForm();
public ConvertCtrl _convertctrl = null;
public string _bmpFile = Path.Combine(LEAD_VARS.MediaDir,"ConvertCtrl_SaveStillBitmap.bmp");
public void SaveStillBitmapExample()
{
   // input and output file names
   string inFile = Path.Combine(LEAD_VARS.MediaDir,"ConvertCtrl_Source.avi");
   string outFile = Path.Combine(LEAD_VARS.MediaDir,"ConvertCtrl_SaveStillBitmapExample.WMV");

   try
   {
      // reference the convert control
      _convertctrl = _form.ConvertCtrl;

      // set a timer on the form to make the still bitmap
      _form.TestTimer.Interval = 5000;
      _form.TestTimer.Tick += new EventHandler(SaveStillBitmap_Helper);

      // select the target format
      _convertctrl.TargetFormat = TargetFormatType.WMV;

      // select video and audio target formats for the output
      int index = -1;
      TargetVideoFormats targetvideoformats = _convertctrl.TargetFormats[_convertctrl.TargetFormat].VideoFormats;
      index = targetvideoformats.IndexOf("{33564D57-0000-0010-8000-00AA00389B71}");// Windows Media Video 9 (WMV)
      targetvideoformats.Selection = index;
      TargetAudioFormats targetaudioformats = _convertctrl.TargetFormats[_convertctrl.TargetFormat].AudioFormats;
      index = targetaudioformats.IndexOf("{00000161-0000-0010-8000-00AA00389B71}");// Windows Media Audio (WMA)
      targetaudioformats.Selection = index;

      // set the source and target files
      _convertctrl.SourceFile = inFile;
      _convertctrl.TargetFile = outFile;

      // convert it now!
      _convertctrl.StartConvert();

      // now start the test timer for the still capture
      _form.TestTimer.Start();
   }
   catch (Exception)
   {
      _result = false;
   }

   // we'll loop on the state and pump messages for this example.
   // but you should not need to if running from a Windows Forms application.
   while (_convertctrl.State == ConvertState.Running)
      Application.DoEvents();
}

public void SaveStillBitmap_Helper(object sender, EventArgs e)
{
   // cancel the timer
   _form.TestTimer.Stop();

   // try to simulate an error condition
   _convertctrl.SaveStillBitmap(_bmpFile, StillFormatType.BMP, 0, 0, -1);

   // check for the capture file and set the result
   if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), _bmpFile)))
      _result = true;
}

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

Target Platforms

See Also

Reference

ConvertCtrl Class
ConvertCtrl Members

Error processing SSI file
Leadtools.MediaFoundation requires a Multimedia or Multimedia Suite license and unlock key. For more information, refer to: LEADTOOLS Toolkit Features