Windows mobile 如何在windows mobile 6应用程序中使用摄像头

Windows mobile 如何在windows mobile 6应用程序中使用摄像头,windows-mobile,windows-mobile-6.5,windows-mobile-6,Windows Mobile,Windows Mobile 6.5,Windows Mobile 6,我正在创建windows mobile 6.5应用程序。在那个应用程序中,我必须使用像图片和视频这样的相机操作。 有一个表单包含两个按钮,一个用于图片,另一个用于视频。若用户点击图片按钮,相机启动,点击图片并将图片保存到指定位置。同样的步骤也适用于从应用程序捕获视频 谢谢你的帮助 提前感谢查看该功能。它可以完全按照您指定的方式执行:使用内置摄像头应用程序将视频或图像文件保存到用户定义的位置。使用此API创建应用程序只需几分钟。请查看该函数。它可以完全按照您指定的方式执行:使用内置摄像头应用程序将

我正在创建windows mobile 6.5应用程序。在那个应用程序中,我必须使用像图片和视频这样的相机操作。 有一个表单包含两个按钮,一个用于图片,另一个用于视频。若用户点击图片按钮,相机启动,点击图片并将图片保存到指定位置。同样的步骤也适用于从应用程序捕获视频

谢谢你的帮助


提前感谢

查看该功能。它可以完全按照您指定的方式执行:使用内置摄像头应用程序将视频或图像文件保存到用户定义的位置。使用此API创建应用程序只需几分钟。

请查看该函数。它可以完全按照您指定的方式执行:使用内置摄像头应用程序将视频或图像文件保存到用户定义的位置。让应用程序使用此API只需几分钟。

最简单的方法是在上使用,此方法独立于硬件。请参见此示例:

using System.ComponentModel;
using System.IO;
using System.Windows.Forms;
using Microsoft.WindowsMobile.Forms;

namespace CameraExample
{

    public class Form1 : Form
    {
        #region Code Designer.cs
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private IContainer components;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.btnPhoto = new System.Windows.Forms.Button();
            this.btnVideo = new System.Windows.Forms.Button();
            this.sfdFile = new System.Windows.Forms.SaveFileDialog();
            this.SuspendLayout();
            // 
            // btnPhoto
            // 
            this.btnPhoto.Location = new System.Drawing.Point(3, 3);
            this.btnPhoto.Name = "btnPhoto";
            this.btnPhoto.Size = new System.Drawing.Size(72, 20);
            this.btnPhoto.TabIndex = 0;
            this.btnPhoto.Text = "Photo";
            this.btnPhoto.Click += new System.EventHandler(this.btnPhoto_Click);
            // 
            // btnVideo
            // 
            this.btnVideo.Location = new System.Drawing.Point(81, 3);
            this.btnVideo.Name = "btnVideo";
            this.btnVideo.Size = new System.Drawing.Size(72, 20);
            this.btnVideo.TabIndex = 1;
            this.btnVideo.Text = "Video";
            this.btnVideo.Click += new System.EventHandler(this.btnVideo_Click);
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
            this.AutoScroll = true;
            this.ClientSize = new System.Drawing.Size(240, 294);
            this.Controls.Add(this.btnVideo);
            this.Controls.Add(this.btnPhoto);
            this.MinimizeBox = false;
            this.Name = "Form1";
            this.Text = "Form1";
            this.ResumeLayout(false);

        }

        #endregion

        private Button btnPhoto;
        private SaveFileDialog sfdFile;
        private Button btnVideo;

        #endregion

        public Form1()
        {
            InitializeComponent();
        }

        enum CameraType
        {
            Photo,
            Video
        }

        private void btnPhoto_Click(object sender, System.EventArgs e)
        {
            sfdFile.FileName = "photo.jpg";
            sfdFile.Filter = "Image Files |*.jpg";
            if (sfdFile.ShowDialog() == DialogResult.OK)
                ShowCamera(sfdFile.FileName, CameraType.Photo);
        }

        private void btnVideo_Click(object sender, System.EventArgs e)
        {
            sfdFile.FileName = "video.wmv";
            sfdFile.Filter = "Video Files |*.wmv";
            if (sfdFile.ShowDialog() == DialogResult.OK)
                ShowCamera(sfdFile.FileName, CameraType.Video);
        }

        private void ShowCamera(string FileName, CameraType typeOfCamera)
        {
            FileInfo fi = new FileInfo(FileName);
            CameraCaptureDialog camera = new CameraCaptureDialog
            {
                InitialDirectory = fi.DirectoryName,
                DefaultFileName = fi.Name,
                Mode = typeOfCamera == CameraType.Photo ? CameraCaptureMode.Still : CameraCaptureMode.VideoWithAudio,
                VideoTypes = CameraCaptureVideoTypes.All,
                Title = "Using the camera"
            };

            if (camera.ShowDialog() == DialogResult.OK)
                MessageBox.Show((typeOfCamera == CameraType.Photo ? "Photo " : "Video ") + FileName + " Captured");
            else
                MessageBox.Show("Not Captured");
        }
    }
}
使用System.ComponentModel;
使用System.IO;
使用System.Windows.Forms;
使用Microsoft.WindowsMobile.Forms;
名称空间摄影机示例
{
公开课表格1:表格
{
#区域代码设计器.cs
/// 
///必需的设计器变量。
/// 
私人IContainer组件;
/// 
///清理所有正在使用的资源。
/// 
///如果应释放托管资源,则为true;否则为false。
受保护的覆盖无效处置(布尔处置)
{
if(处理和(组件!=null))
{
组件。Dispose();
}
基地。处置(处置);
}
#区域Windows窗体设计器生成的代码
/// 
///设计器支持所需的方法-不修改
///此方法的内容与代码编辑器一起使用。
/// 
私有void InitializeComponent()
{
this.btnPhoto=new System.Windows.Forms.Button();
this.btnVideo=new System.Windows.Forms.Button();
this.sfdFile=new System.Windows.Forms.SaveFileDialog();
这个.SuspendLayout();
// 
//btnPhoto
// 
this.btnPhoto.Location=新系统.图纸.点(3,3);
this.btnPhoto.Name=“btnPhoto”;
this.btnPhoto.Size=新系统.图纸.尺寸(72,20);
this.btnPhoto.TabIndex=0;
this.btnPhoto.Text=“Photo”;
this.btnPhoto.Click+=新建System.EventHandler(this.btnPhoto\u Click);
// 
//btnVideo
// 
this.btnVideo.Location=新系统图纸点(81,3);
this.btnVideo.Name=“btnVideo”;
this.btnVideo.Size=新系统图纸尺寸(72,20);
this.btnVideo.TabIndex=1;
this.btnVideo.Text=“视频”;
this.btnVideo.Click+=新建System.EventHandler(this.btnVideo\u Click);
// 
//表格1
// 
this.AutoScaleDimensions=新系统.Drawing.SizeF(96F,96F);
this.AutoScaleMode=System.Windows.Forms.AutoScaleMode.Dpi;
this.AutoScroll=true;
this.ClientSize=新系统.Drawing.Size(240294);
this.Controls.Add(this.btnVideo);
this.Controls.Add(this.btnPhoto);
this.ebox=false;
this.Name=“Form1”;
this.Text=“Form1”;
此选项为.resume布局(false);
}
#端区
私人按钮btnPhoto;
私有保存文件对话框sfdFile;
私人按钮btnVideo;
#端区
公共表格1()
{
初始化组件();
}
枚举摄影机类型
{
照片,
视频
}
私有void btnPhoto_单击(对象发送者,System.EventArgs e)
{
sfdFile.FileName=“photo.jpg”;
sfdFile.Filter=“图像文件|*.jpg”;
if(sfdFile.ShowDialog()==DialogResult.OK)
ShowCamera(sfdFile.FileName,CameraType.Photo);
}
私有无效btnVideo_单击(对象发送者,System.EventArgs e)
{
sfdFile.FileName=“video.wmv”;
sfdFile.Filter=“视频文件|*.wmv”;
if(sfdFile.ShowDialog()==DialogResult.OK)
ShowCamera(sfdFile.FileName,CameraType.Video);
}
私有void ShowCamera(字符串文件名,CameraType类型摄像机)
{
FileInfo fi=新的FileInfo(文件名);
CameraCaptureDialog camera=新建CameraCaptureDialog
{
InitialDirectory=fi.DirectoryName,
DefaultFileName=fi.Name,
Mode=typeOfCamera==CameraType.Photo?CameraCaptureMode.Still:CameraCaptureMode.VideoWithAudio,
VideoTypes=CameraCaptureVideoTypes.All,
Title=“使用相机”
};
if(camera.ShowDialog()==DialogResult.OK)
MessageBox.Show((typeOfCamera==CameraType.Photo?“Photo”:“Video”)+文件名+“Captured”);
其他的
MessageBox.Show(“未捕获”);
}
}
}

最简单的方法是在上使用,此方法独立于硬件。请参见此示例:

using System.ComponentModel;
using System.IO;
using System.Windows.Forms;
using Microsoft.WindowsMobile.Forms;

namespace CameraExample
{

    public class Form1 : Form
    {
        #region Code Designer.cs
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private IContainer components;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.btnPhoto = new System.Windows.Forms.Button();
            this.btnVideo = new System.Windows.Forms.Button();
            this.sfdFile = new System.Windows.Forms.SaveFileDialog();
            this.SuspendLayout();
            // 
            // btnPhoto
            // 
            this.btnPhoto.Location = new System.Drawing.Point(3, 3);
            this.btnPhoto.Name = "btnPhoto";
            this.btnPhoto.Size = new System.Drawing.Size(72, 20);
            this.btnPhoto.TabIndex = 0;
            this.btnPhoto.Text = "Photo";
            this.btnPhoto.Click += new System.EventHandler(this.btnPhoto_Click);
            // 
            // btnVideo
            // 
            this.btnVideo.Location = new System.Drawing.Point(81, 3);
            this.btnVideo.Name = "btnVideo";
            this.btnVideo.Size = new System.Drawing.Size(72, 20);
            this.btnVideo.TabIndex = 1;
            this.btnVideo.Text = "Video";
            this.btnVideo.Click += new System.EventHandler(this.btnVideo_Click);
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
            this.AutoScroll = true;
            this.ClientSize = new System.Drawing.Size(240, 294);
            this.Controls.Add(this.btnVideo);
            this.Controls.Add(this.btnPhoto);
            this.MinimizeBox = false;
            this.Name = "Form1";
            this.Text = "Form1";
            this.ResumeLayout(false);

        }

        #endregion

        private Button btnPhoto;
        private SaveFileDialog sfdFile;
        private Button btnVideo;

        #endregion

        public Form1()
        {
            InitializeComponent();
        }

        enum CameraType
        {
            Photo,
            Video
        }

        private void btnPhoto_Click(object sender, System.EventArgs e)
        {
            sfdFile.FileName = "photo.jpg";
            sfdFile.Filter = "Image Files |*.jpg";
            if (sfdFile.ShowDialog() == DialogResult.OK)
                ShowCamera(sfdFile.FileName, CameraType.Photo);
        }

        private void btnVideo_Click(object sender, System.EventArgs e)
        {
            sfdFile.FileName = "video.wmv";
            sfdFile.Filter = "Video Files |*.wmv";
            if (sfdFile.ShowDialog() == DialogResult.OK)
                ShowCamera(sfdFile.FileName, CameraType.Video);
        }

        private void ShowCamera(string FileName, CameraType typeOfCamera)
        {
            FileInfo fi = new FileInfo(FileName);
            CameraCaptureDialog camera = new CameraCaptureDialog
            {
                InitialDirectory = fi.DirectoryName,
                DefaultFileName = fi.Name,
                Mode = typeOfCamera == CameraType.Photo ? CameraCaptureMode.Still : CameraCaptureMode.VideoWithAudio,
                VideoTypes = CameraCaptureVideoTypes.All,
                Title = "Using the camera"
            };

            if (camera.ShowDialog() == DialogResult.OK)
                MessageBox.Show((typeOfCamera == CameraType.Photo ? "Photo " : "Video ") + FileName + " Captured");
            else
                MessageBox.Show("Not Captured");
        }
    }
}
使用System.ComponentModel;
使用System.IO;
使用System.Windows.Forms;
使用Microsoft.WindowsMobile.Forms;
名称空间摄影机示例
{
公开课表格1:表格
{
#区域代码设计器.cs
/// 
///必需的设计器变量。
/// 
私人IContainer组件;
/// 
///清理所有正在使用的资源。
/// 
///如果应释放托管资源,则为true;否则为false。
受保护的覆盖无效处置(布尔处置)
{
if(处理和(组件!=null))