Windows Phone 8.1 Multi Media (1): Photos

Source: Internet
Author: User

Original: Windows Phone 8.1 Multi Media (1): Photo

Windows Phone 8.1 Multi Media (1): Photos

Windows Phone 8.1 Multi Media (2): Video

Windows Phone 8.1 Multi Media (3): Music

(1) Taking photos

1) captureelement

Captureelement is a preview of the controls placed on the app interface:

<Grid>     <captureelement  x:name= "capturephotoelement"/> </Grid><Page.bottomappbar>    <CommandBar>        <Appbarbuttonx:name= "Btncapturephoto"Icon= "Camera"Label= "Capture"Click= "Btncapturephoto_click"/>    </CommandBar></Page.bottomappbar>

2) MediaCapture

MediaCapture is an important class for controlling shooting.

First initialize the MediaCapture and set the Captureelement Source to the MediaCapture:

MediaCapture photocapture;imageencodingproperties imgencodingproperties;protected Override Async voidonnavigatedto (NavigationEventArgs e) {Capturephotoelement.source=awaitInitialize (); awaitPhotocapture.startpreviewasync ();}Private AsyncTask<mediacapture>Initialize () {photocapture=NewMediaCapture (); awaitPhotocapture.initializeasync (); PhotoCapture.VideoDeviceController.PrimaryUse=Captureuse.photo; Imgencodingproperties=Imageencodingproperties.createjpeg (); Imgencodingproperties.width=640; Imgencodingproperties.height=480; returnphotocapture;}

Then complete the shot when you press a button:

Private Async void Btncapturephoto_click (object  sender, RoutedEventArgs e) {    varawait KnownFolders.PicturesLibrary.CreateFileAsync ("photo.jpg", Creationcollisionoption.generateuniquename);     await Photocapture.capturephototostoragefileasync (imgencodingproperties, photo);}

You can also add events for phone entity keys:

hardwarebuttons.camerahalfpressed + = hardwarebuttons_camerahalfpressed; Async void Hardwarebuttons_camerahalfpressed (object  sender, Cameraeventargs e) {    await  PhotoCapture.VideoDeviceController.FocusControl.FocusAsync ();}

Finally, remember to release the MediaCapture resource when you leave the page:

protected Override void Onnavigatedfrom (NavigationEventArgs e) {    ifnull  )    {        Photocapture.dispose ();         NULL ;    }}

(2) Editing photos

I've used the Nokia Imaging SDK and Writablebitmapex library here to search and install in Nuget.

Note To change the CPU in Configuration Manager to ARM, the Nokia Imaging SDK will not be available.

The use of the method is very simple, such as the following for a picture to add a filter:

WriteableBitmap Originbitmap; WriteableBitmap Editedbitmap;Private Async voidEditbutton_click (Objectsender, RoutedEventArgs e) {    varImageSource =NewBitmapimagesource (Originbitmap.asbitmap ()); using(varEffect =NewFilterEffect (ImageSource)) {        varFilter =NewAntiquefilter (); Effect. Filters=New[] {filter}; varRenderer =Newwriteablebitmaprenderer (effect, originbitmap); Editedbitmap=awaitrenderer.        Renderasync ();    Editedbitmap.invalidate (); } Myimage.source=Editedbitmap;}

More ways to use the Nokia Help Center view: Links

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.