I’m showing video stream in MediaElement (the stream is not from server machine), when the user clicks button I want to show captured frame in Image control, and then user can save this image to file).
My code looks like this:
private void TakePicture(object sender, RoutedEventArgs e)
{
WriteableBitmap writeableBitmap = new WriteableBitmap(uiMediaElement, null);
uiImage.Source = writeableBitmap;
}
private void SaveImage(object sender, RoutedEventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
if (saveFileDialog.ShowDialog() == true)
{
Stream stream = saveFileDialog.OpenFile();
var extendedImage = uiImage.ToImage(); //this is extension method from ImageTools library uiElement.ToImage()
extendedImage.WriteToStream(stream);
}
}
The probem is that I get exception:
WriteableBitmap has protected content. Pixel access is not allowed.
Take a look to WriteableBitmap with MediaElement thread on forums.silverlight.net.
From that post