Saves a snapshot from the running stream to a file as a bitmap.
public virtual void SaveStillBitmap(string fileName,Leadtools.Mediafoundation.StillFormatType format,int quality,int flags,int timeOut)
Public Overridable Sub SaveStillBitmap( _ByVal fileName As String, _ByVal format As Leadtools.Mediafoundation.StillFormatType, _ByVal quality As Integer, _ByVal flags As Integer, _ByVal timeOut As Integer _)
public:virtual void SaveStillBitmap(String^ fileName,Leadtools.Mediafoundation.StillFormatType format,int quality,int flags,int timeOut)
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.
This method does not return until the timeout occurs or the sample is captured.
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 namesstring 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 outputint 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 resultif (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";}
Imports LeadtoolsImports Leadtools.MediaFoundationImports LeadtoolsMediaFoundationExamples.FixturesPublic _result As Boolean = FalsePublic _form As ConvertCtrlForm = New ConvertCtrlForm()Public _convertctrl As ConvertCtrl = NothingPublic _bmpFile As String = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_SaveStillBitmap.bmp")Public Sub SaveStillBitmapExample()' input and output file namesDim 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 = 5000AddHandler _form.TestTimer.Tick, AddressOf SaveStillBitmap_Helper' select WMV target format_convertctrl.TargetFormat = TargetFormatType.WMV' select video and audio target formats for the outputDim index As Integer = -1Dim trgvideoformats As TargetVideoFormats = _convertctrl.TargetFormats(_convertctrl.TargetFormat).VideoFormatsindex = trgvideoformats.IndexOf("{33564D57-0000-0010-8000-00AA00389B71}") ' Windows Media Video 9 (WMV)trgvideoformats.Selection = indexDim trgaudioformats As TargetAudioFormats = _convertctrl.TargetFormats(_convertctrl.TargetFormat).AudioFormatsindex = 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 = FalseEnd 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.RunningApplication.DoEvents()LoopEnd SubPublic 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 resultIf File.Exists(Path.Combine(Directory.GetCurrentDirectory(), _bmpFile)) Then_result = TrueEnd IfEnd SubPublic NotInheritable Class LEAD_VARSPublic Const MediaDir As String = "C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 19\Media"End Class
|
Products |
Support |
Feedback: SaveStillBitmap Method (ConvertCtrl) - Leadtools.MediaFoundation |
Introduction |
Help Version 19.0.2017.6.16
|

Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.