Windows Phone 8 lens application-13 features required to upgrade lenses for Windows Phone 8 to WP8

Source: Internet
Author: User
Tags transparent image


Lens is actually a Filter Lens. When you use the shutter button in Windows Phone 8, you can start the camera function. You can see a lens button in the camera AppBar. This is a brand-new method of application experience. I personally like this method very conveniently, in addition, in the default camera, you can select the filter effect of the target application. This effectively improves the user experience, which is unique to the Windows Phone platform, it also provides moreProgramPortal.



This article is an update of 13 feature series required to be updated to WP8. We hope this series will bring some development convenience to Windows Phone 8 developers.



At the same time, you are welcome to communicate with me or @ Wang Bo _ nick on Sina Weibo.



Is the volume button displayed in the AppBar after the camera is started.






Is an application experience process using lens.



 






First, if you want to take a photo and save the photo to the album, you mustWmappmanifestDeclare the permission to use the lens and album media library.






In addition, if you do not select the above two items, your application will be displayed in Lens picker. You need to modify the extension registration of the camera.WmappmanifestFile, but this time you want to open and edit the file, add the followingCode:


<Extension ExtensionName="Camera_Capture_App" 
           ConsumerID="{5B04B775-356B-4AA0-AAF8-6491FFEA5631}"
           TaskID="_default" />


And must followTokenAfter the node






In this way, you can see your application in Lens picker After deploying your application.






It can be seen that only my demo program does not have an icon and it looks unfriendly and will certainly be despised by many people. Of course, I also want to set the default icon, we all know that WP8 supports three resolutions. Therefore, in Lens Picker, we also need three icon sizes to adapt to three resolutions.






Here is a detailed template description to download PDF files and original PSD files: icon templates for Windows Phone 8



You need to provide the above three resolution icons and use the naming rules, and put them inAssetsFolder so that you can see the icon in the lens picker of your application at different resolutions. Here you can see the icon of the SDK that I used when I was lazy, but the effect is already available ~



If you want to make the following effect that can adapt to system color changes, use a PNG transparent image.






After you click the lens button, all applications that support the lens API are displayed. Click an application icon in the list and jump to the target application through deep link. For more information about how to deal with this deep link, see applications in Windows Phone 8. For more information, see msdn: http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj662936 (V = vs.105). aspx.



 



I believe that the general application that provides filters provides the image editing function. After various effects and special effects, the photo display will be brilliant, of course, you can use an entrance connection in the photo library to send the photo to a lens application for editing.






You can see that this image is saved from a lensapp and can be opened using this app. Below I will introduce how to implement this function.



First, your image is saved through your lensapp, and then the open link will appear directly in the item in the corresponding app bar.


MediaLibrary library = new MediaLibrary ();

                 string lName = GeneratePhotoName ();


                 var myStore = IsolatedStorageFile.GetUserStoreForApplication ();


                 if (myStore.FileExists (lName))
                 {
                     MessageBox.Show ("The picture already exists");
                 }
                 else
                 {
                     Picture newPicture = this.mediaLibrary.SavePictureToCameraRoll (lName, e.ChosenPhoto);

                     MessageBox.Show ("Saved successfully!", "Hint", MessageBoxButton.OK);


 



 






To declare the media expansion function, you also needWmappmanifestFile registration statement


 




<Extension ExtensionName="Photos_Rich_Media_Edit" 
           ConsumerID="{5B04B775-356B-4AA0-AAF8-6491FFEA5632}" 
           TaskID="_default" />


 



We also need to keep upTokenNodes inExtensionAdd this node






The method for obtaining images from open link is also very simple, that is, the method for sharing files between applications,



 


 
protected override void OnNavigatedTo(NavigationEventArgs e)
{
    // Get a dictionary of query string keys and values.
    IDictionary<string, string> queryStrings = this.NavigationContext.QueryString;

    // Ensure that there is at least one key in the query string, and check whether the "token" key is present.
    if (queryStrings.ContainsKey("token"))
    {
        // Retrieve the photo from the media library using the token passed to the app.
        MediaLibrary library = new MediaLibrary();
        Picture photoFromLibrary = library.GetPictureFromToken(queryStrings["token"]);

        // Create a BitmapImage object and add set it as the image control source.
        // To retrieve a full-resolution image, use the GetImage() method instead.
        BitmapImage bitmapFromPhoto = new BitmapImage();
        bitmapFromPhoto.SetSource(photoFromLibrary.GetPreviewImage());
        image1.Source = bitmapFromPhoto;

    }
}


 



The deep link method has been introduced before. I believe you don't want to listen to me again.



For more information, see Inter-Application Communication in Windows Phone 8.



Http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj662942 (V = vs.105). aspx



I believe you have some knowledge about the lens app,You are welcome to communicate with me here or on Sina Weibo.@ Wang Bo _ Nick


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.