Capturing and Saving Image in Windows 10 App

Generally during application development, developers need to use image capturing feature within their applications just because of the need of an application or as an added feature. As it comes, for the platform like Windows 10 there are few changes in the code syntax which need to be addressed. So this following blog post is about using the new syntax to utilize image capture and save functionality in a Windows 10 app.

In this blog post, we will start with functionality to capture images in a Windows 10 application. For that, we need to add the capability of Webcam and PicturesLibrary in the  “Package.appxmanifest” file. After adding the capability, we need to add a Button to capture Image and an Image control to show the captured image. Then we will save the image in a location in the system.

So, add the following code in the XAML file:

XAML Code

Before adding any code in the Capture_click and Save_Click events, we have to add few namespaces in .CS file, so that no issues will occur in the code:

Namespaces

Now, we go to the Capture_click event to capture the image using the webcam. But before adding the functionality of capture_click, we need to declare following variables which will be used throughout the application:

Now, the functionality of this capture_click event is:

Capture Functionality

Now, we will add the code for save_click method, which will save the Image file at particular location in the system:

Save Functionality

Run the program, and enjoy!