Extract image bitmap from Media Element in DNN Modules with Silverlight 3.0

For our upcoming new release of our DotNetNuke Module¬†Silverlight Video Library with silverlight 3, a feature which previously took more than a few third party dll’s and full trust just to extract a jpg from a wmv was a nightmare.
Now with silverlight 3 comes WriteableBitMap!
You will quickly fall in love with WriteableBitMap as in just 3 lines of code you can effectively take a screenshot of any UI element and make that the contents for an Image.
See below:

public WriteableBitmap GetBitmapFromItem(FrameworkElement ctl)
WriteableBitmap wb = new WriteableBitmap((int)ctl.ActualWidth, (int)ctl.ActualHeight);
wb.Render(ctl, new TranslateTransform());
return wb;

Now just use that as the Source object for an image and presto. Since this works for all UI elements, suddenly image reflection becomes a step easier. You could even set a timer object to refresh this every few milliseconds so you get a reflection of video without the overhead of 2 x Media Elements.
Download this DotNetNuke module from our website at: https://interactivewebs.com and stay tuned for our new release.

Leave a Reply

Your email address will not be published. Required fields are marked *