C# ScreenCaputre on Github
void dump_buffer()
{
IDirect3DSurface9* pRenderTarget=NULL;
IDirect3DSurface9* pDestTarget=NULL;
const char file[] = "Pickture.bmp";
// sanity checks.
if (Device == NULL)
return;
// get the render target surface.
HRESULT hr = Device->GetRenderTarget(0, &pRenderTarget);
// get the current adapter display mode.
//hr = pDirect3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&d3ddisplaymode);
// create a destination surface.
hr = Device->CreateOffscreenPlainSurface(DisplayMde.Width,
DisplayMde.Height,
DisplayMde.Format,
D3DPOOL_SYSTEMMEM,
&pDestTarget,
NULL);
//copy the render target to the destination surface.
hr = Device->GetRenderTargetData(pRenderTarget, pDestTarget);
//save its contents to a bitmap file.
hr = D3DXSaveSurfaceToFile(file,
D3DXIFF_BMP,
pDestTarget,
NULL,
NULL);
// clean up.
pRenderTarget->Release();
pDestTarget->Release();
}
using System;
using System.Drawing;
using Microsoft.Expression.Encoder.ScreenCapture;
// Added references to:
// Microsoft.Expression.Encoder
// Microsoft.Expression.Encoder.Types
// Microsoft.Expression.Encoder.Utilities
// WindowsBase
// System.Drawing (for Rectangle)
namespace scrcap
{
class Program
{
static void Main(string[] args)
{
ScreenCaptureJob job = new ScreenCaptureJob();
// You can capture a window by setting its coordinates here
job.CaptureRectangle = new Rectangle(100, 100, 200, 200);
// Include the mouse pointer in the captured video
job.CaptureMouseCursor = true;
// Outfile U can transcode the xesc file to something else later.
// Note that's silently does nothing if the file already exists.
job.OutputScreenCaptureFileName = @"C:\Windows\Temp\capture.xesc";
// Do some capture
job.Start();
// Wait for a keypress
Console.ReadKey();
// And stop
job.Stop();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Diagnostics;
using BytescoutScreenCapturingLib; //bytescout screencapturing activex object
namespace SimpleCaptureCSharp
{
class Program
{
static void Main(string[] args)
{
// create new screen capturer objec
CapturerClass
capturer =
new
CapturerClass
();
capturer.
CapturingType
= CaptureAreaType.
catScreen
;
// set capturing area type to catScreen to capture whole screen
capturer.
OutputFileName
= "EntireScreenCaptured.wmv";
// set output video filename to .WMV or .AVI file
// set output video width and height
capturer.
OutputWidth
=
640
;
capturer.
OutputHeight
=
480
;
// uncomment 2 set Bytescout Lossless Video format output video compression
// do not forget to set file to .avi format if you use Video Codec Name
// capturer.CurrentVideoCodecName = "Bytescout Lossless";
capturer.
Run
(); // run screen video capturing
Thread.
Sleep
(
15000
); // wait for 15 seconds
capturer.
Stop
(); // stop video capturing
Process.
Start
("EntireScreenCaptured.wmv");
}
}
}
Keine Kommentare:
Kommentar veröffentlichen