Display rectangular area on expression encoder preview in windows c#
I am using expression encoder 4 in my windows c# application to show
preview of a webcam on a panel control (panelVideoPreview). Here I want to
show a rectangular shape on that preview (Panel) also. for that I have
tried to use another panel (with backColor = "transparent") but doesn't
worked.. I also found the concept of canvas for that but no result...
So how can I display on rectangular (static) area on my preivew panel.
The code which I am using for display preview is:
private void ShowPreivew()
{
try
{
EncoderDevice video = null;
EncoderDevice audio = null;
// Reading the audio and video devices from the config.
GetSelectedVideoAndAudioDevices(out video, out audio);
if (video == null)
{
return;
}
// Starts new job for preview window
_job = new LiveJob();
// Checks for a/v devices
if (video != null && audio != null)
{
// Create a new device source. We use the first audio
and video devices on the system
_deviceSource = _job.AddDeviceSource(video, audio);
// Is it required to show the configuration dialogs ?
_deviceSource.PickBestVideoFormat(panelVideoPreview.Size,
15);
// Get the properties of the device video
SourceProperties sp =
_deviceSource.SourcePropertiesSnapshot();
//// Resize the preview panel to match the video
device resolution set
//panelVideoPreview.Size = new Size(sp.Size.Width,
sp.Size.Height);
// Setup the output video resolution file as the preview
_job.OutputFormat.VideoProfile.Size = new
Size(panelVideoPreview.Size.Width,
panelVideoPreview.Size.Height);
// Display the video device properties set
toolStripStatusLabel1.Text = sp.Size.Width.ToString()
+ "x" + sp.Size.Height.ToString() + " " +
sp.FrameRate.ToString() + " fps";
// Sets preview window to winform panel hosted by xaml
window
_deviceSource.PreviewWindow = new PreviewWindow(new
HandleRef(panelVideoPreview,
panelVideoPreview.Handle));
// Make this source the active one
_job.ActivateSource(_deviceSource);
toolStripStatusLabel1.Text = "Preview activated";
}
else
{
// Gives error message as no audio and/or video
devices found
MessageBox.Show("No Video/Audio capture devices have
been found.", "Warning");
toolStripStatusLabel1.Text = "No Video/Audio capture
devices have been found.";
}
}
catch (Exception ex)
{
toolStripStatusLabel1.Text = ex.Message;
MessageBox.Show(ex.Message);
}
}
Thanks in advance.
No comments:
Post a Comment