DirectShow和Cplus Plus [英] directshow and cplus plus
问题描述
每个人都有一个小问题,我需要使用DirectShow和C ++创建一个应用程序捕获图像,详细信息在这里
我需要捕获图像自动检测和手动
能够配置输出和相机缩放等...
我已经达到捕获图像并将其保存在bmp中的阶段了
我已经停止在msdn中搜索,没有任何东西
我可能还不太了解DirectShow [使用哪种拟合器以及如何在这些过滤器之间组合]
我希望我能为我的问题找到避难所
第二个问题是,是否有任何方法可以设计用户界面,而不是在win32中手动创建每个组件?
hi every one i got a little problem i need to create a app capture image with directshow and c++ here the details
i need to capture image autodetect and manual
ability to configure the output and camera zoom etc ...
i have reached the phase of capturing image and save it in bmp
and i have stopped seeking in msdn without any stuff
may i haven''t understand directshow very well [what fitler to use and how to combine between those filters ]
i hope i will find a refuge for my questions
and the second question is if there is any way to design the user''s interface without instead of creating every component by hand in win32 ?
推荐答案
If you want simulate the printscreen in C++.
Try this small example then...
#include <windows.h>
char EditText[256];
int EditTextLength;
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
char szClassName[ ] = "WindowsApp";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nCmdShow)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default colour as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Clipboard Windows App", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nCmdShow);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HWND hwndButton;
static HWND hwndEdit;
HGLOBAL hGlobal;
PSTR pGlobal;
switch (message) /* handle the messages */
{
case WM_CREATE:
hwndButton = CreateWindow ( TEXT ("button"),"Cut Text",WS_CHILD|WS_VISIBLE|1,55,100,100,25,hwnd,(HMENU) 1,((LPCREATESTRUCT) lParam) -> hInstance,NULL);
hwndEdit = CreateWindow (TEXT ("edit"),NULL,WS_CHILD| ES_LEFT|WS_BORDER| WS_VISIBLE,55, 50, 100, 25, hwnd,
(HMENU) 1,((LPCREATESTRUCT) lParam) -> hInstance ,NULL);
return 0;
case WM_COMMAND:
switch (wParam)
{
case 1:
EditTextLength = GetWindowTextLength(hwndEdit) +1;
GetWindowText(hwndEdit, EditText, EditTextLength);
hGlobal = GlobalAlloc(GHND|GMEM_SHARE,
EditTextLength*sizeof (char));
pGlobal = (char*)GlobalLock (hGlobal);
strcpy (pGlobal, EditText);
GlobalUnlock(hGlobal);
OpenClipboard(hwnd);
EmptyClipboard();
SetClipboardData(CF_TEXT, hGlobal);
CloseClipboard();
break;
}
return 0;
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
</windows.h>
我使用ISampleGrabber获取缓冲区并将其转换为图像
i have used the ISampleGrabber to get buffer and convert it to image
这篇关于DirectShow和Cplus Plus的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!