도전2022

카메라 관련 내용. 본문

작업/윈도우폰7

카메라 관련 내용.

hotdigi 2011. 7. 6. 18:58

LaunchersAndChoosers 예제 셈플에 있는 카메라 부분을 분석하자.

TaskPicturePage.xaml 파일의 내용을 살펴보자.

카메라를 구동하면 작은 불럭이 움직이는 모습이 나타나고, 캡쳐하면

ChoosePhotoPage.xaml로 연동되어서 다음의 함수 부분에서 저장을 하도록 코드를 작성한다.


void photoChooserTask_Completed(object sender, PhotoResult e)
        {
            Debug.WriteLine("***\t In photoChooserTask_Completed function of ChoosePhotoPage\t ***");

            if (e.TaskResult == TaskResult.OK)
            {
                BitmapImage bitmap = new BitmapImage();
                bitmap.SetSource(e.ChosenPhoto);
                imgChosenPhoto.Source = bitmap;
            }
            else if (e.TaskResult == TaskResult.Cancel)
                MessageBox.Show("No photo was chosen - operation was cancelled", "Photo not chosen", MessageBoxButton.OK);
            else
                MessageBox.Show("Error while choosing photo:\n" + e.Error.Message, "Fail", MessageBoxButton.OK);
        }