Step By Step Creation Of Camera App In Universal Windows App

I will try to figure them out, one by one,

Step 1 : Create Windows Universal Project.

  • Open Visual Studio 2015 -> New Project.

    New Project

Step 2: Give the Project Name.

  • New Project Window will open. You can select an installed template like “Universal” under the Windows on Visual C# Template and select a Blank app (Universal Windows).
  • Type the project name CameraApp and click OK button.

    Project Name

Step 3: Set the platform Versions.

  • Here, we choose the Target Version and Minimum Version for our Universal Windows Application. Let it be like that and click OK.

     platform Versions

Step 4: Choose Designer Window,

  • The Project Main Window will be displayed. You can click the View - Designer.

    Designer Window

Step 5: Designer Window Loading is given below:

Designer Window Loading

Designer Window Loading

Step 6 : Designing the App

  • Design the app by placing the button tool from the tool box and change the name to camera in the Property Window.

    Designing the App

  • Next, place the Image tool from the tool box and change the name to capturedImage in the Property Window.

    Designing the App

Step 7: Add the Coding

  • To add coding, double click on the button. Add the mentioned source code, given below:

    Coding
    1. using Windows.Media.Capture;   
    2. using Windows.Storage;   
    3. using Windows.Storage.Streams;   
    4. using Windows.UI.Xaml.Media.Imaging;   
  • Add the code, given below, in the appropriate place (Camera Button) and added the keyword async in Camera click method.

    Coding
    1. CameraCaptureUI captureUI = new CameraCaptureUI();  
    2. captureUI.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Jpeg;  
    3. StorageFile image = await captureUI.CaptureFileAsync(CameraCaptureUIMode.Photo);  
    4. BitmapImage bitmapImage = new BitmapImage();  
    5. using(IRandomAccessStream fileStream = await image.OpenAsync(FileAccessMode.Read))   
    6. {  
    7.     bitmapImage.SetSource(fileStream);  
    8. }  
    9. capturedImage.Source = bitmapImage;  

Step 9: Run the Application

  • Click the local machine on the Standard tool bar for running the Application.

    Coding

Output

Output

Conclusion

I hope you understood Camera app in Universal Window and how to run it. I have covered all the required things. If you find anything, which I missed in this article, please let me know. Please share your valuable feedback or suggestions.


Similar Articles