WindowsMobile PDA에 장착된 카메라 제어 소스입니다.
카메라 제어는 PDA 제조사와 상관없이 아래의 소스를 이용하여 사용가능합니다.
Windows.Mobile.dll 참조 추가해주세요.
private void button1_Click(object sender, EventArgs e)
{
CameraCaptureDialog cameraCapture = new CameraCaptureDialog();
cameraCapture.Owner = this;
cameraCapture.InitialDirectory = @"\My Documents\";//저장경로 설정
cameraCapture.DefaultFileName = cameraCapture.DefaultFileName + ".jpg";//이미지파일 기본 이름 설정
cameraCapture.Mode = CameraCaptureMode.Still;//카메라 설정
cameraCapture.StillQuality = CameraCaptureStillQuality.Default;//화질설정
object cameraEnabled = Microsoft.WindowsMobile.Status.SystemState.GetValue(Microsoft.WindowsMobile.Status.SystemProperty.CameraEnabled);
if (null != cameraEnabled && 0 == (int)cameraEnabled)
{
MessageBox.Show("The camera is disabled", this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
return;
}
try
{
if (DialogResult.OK == cameraCapture.ShowDialog())
{
string fileName = cameraCapture.FileName;
pictureBox1.Image = new Bitmap(fileName);
pictureBox1.Show();
MessageBox.Show("The picture or video has been successfully captured and saved to:\n\n" + fileName,
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
}
}
catch (ArgumentException ex)
{
// An invalid argument was specified.
MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK,
MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
}
catch (OutOfMemoryException ex)
{
// There is not enough memory to save the image or video.
MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK,
MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
}
catch (InvalidOperationException ex)
{
// An unknown error occurred.
MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK,
MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
}
}
'C#' 카테고리의 다른 글
[C#/PDA]Button의 텍스트 문자열 다중 출력 예제 (0) | 2016.01.18 |
---|---|
[C#]동호회 회원관리 프로그램 소개 (0) | 2016.01.15 |
[C#/PDA]PDA에서 실행 파일 경로 얻어오기 (0) | 2016.01.15 |
[C#]문자를 Bitmap 파일로 변환하기 (0) | 2016.01.15 |
[C#]pictureBox 동적 생성 예제 (0) | 2016.01.15 |