Quickly build Windows 8 style apps 29-capture pictures and videos

Source: Internet
Author: User

Original: Quickly build Windows 8 style apps 29-capture pictures and videos

Introduction

This post focuses on the concept of camera in Windows 8, the fundamentals of capturing pictures and videos, how to capture pictures and videos, and camera best practices.

One, camera about camera

1. The camera dialog provides a touchscreen-optimized full-screen experience where you can capture photos and videos from an embedded or attached camera.

2. The full screen dialog handles the work of displaying the camera UI.

3. This dialog box allows you to capture a photo or video using a method call to Windows.Media.Capture.CameraCaptureUI.captureFileAsyncAPI.

4. As part of the capture experience, users can trim the captured photos, clip the captured video, and then return them to the calling application.

5. Users can also adjust some camera settings, such as brightness, contrast, and exposure, before capturing photos or videos. The Camera dialog box is used for live photo and video capture.

Camera settings

1. Camera settings can be adjusted with camera options

2. Including photo resolution, whether video anti-jitter, brightness, contrast and other options

Edit Photos

1. Crop button to crop the photo

2. "OK" button to confirm captured photos

3. "Re-shoot" button to take photos again

Edit Video

1. "Clip" button for clip video

2. "OK" button to confirm the captured video

3. "Re-shoot" button to re-capture the video

Second, the basic principles of capturing pictures and videos

First, we need to register the camera/microphone permissions in the manifest file.

Next, in the corresponding. cs file, add the namespace.

Finally, the Cameracaptureui object is declared, the object property is set, and the Capturefileasync method is called.

Then we can use the app to call the camera to capture the photo/video.

Third, how to achieve capture pictures and videos enable webcam permissions

1. When capturing photos, the app must allow the use of the camera

2. You can enable webcam permissions by setting the application manifest file (package.appxmanifest)

3.Capabilities tab, tick webcam

Enable Microphone Permissions

1. When capturing video, the app generally allows the use of a microphone

2. You can enable microphone permissions by setting the application manifest file (package.appxmanifest)

3.Capabilities tab, tick microphone

Capturing photo-related properties

Capturing video-related properties

How to capture photos
   1:  using Windows.Media.Capture;
   2:  private  async  void  Oncapturephoto (object  sender, Tappedroutedeventargs e)
   3:  {
   4:      new cameracaptureui ();
   5:  
   6:      var file = await camera. Capturefileasync (Cameracaptureuimode.photo);
   7:      ifnull)
   8:      {
   9:          photo = file;
  Ten:  
One   :          datatransfermanager.showshareui ();
  :      }
  :  }

Phone;video can be set by Cameracaptureuimode; Phoneorvideo.

How to capture Video
   1:  using Windows.Media.Capture;
   2:  privatevoid oncapturevideo (object sender, Tappedroutedeventargs e)
   3:  {
   4:        new cameracaptureui ();
   5:  
   6:        camera. Videosettings.format = cameracaptureuivideoformat.wmv;
   7:  
   8:        var file = await camera. Capturefileasync (Cameracaptureuimode.video);
   9:        ifnull)
  Ten:        {
One   :             video = file;
  :             datatransfermanager.showshareui ();
  :        }
  :  }
Four, the camera best practice camera UI reasonable use

For example, for apps that provide profile pictures, you can capture photos and update your profile by launching the Camera dialog box.

Irrational use of the camera UI

1. When a user scans a barcode using the camera, the barcode Reader app can give the user real-time feedback to let the user know if the bar code is readable. In this case, using the Camera dialog box may not be the right choice because it does not provide any direct control over the captured video stream. You should instead use the MediaCapture API.

2. If you need to add UI customizations that exceed the functionality provided by the camera dialog, you should instead use MediaCapture.

3. If your app is a video or photo editing application, or has some photo or video editing features, you should use the Camera dialog box when the trim and crop feature is turned off. Then, the trim and crop features in your application will not be duplicated with the features provided in the Camera dialog box.

Related references:

1. Media Capture example;

2. Camera Capture UI example;

3. Camera options UI example;

4. Capturing or rendering audio, video, and images (Windows store apps using C#/vb/c++ and XAML) (Windows);

Quickly build Windows 8 style apps 29-capture pictures and videos

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.