2987
- 收藏
- 点赞
- 分享
- 举报
Windows Mobile 相机操作
本文讲述了如何在Windows Mobile下启动相机的功能
当前测试环境:
IDE: VS2008
SDK: Windows Mobile 5.0
参考:
《在Windows Mobile上使用GDI+》《Windows Mobile图像系统开发》《Windows Mobile三维编程》
例子:
请下载本文附带例子工程
技术实现:
要实现启动Windows Mobile相机功能,主要使用到一个API: SHCameraCapture(),该函数主要启动一个相机拍摄的对话框,用来拍摄相片和视频。
函数原型:
HRESULT SHCameraCapture (
PSHCAMERACAPTURE pshcc
);
参数:
pshcc
[in/out] 参考SHCAMERACAPTURE 结构体, 它包含了初始化 SHCameraCapture 函数的信息, 并且包含完全合法的相片或视频的路径名的参考信息。
返回值:
S_OK
执行成功。
S_FALSE
用户终止相机拍摄的对话框。
E_OUTOFMEMORY
没有足够的内存存储图片或视频。
E_INVALIDARG
一个不合法的冲突。
"HRESULT_FROM_WIN32 (ERROR_RESOURCE_DISABLED)"
该错误表明相机无法使用是由于某个特定的条件值引起。
参考代码:
VOID StartCamera(HWND hwndDlg)
{
HRESULT hr;
HRESULT hReturn;
SHCAMERACAPTURE shcc;
LONG lCheckStateInitialDir;
LONG lCheckStateDefaultFileName;
LONG lCheckStateTitle;
LONG lCheckStateResolution;
LONG lCheckStateVideoTimeLimit;
TCHAR szInitialDir[MAX_INITIAL_DIR] = { 0 };
TCHAR szDefaultFileName[MAX_FILE_NAME] = { 0 };
TCHAR szTitle[MAX_TITLE] = { 0 };
DWORD dwResolutionWidth;
DWORD dwResolutionHeight;
DWORD dwVideoTimeLimit;
LPCTSTR szFormat;
TCHAR szMessage[MAX_MESSAGE] = { 0 };
// Get the state of the checkboxs
lCheckStateInitialDir = SendDlgItemMessage(hwndDlg, IDC_CHECK_INITIAL_DIR, BM_GETCHECK, 0, 0);
lCheckStateDefaultFileName = SendDlgItemMessage(hwndDlg, IDC_CHECK_DEFAULT_FILE_NAME, BM_GETCHECK, 0, 0);
lCheckStateTitle = SendDlgItemMessage(hwndDlg, IDC_CHECK_TITLE, BM_GETCHECK, 0, 0);
lCheckStateResolution = SendDlgItemMessage(hwndDlg, IDC_CHECK_RESOLUTION, BM_GETCHECK, 0, 0);
lCheckStateVideoTimeLimit = SendDlgItemMessage(hwndDlg, IDC_CHECK_VIDEO_TIME_LIMIT, BM_GETCHECK, 0, 0);
// Get the user inputs of the edit controls
GetDlgItemText(hwndDlg, IDC_INITIAL_DIR, szInitialDir, ARRAYSIZE(szInitialDir));
GetDlgItemText(hwndDlg, IDC_DEFAULT_FILE_NAME, szDefaultFileName, ARRAYSIZE(szDefaultFileName));
GetDlgItemText(hwndDlg, IDC_TITLE, szTitle, ARRAYSIZE(szTitle));
dwResolutionWidth = GetDlgItemInt(hwndDlg, IDC_RESOLUTION_WIDTH, NULL, FALSE);
dwResolutionHeight = GetDlgItemInt(hwndDlg, IDC_RESOLUTION_HEIGHT, NULL, FALSE);
dwVideoTimeLimit = GetDlgItemInt(hwndDlg, IDC_VIDEO_TIME_LIMIT, NULL, FALSE);
// Specify the arguments of SHCAMERACAPTURE
ZeroMemory(&shcc, sizeof(shcc));
shcc.cbSize = sizeof(shcc);
shcc.hwndOwner = hwndDlg;
shcc.pszInitialDir = (BST_UNCHECKED == lCheckStateInitialDir) ? CECAMERA_DEFAULT_INITIAL_DIR : szInitialDir;
shcc.pszDefaultFileName = (BST_UNCHECKED == lCheckStateDefaultFileName) ? CECAMERA_DEFAULT_FILE_NAME : szDefaultFileName;
shcc.pszTitle = (BST_UNCHECKED == lCheckStateTitle) ? CECAMERA_DEFAULT_TITLE : szTitle;
shcc.StillQuality = g_StillQuality;
shcc.VideoTypes = g_VideoTypes;
shcc.nResolutionWidth = (BST_UNCHECKED == lCheckStateResolution) ? CECAMERA_DEFAULT_RESOLUTION_WIDTH : dwResolutionWidth;
shcc.nResolutionHeight = (BST_UNCHECKED == lCheckStateResolution) ? CECAMERA_DEFAULT_RESOLUTION_HEIGHT : dwResolutionHeight;
shcc.nVideoTimeLimit = (BST_UNCHECKED == lCheckStateVideoTimeLimit) ? CECAMERA_DEFAULT_VIDEO_TIME_LIMIT : dwVideoTimeLimit;
shcc.Mode = g_Mode;
// Call SHCameraCapture() function
g_bCameraRunning = TRUE;
hReturn = SHCameraCapture(&shcc);
g_bCameraRunning = FALSE;
// Check the return codes of the SHCameraCapture() function
switch (hReturn)
{
case S_OK:
// The method completed successfully.
szFormat = (LPCTSTR)LoadString(g_hInstance, IDS_NOERROR, NULL, 0);
CPR(szFormat);
CHR(StringCchPrintf(szMessage, ARRAYSIZE(szMessage), szFormat, shcc.szFile));
MessageBox(hwndDlg, szMessage, g_szCaption, MB_OK | MB_ICONINFORMATION);
break;
case S_FALSE:
&am, p;nb, sp; // The user canceled the Camera Capture dialog box.
break;
case E_INVALIDARG:
// An invalid argument was specified.
szFormat = (LPCTSTR)LoadString(g_hInstance, IDS_ERROR_INVALIDARG, NULL, 0);
CPR(szFormat);
MessageBox(hwndDlg, szFormat, g_szCaption, MB_OK | MB_ICONEXCLAMATION);
break;
case E_OUTOFMEMORY:
// There is not enough memory to save the image or video.
szFormat = (LPCTSTR)LoadString(g_hInstance, IDS_ERROR_OUTOFMEMORY, NULL, 0);
CPR(szFormat);
MessageBox(hwndDlg, szFormat, g_szCaption, MB_OK | MB_ICONSTOP);
break;
case HRESULT_FROM_WIN32(ERROR_RESOURCE_DISABLED):
// The camera is disabled.
szFormat = (LPCTSTR)LoadString(g_hInstance, IDS_ERROR_CAMERADISABLED, NULL, 0);
CPR(szFormat);
MessageBox(hwndDlg, szFormat, g_szCaption, MB_OK | MB_ICONSTOP);
break;
default:
// An unknown error occurred.
szFormat = (LPCTSTR)LoadString(g_hInstance, IDS_ERROR_UNKNOWN, NULL, 0);
CPR(szFormat);
CHR(StringCchPrintf(szMessage, ARRAYSIZE(szMessage), szFormat, hReturn));
MessageBox(hwndDlg, szMessage, g_szCaption, MB_OK | MB_ICONSTOP);
break;
}
Error:
return;
}
出自:http://www.a3gs.com/BookViews.asp?InfoID=2940&classID=925&InfoType=0]
我来回答
回答0个
时间排序
认可量排序
暂无数据
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2012-12-04 11:57:50
-
2008-08-14 01:01:56
-
2012-12-04 13:07:48
-
2010-07-19 15:15:27
-
2012-12-04 11:57:10
-
2012-12-04 12:57:16
-
2012-12-04 11:51:25
-
2008-07-06 21:15:38
-
2008-05-26 22:18:30
-
2012-12-04 11:55:04
-
2012-12-04 13:08:38
-
2012-12-04 11:49:35
-
2008-08-27 23:28:34
-
2008-08-27 23:29:54
-
2012-12-04 11:46:15
-
2010-06-01 23:29:28
-
2010-06-01 23:25:04
-
2010-01-28 10:15:14
-
2012-12-04 13:04:58
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
5RK3588的DPHY0接lt6911uxe转HDMI抓帧分辨率不对
-
20求rv1106板子的sdk包或者开发板资料
-
10ss928烧录uboot失败
-
10求助,3588调试imx586和ov50c40时,按照瑞芯微的单摄8k配置好设备树后,驱动配置的8k分辨率的,但是只能抓到4k的图,且颜色偏粉
-
50帮忙解决个交叉编译的问题
-
20帮忙交叉编译个源码
-
5Hi3516CV610 如何使用SD卡升级固件
-
5cat /dev/logmpp 报错 <3>[ vi] [func]:vi_send_frame_node [line]:99 [info]:vi pic queue is full!
-
50如何获取vpss chn的图像修改后发送至vo
-
5FPGA通过Bt1120传YUV422数据过来,vi接收不到数据——3516dv500
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认