MobilePictureSample

Taking pictures with mobile devices is common .  The quality of the pictures might not be as good and it might not be always as easy to zoom,  control the flash,  or properly focus, but it does its job well enough in most situations.  The biggest advantage is that you always have your phone so you can capture images that normally would be missed.

When we started working on the Mobile SDK for Windows Apps in 2011, one of the most interesting use cases was being able to take pictures on the mobile device and then using these pictures with the Windows app.  From a customer point of view, this is one of the most compelling reasons to implement an application using the SDK.

What makes this different from usual?  Why would you do it this way?

The answer requires a bit of background information.  The biggest difference is where the picture is first processed.  Instead of being controlled by a local application on the device, the picture is provided to the remote application first.  Since the application is running on XenDesktop/XenApp, it uses the SDK to trigger the picture being taken and collecting the picture when it is done.  This makes it possible to inject a picture directly into a Windows app from a mobile device (phone or tablet).

A number of use cases came to mind early on including maintenance and insurance.  It is possible to not only instantly take pictures at remote locations but to also have these pictures be included in the corporate databases in a very quick way.  The most famous use of this model is from Warren Simondson from Ctrl-Alt-Del.  In this case, the camera is used make sure that miners are where they say they are.

Several months ago, I started working on a project to share on the blog.  This work was meant to extend what was done for MobileHelloWorld. Even though I had made great progress, I never quite got it to the state where I wanted to release it to the world.  The intent was to make it all about pictures and taking new ones.  It uses the SDK more than MobileHelloWorld and has a number of useful features.

  • Enumerates all pictures under My Pictures and puts them in a list for display
  • Navigates backwards and forwards using arrow buttons
  • Rotates picture based on user using rotate buttons
  • Slideshow mode by holding forward or backward buttons for a few seconds
  • Touch the picture will hide/show the controls using a toggle
  • Pictures with Apple orientation are presented correctly
  • Changes to rotation can be saved
  • Pictures are shown as true size if they fit.  If too large, they are zoomed down to the largest fitting size.
  • Label for photo at top right displays name, number, and dimensions
  • New pictures can be taken with the camera button
  • Device rotation will trigger a replacement of controls
  • Control placement is based on screen relative position (top, middle, bottom, left, middle, bottom)
  • Control size is adjusted based on the device type (phone, tablet, PC)
  • The app remembers the last displayed photo and uses it for the next time
  • Icons come from the Visual Studio resource kit and are safe to distribute
  • Delete pictures that are not wanted

My favorite features are the slideshow and being able to capture new pictures.  I also appreciate the ability to correctly display pictures from iOS devices.  Without the code to detect true orientation, it can be quite frustrating.

Instead of dragging you through all the code like I did for HelloWorld, I will instead offer the source code first.

download

There is a lot of potential for using this program as a template for something much more interesting.  This code works fine with the emulator so it is possible to simulate on a Windows 7/8 dev machine with the SDK.  In fact, that is the best place to start since it can be difficult getting a dev server going.

To recap, the program can display pictures from your My Pictures folder and add new ones using the mobile device to capture them.