如何完成截屏? [英] How can complete the screen capture?
本文介绍了如何完成截屏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想尝试做一个屏幕捕获软件.
但是我不知道从哪里开始.
要做的事情的软件:
屏幕数据存储视频数据.
您可以再次播放.
另一位主持人也可以看到我的屏幕.
请帮助我.
I want to try to do a screen capture software.
But I don''t know where to start.
The software of things to do:
Screen data storage for video data.
You can play it again.
Another host can also see my screen.
Please help me on this.
推荐答案
如果您使用的是Google,那么您会发现很多.我只为您提供一些,希望对您有所帮助:
1. 捕获屏幕的各种方法 [ Barry的屏幕截图 [屏幕截图(基于简单Win32对话框) [ ^ ]
If you Google, you will find many. I am providing you few, hope these helps :
1. Various methods for capturing the screen[^]
2. Barry''s Screen Capture[^]
3. Screen Capture (Simple Win32 Dialog Based)[^]
这是一个简单的d3d屏幕截图,您可能需要从资源文件夹中的d3d安装中获取d3d9.h:
Here is a simple d3d screen capture, you may need d3d9.h from your d3d install in your resources folder:
// usage: TakeScreenShot("C:\\Yourname.bmp");
void TakeScreenShot(char* file_name)
{
LPDIRECT3D8 pD3D = NULL;
LPDIRECT3DDEVICE8 device = NULL;
pD3D = Direct3DCreate8( D3D_SDK_VERSION );
int nMode = 0;
D3DDISPLAYMODE d3ddm;
bool bDesiredAdaptorModeFound = false;
int nMaxAdaptorModes = pD3D->GetAdapterModeCount( 0 ); //0, 22
for( nMode = 0; nMode < nMaxAdaptorModes; ++nMode ) {
pD3D->EnumAdapterModes( D3DADAPTER_DEFAULT, nMode, &d3ddm );
if( d3ddm.Width != 640 || d3ddm.Height != 480 )
continue;
if( d3ddm.Format != D3DFMT_X8R8G8B8 )
continue;
if( d3ddm.RefreshRate != 75 )
continue;
bDesiredAdaptorModeFound = true;
break;
}
pD3D->CheckDeviceType( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DFMT_X8R8G8B8, FALSE );
pD3D->CheckDeviceFormat( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D16 );
D3DCAPS8 d3dCaps;
pD3D->GetDeviceCaps( D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL, &d3dCaps );
DWORD dwBehaviorFlags = 0;
if( d3dCaps.VertexProcessingCaps != 0 )
dwBehaviorFlags |= D3DCREATE_HARDWARE_VERTEXPROCESSING;
else
dwBehaviorFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
D3DPRESENT_PARAMETERS d3dpp;
memset(&d3dpp, 0, sizeof(d3dpp));
d3dpp.Windowed = TRUE;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferWidth = 1600;
d3dpp.BackBufferHeight = 1200;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, GetDesktopWindow(), dwBehaviorFlags, &d3dpp, &device ); //Gets Desktop Area
int screenx = GetSystemMetrics(SM_CXSCREEN);
int screeny = GetSystemMetrics(SM_CYSCREEN);
LPDIRECT3DSURFACE8 frontbuf = 0;
device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &frontbuf);
device->CreateImageSurface(screenx, screeny, D3DFMT_A8R8G8B8, &frontbuf);
HRESULT hr = device->GetFrontBuffer(frontbuf);
D3DXSaveSurfaceToFile(file_name, D3DXIFF_BMP, frontbuf, NULL, NULL);
frontbuf->Release();
device->Release();
pD3D->Release();
}
这篇关于如何完成截屏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文