Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Fri, 04 Jul 2008 10:30:53 +0200,    group: microsoft.public.win32.programmer.directx.video        back       


Screen Capture Using DirectX   
Hi Everybody,


I've done a small application that plays video (wmv) full screen using
the standard TMediaPlayer in Delphi 2007.

Now i'm trying to add the code to grab the screen and save it to a BMP
or JPG on local disk every N minutes.

I'm using this code found on internet :

procedure ScreenShot(x : integer; y : integer; Width : integer; Height
: integer; bm : TBitMap);
var
  dc: HDC;
begin
  //test width and height
  if ((Width = 0) OR (Height = 0)) then exit;
  bm.Width := Width;
  bm.Height := Height;

  //get the screen dc
  dc := GetDC(0);

  if (dc = 0) then exit;

  //copy from the screen to the bitmap
  BitBlt(bm.Canvas.Handle,0,0,Width,Height,Dc,x,y,SRCCOPY);


  //release the screen dc
  ReleaseDc(0, dc);
end;

This is very simple but does not work with video. It return a black
screen !

In the last two days I' ve found that the reason of the failure is HW
acceleration of the Video Card. If I disable that function then the
Software works, but obviously i can't disable HW Acceleration.

Someone told me that I have to use DirectDraw / DirectX API because
TMediaPlayer uses overlay but I don't know nothing about this API's

Does anybody have some sample code to do this screen capture function
using directdraw?


Thank you

Luca
date: Fri, 04 Jul 2008 10:30:53 +0200   author:   MaHi

Re: Screen Capture Using DirectX   
From: "MaHi"

> In the last two days I' ve found that the reason of the
> failure is HW acceleration of the Video Card. If I
> disable that function then the Software works, but
> obviously i can't disable HW Acceleration.
>
> Someone told me that I have to use DirectDraw / DirectX
> API because TMediaPlayer uses overlay but I don't know
> nothing about this API's
>
> Does anybody have some sample code to do this screen
> capture function using directdraw?

Read the whole thread linked from Q10 in my FAQ (link 
below).



-- 
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm
date: Fri, 4 Jul 2008 11:55:50 -0400   author:   Alessandro Angeli

Re: Screen Capture Using DirectX   
On Fri, 4 Jul 2008 11:55:50 -0400, "Alessandro Angeli" 

>Read the whole thread linked from Q10 in my FAQ (link 
>below).

Dear Alessandro,

Thank for your support.

I'm trying to understand the meanings of your posts...

I use Delphi and usually I work on Database projects. Then will be
difficult to solve that problem, but i have to try.

Bye.

Luca
date: Mon, 07 Jul 2008 10:04:51 +0200   author:   MaHi

Re: Screen Capture Using DirectX   
On Fri, 4 Jul 2008 11:55:50 -0400, "Alessandro Angeli" 

>Read the whole thread linked from Q10 in my FAQ (link 
>below).

Dear Alessandro,


I would like to give you some more details because i think that maybe
all could be more simple compared to what you explain in that
messages.

I have to make full screen snapshot by code inside the application
that is displayed full screen on the PC!

Using Delphi I wrote an application that simply display movies (WMV)
full screen. The same application has to take screenshot of itself to
confirm to the user that the video running at a fixed Date/Time is the
one planned in a schedule.

This scenario could simplify the solution of my problem?

Thank you.

Luca
date: Mon, 07 Jul 2008 10:43:20 +0200   author:   MaHi

Re: Screen Capture Using DirectX   
From: "MaHi"

> This scenario could simplify the solution of my problem?

If you were to use DirectShow directly, it would because you 
would be able to either locally disable the overlay so that 
you can grab the picture or get a snapshot from the video 
renderer or insert a grabbing filter before the video 
renderer. But you are using a blackbox player so, unless it 
gives you access to its internal graph (assuming it uses 
DirectShow internally), the only simplification is that you 
don't have to inject the hooking code since the player is 
already in your own process.


-- 
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm
date: Mon, 7 Jul 2008 12:40:45 -0400   author:   Alessandro Angeli

Re: Screen Capture Using DirectX   
On Mon, 7 Jul 2008 12:40:45 -0400, "Alessandro Angeli"
 wrote:


>If you were to use DirectShow directly, it would because you 
>would be able to either locally disable the overlay so that 
>you can grab the picture or get a snapshot from the video 
>renderer or insert a grabbing filter before the video 
>renderer. But you are using a blackbox player so, unless it 
>gives you access to its internal graph (assuming it uses 
>DirectShow internally), the only simplification is that you 
>don't have to inject the hooking code since the player is 
>already in your own process.

TMediaPlayer use MCI Technology and i think it is older than
directx/directshow technologies.

For other purposes i'm thinking to change from TMediaPlayer to Windows
Media Player ActiveX (TWindowsMediaPlayer). 

This choice could change something about the "screen capture" issue ?

Thanks.

Luca
date: Tue, 08 Jul 2008 11:48:49 +0200   author:   MaHi

Re: Screen Capture Using DirectX   
From: "MaHi"

> TMediaPlayer use MCI Technology and i think it is older
> than directx/directshow technologies.

MCI doesn't know how to play anything and it relies on MCI 
drivers. The MCI driver that supports WMV uses DirectShow 
internally.

> For other purposes i'm thinking to change from
> TMediaPlayer to Windows Media Player ActiveX
> (TWindowsMediaPlayer).
>
> This choice could change something about the "screen
> capture" issue ?

You would still not be able to disable the overlay or to 
access the renderer directly. You can DirectShow directly 
instead. It is more or less as easy as using WMP (easier in 
some respects) and, if you can access automation (aka 
ActiveX) classes like WMP, you should be able to access the 
automation wrapper in quartz.dll, which is more than 
adequate to play WMV files:

http://msdn.microsoft.com/en-us/library/ms787852(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms783712(VS.85).aspx

(Notice that VB6 simply means automation-aware.)

-- 
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm
date: Tue, 8 Jul 2008 14:18:15 -0400   author:   Alessandro Angeli

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us