Capturing Photos with a Mobile Device Camera in C#
Recently, I was thinking about a small task - to use the camera in my application and get photos from it. As it turned out, it's quite simple to do.
For this, you just need to add the Microsoft.WindowsMobile.Forms library to your project.
The library is located in the Windows Mobile SDK - you can download it from the Microsoft website.
A piece of code that implements photo capture:
CameraCaptureDialog cameraCaptureDialog = new CameraCaptureDialog();
cameraCaptureDialog.Owner = this;
cameraCaptureDialog.Title = "Фотография";
cameraCaptureDialog.Mode = CameraCaptureMode.Still;
if (cameraCaptureDialog.ShowDialog() == DialogResult.OK &&
cameraCaptureDialog.FileName.Length > 0)
{
pictureBox1.Image = new Bitmap(cameraCaptureDialog.FileName);
}
The code includes the camera, and after it's done, it passes the captured photo to our pictureBox, if it exists.
You can download the example with the source code here: mobilecam.rar · 22 downloads
- mobilecam.rar 226.2 KB 22 downloads
Comments (0)
No comments yet.