|
|
|
date: Fri, 04 Jul 2008 10:31:09 +0200,
group: microsoft.public.win32.programmer.directx.graphics
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:31:09 +0200
author: MaHi
|
|