Resize Live Video to a Window This source code snippet illustrates how to resize a live video stream to fit a window.
When displaying a live image data stream, it is often desirable to resize the stream to fit a window. The following programming example illustrates how to crop the image data stream. Please note that only the image data stream's display is cropped and not the data stream itself (actual image data stream remains unchanged). The sample application's window looks as follows: The program starts by activating the built-in dialog box, that the end-user may use to select a video capture device (.ShowDeviceSettingsDialog). Before resizing the video display, IC Imaging Control has to be told not to use the default size of the image data stream (by default, this is the video format's resolution). To achieve this, .LiveDisplayDefault simply has to be set to false. The window's .Height and .Width properties are used to determine the size of the image data stream display. The properties .LiveDisplayHeight and .LiveDisplayWidth are set to IC Imaging Control's .Height and .Width. This resizes the display of the live video to the current size of the IC Imaging Control window on the form. C# private void Form1_Load(object sender, System.EventArgs e) { icImagingControl1.ShowDeviceSettingsDialog(); if( !icImagingControl1.DeviceValid ) { Close(); return; } icImagingControl1.LiveDisplayDefault = false; icImagingControl1.LiveDisplayHeight = icImagingControl1.Height; icImagingControl1.LiveDisplayWidth = icImagingControl1.Width; icImagingControl1.LiveStart(); } |