View Full Version : Capture Frame to image file programmatically
Starduster
25th July 2008, 14:41
I have an application that uses WMP to display video in a web page. I'd like to allow a user to click a button and save the current frame to a .jpg, .gif, or .png.
I have complete control over the web server and the user's PC so I can entertain a number of different program or command line options on the web server or the PC as well as where to store the file. The key is to be able to make it transparent to the user.
Can anyone point me in the right direction on this?
Many thanks!
JohnnyMalaria
25th July 2008, 23:01
Unfortunately, the WMP object doesn't expose a method to capture the content of the video window so you'll have to resort to WIN32 GDI functions to do it.
The main WMP window has the following attributes:
Caption: Windows Media Player
Class: WMP Skin Host
The video window within the WMP object has the following attributes:
Caption: WMPVideoWindow
Class: WMPVideoWindow
So you could use something along the lines of:
Use FindWindow(..) to locate the WMP top-level window
Use FindWindow(..) to locate the window listed above
Follow Capturing an image (http://msdn.microsoft.com/en-us/library/ms532314.aspx)from the MS Platform SDK
Then use the GDI+ API to convert the bitmap to JPG, PNG or GIF (see the GDI+ documentation).
Note, to get the content of the window you will most likely have to disable video acceleration either system wide or via the Performance tab in WMP itself. There maybe a programmatic or registry way to do this but I can't find one.
HTH
Starduster
26th July 2008, 00:23
Many thanks! I'll give that a go and see what we can get done!
Thanks again!
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.