Monday, October 18, 2010

Pictures Lab for Windows Phone

"Windows Phones are going to be absolutely amazing devices for taking pictures and dealing with pictures." - Joe Belfiore at the official Windows Phone 7 launch event in NYC. I totally agree, they are. Just think about that each device needs to have at least a 5 megapixel camera and the little camera button with the "pocket to picture" functionality. I've been working heavily to enhance this photo experience with my kind of skills. This blog post contains information about the Windows Phone app I created and will also provide the references to how it works internally.


Download here

Pictures Lab is the ultimate picture effects app for all Windows Phone device types.
MSNBC.com: "a Swiss Army knife of photo tweaks".
Engadget.com: "a must-have for WP7 devices ... the program provides a set of amazing effects and tweaks for your photos"
Gizmodo.com : "Pictures Lab offers a ton of effects for your money."

If you like to make beautiful photos, then this app is a perfect addition to your phone’s toolset. Pictures Lab provides you with thousands of different modifications for your photos and has a camera functionality with superior features like face detection auto focus, steady mode and much more. It's also integrated as a Lens.
Pictures Lab is the original with high quality filters, features and great user experience. It's fast and responsive and you quickly get your job done with just a few moves. Often been copied, but never reached.
Microsoft uses Pictures Lab in its presentations as a "delightful app" which "Looks and feels like an integral part of Windows Phone". "Uncluttered, polished experience".

The app comes with controllable, easy-to-use, but advanced effects like different vintage and hipster-like filters, Tilt Shift (miniature faking), HDR, Lomo, Soften, Auto Adjust, Sharpen, Comic, Bulge, B&W, Sepia and many more. Dynamic previews of the effects are shown in a list, making it possible to easily pick the right one. The high quality borders are also presented in a nice preview list and can be combined with any filter and any aspect ratio. Multiple effects can also be combined.
It is also possible to crop, rotate and flip images. An enhanced picture and the EXIF data can be saved to the phone’s pictures hub or shared directly on Facebook, Twitter and other social networks. Later editing is also supported. The app performs the image processing on the original picture in its original resolution, thus making it also possible to print the image or use it as desktop wallpaper.
Full Pictures Hub Apps integration and support for landscape and portrait orientation. Trial version with complete functionality only save is disabled.

    If YouTube works better for you.

Reviews
  • The well-known site Engadget lists it under The best apps, accessories, and tips. They write: "... a must-have for WP7 devices ... the program provides a set of amazing effects and tweaks for your photos ..."
  • Gizmodo included Pictures Lab in Windows Phone 7 Essential Apps, Reviewed. They also recorded a video. They write: "Your phone isn't complete until you can take photos that look like they came out of a $5 camera from 1974. Pictures Lab fortunately offers a ton of other effects for your money. $2."
  • Gizmodo Australia also featured it in the article The Best Windows Phone 7 Apps.
  • msnbc.com wrote: "The app, a Swiss Army knife of photo tweaks, will be one of my first downloads."
  • techradar.com wrote that Pictures Lab is the #1 app worth paying for: "Tilt-shift effects, crop and rotate... Pictures Lab combines the fun effects of an iPhone photo app like Hipstamatic with the useful fixes you're mostly likely to need (sharpen and - in the imminent update - crop) in a beautifully designed app that crosses the power of Silverlight with the tools of the Windows Phone 7 interface. Pick a photo, see all the possible effects as thumbnails or swipe up and down to try them one at a time."
  • msnbc.com listed it in the article: "The first Windows Phone 7 apps you should grab"
  • MSN UK listed it under the "20 top mobile phone app". And they put my fat nose on the front page. Fortunately two of my girls brought the beauty back to the page.
  • America's popular WIRED magazine with a circulation of 800,000 featured Pictures Lab in there special edition WIRED App Guide.
  • UK's popular gadget magazine T3 with a circulation of more than 60,000 featured Pictures Lab in the 02/2011 issue on the page: "Killer Apps"
  • Pictures Lab was featured in Channel 9's Hot Apps series.
  • Nokia writes "it’s the closest thing to having Photoshop on your mobile phone."
  • Nokia included Pictures Lab in Top of the Apps: 10 Hotties.
  • Softpedia featured the Windows Phone 8 update.
  • All About Windows Phone reviewed the app: "Pictures Lab is one of many photo toolboxes for your smartphone, but it's the one that I enjoy using the most." and "Very, very much recommended."
  • All About Windows Phone also reviewed the Windows Phone 8 update: "It goes significantly beyond the one shot filters typically offered in apps of this type (Nokia Creative Suite, HTC Photo Enhancer) to the point at which it's about a lot more than just fun filters."
  • Another very popular UK magazine Stuff wrote a 5 stars review in the March edition. They write that Pictures Lab is better than a well-known iPhone app.  
  • Germany's popular media and design magazine PAGE with a circulation of 20,000 featured Pictures Lab in the 01/2011 issue
  • Microsoft features Pictures Lab in their presentation slides for Windows Phone under the category delight: "Looks and feels like an integral part of Windows Phone 7". "Uncluttered, polished experience".
  • Geek.com listed it as one of the Five must have apps for Windows Phone: "Pictures Lab is $2.99, but well worth it in my opinion for all of the new features added to the camera on your phone."
  • The famous blogger Scott Hanselman says in his Essential Apps blog post: "Pictures Lab is a nice effects and editing application (if not THE BEST editing app) for Windows Phone. All the functionality is there and cleanly integrated with the Photos Hub. Crop, Rotate, Effects, etc. It's a must-have if you are doing any photography on your phone."
  • Business Insider writes "Pictures Lab is like Instagram for Windows Phone 7. Take pictures with Pictures Lab, apply filters, and share them with friends."
  • The famous design site Smashing Magazine included Pictures Lab as an example in the article Introduction To Designing For Windows Phone 7 And Metro
  • Bright Hub lists Pictures Lab as the first app in Top 5 Samsung Focus Apps: "It is considered one of the most popular photo editing programs on the Windows Phone platform, and for good reason. It has an array of sophisticated and beautiful effects ..."
  • APC (Australian Personal Computer) writes: "WP7’s best picture editing and effects app.Pictures Lab has received a lot of attention as the “go-to” image editing suite for new WP7 users – and for good reason, too."
  • Mobility Digest wrote: "This app makes me happy. Tons of features, seems simple to use and it’s cheap – that’s a win! It even has a trial mode that includes all effects."
  • Mobility Digest also posted a walk through: "I didn’t realize it, but when you go to the list of available effects you get to see a preview of the effect which is really great and I have to say, I’m really impressed for how much this app can do."
  • Mobility Digest listed it in: "The First 25 Windows Phone Apps To Download"
  • Pocket-Lint wrote in the article Best Windows Phone 7 photography apps: "... the smart way to go is with Pictures Lab..."
  • maximumpc.com wrote: "Speaking of pictures, for two bucks you can have a great little mobile suite of photo effects, fixes, and basic editing tools. The Windows Phone 7 UI language really shines through in this one."
  • Mobile Choices listed it as one of the two Windows Phone apps in The 12 best Christmas apps: "...turning lifeless images into photographic masterpieces..."
  • The blog Noisecast recorded a nice video review: "The program @PicturesLab is the best photo editor for Windows Phone 7, hands down."
  • 1800pocketpc.com wrote: "If you love to add effects to your picture then this is one app video you wouldn’t want to miss."
  • 1800pocketpc.com also wrote a review including a video
  • wpcentral.com wrote: "... interesting photo effect application."
  • wpcentral.com also got the WP8 update and : "... Things fly along nicely and the effects don’t take too long to apply in full ..."
  • mobiledownloadblog.com wrote: "There is no doubt that any phone device is incomplete without good picture depiction. A fantastic photograph app known as Picture Lab is now available for Windows Phone 7."
  • Techland.com has it on the list: "50 Windows Phone 7 Apps to Get You Started"
  • mobiledownloadblog.com has it on the list: "Samsung Focus: 30 Best WP7 Applications"
  • The German site phoneseven.de wrote: "Die App sieht wirklich klasse aus und lässt sich allem Anschein nach wirklich gut bedienen. Wer also befürchtet hat, dass Windows® Phone 7 zu wenig Möglichkeiten für gute Apps bietet, der wird mit Pictures Lab sicherlich eines besseren belehrt. Die App wird sicherlich zu meinen ersten Käufen aus dem Marketplace gehören."
  • The Portuguese site pcdebolso.com also wrote an article: "Pictures Lab a caminho do Windows phone 7"
  • Dave Campbell wrote a nice review: "All-in-all, I give Pictures Lab 5 stars"
  • John Papa wrote: "Overall, very nice app, good UI, snappy (which was a surprise to me since it does a lot)."
Feature list
  • Full support for Windows Phone 7 and 8 including all screen resolutions.
  • 30 advanced effects: Ten different vintage and hipster-like effects, Tilt Shift (miniature faking), HDR, Lomo, Soften, Auto Adjust, Sharpen, Comic, Bulge, B& W, Sepia, Manual, Edge Detection, Night Vision, Rainbow, Mirror, X-Ray, Heat Image, Colorization, Negative and Bitmap.
  • Editable effect parameters with ready-to-use default values.
  • Combination of multiple effects.
  • 11 high quality borders and more seasonal borders.
  • Share on Facebook, Twitter, Email, NFC and much more.
  • Take photo functionality with face detection auto focus, steady mode, rule of thirds grid. Integrated into the phone as a Lens. The steady mode requires a device with a gyroscope. The face focus is enabled if the device supports focus at point. It also supports devices with a front facing camera.
  • Post edits from the Pictures Hub using the WP Rich Media extension.
  • Crop, rotate and flip also with predefined aspect ratios.
  • Multi-touch manipulation for Tilt Shift and other effects where multi-touch is meaningful.
  • The app can save edited pictures with advanced effects applied in full resolution even on a device with 256 MB RAM. Thus making it also possible to print the image or use it as desktop wallpaper.
  • Full Pictures Hub Extras integration.
  • The trial version includes the complete functionality and all the effects, only the save functionality is disabled.
  • Support for landscape and portrait orientation.
  • Effect list with dynamic previews and caching of the larger previews.
  • Flicking through the effects on the main page.
  • Setting for the maximum output size, JPEG quality and many more.
  • State preservation when the app is deactivated (tombstoning).
  • Localization for English, German, Japanese, Chinese, Russian, Dutch, French, Italian, Spanish, Portuguese and Portuguese (Brasil).








How it works
Some of the image processing algorithms that are used in the Pictures Lab app would normally be implemented as pixel shaders for Silverlight. The Windows Phone platform doesn't support custom pixel shaders at the moment, therefore all effects are implemented in C# and manipulate the WriteabeBitmap Pixels' in some way. How this works in detail was shown in my Coding4Fun articles I've written months ago. This is actually where Pictures Lab has its roots. The first article described all the necessary basics and two simple effects. The second part of this short Coding4Fun article series shows how to implement the basic tilt shift and vintage effects you can find in the Pictures Lab app. Yes, some parts are open source! Except the secret sauces I gotta keep for me that adds the final touch to the effects. I also wrote blog posts about some parts of the application that are surely interesting for other Windows Phone developers.
The Slider control that is used in the App was originally developed by Nokola and then adapted for Windows Phone and made bindable by Clint Rutkas and myself.

To be continued
The planned feature list for the next versions is already pretty long and I have some real diamonds on there. You can follow @PicturesLab on Twitter to get all the status updates. I'd also like to know what feature you want to see in a future version. Just write a comment.

Monday, September 20, 2010

Windows Phone Memory Constraints

The final Windows Phone Developer Tools have been released and the launch date is not far away. It's time to finalize the apps.
Windows Phone has some tough hardware requirements, but it's still a mobile platform with limited resources. In this blog post I'll describe how to determine the current memory usage, what the allowed maximum is to get your app approved for the Marketplace and other constraints a developer should be aware of.


Maximum memory usage
The Windows Phone hardware specifications requires that a device has 256 MB RAM or more. The allowed maximum memory an app can use is defined in the Windows Phone 7 Application Certification Requirements at point 5.2.5
The application must not exceed 90 MB of RAM usage. However, on devices that have more than 256 MB of memory, an application can exceed 90 MB of RAM usage.
One might now ask how to get this information at runtime. Fortunately there's the DeviceExtendedProperties class to obtain some device information at runtime. This class defines the GetValue and TryGetValue methods which expect a string key as parameter. The list of available property keys is defined here. Among other interesting properties like the DeviceUniqueId, it's possible to retrieve the DeviceTotalMemory, the ApplicationCurrentMemoryUsage and the ApplicationPeakMemoryUsage. The property keys are interpreted case-sensitive.
The application needs to define the device identity capability in the WMAppManifest.xml file in order to retrieve the DeviceUniqueId property, but it's not needed for the other keys like the ApplicationPeakMemoryUsage.

Here's the code to get the peak memory usage and the available total memory at runtime:

var timer = new DispatcherTimer {Interval = TimeSpan.FromSeconds(2)};
timer.Tick += (s, e) =>
{
   var memuse = (long)DeviceExtendedProperties.GetValue("ApplicationPeakMemoryUsage");
   var maxmem = (long)DeviceExtendedProperties.GetValue("DeviceTotalMemory");
   memuse /= 1024 * 1024;
   maxmem /= 1024 * 1024;
   MyTextBlock.Text = String.Format("Mem usage: {0} / {1} MB", memuse, maxmem);
};
timer.Start();

The timer checks the properties every two seconds and converts the bytes to MB. The values are then shown in a TextBlock. The peak memory is the most interesting since this value must not exceed 90 MB on a device with 256 MB. Also note that an empty application with two grids and a TextBlock already has a peak of 5 - 7 MB in the emulator or on a device.


PhoneApplicationPage.State limitation
The PhoneApplicationPage.State property is typically used to save transient state for tombstoning. The size of the State data is limited to 2 MB for a Page and 4 MB for the whole application. Be warned, if this limit is reached a not very descriptive exception is thrown. The message text is "The client who called IAccessControl::IsAccessPermitted was the trustee provided tot he method".
If more than 2 / 4 MB is needed to save transient data, the IsolatedStorage can be used. The applications IsolatedStorage is only limited by the device's flash storage size. The minimum requirement for Windows Phone is 8 GB. The available free isolated storage in bytes can be retrieved with the AvailableFreeSpace property of the IsolatedStorageFile class.

Tuesday, August 31, 2010

Rect and Point Extension Methods

I'm currently working on multiple Windows Phone projects and don't have much time for longer blog posts, but I just wanted to get this out.
For one of the projects I need to calculate some simple vector arithmetics like the Euclidean distance. I also need other properties of the Point and Rect structs that aren't built-in the Silverlight framework. As you might know I'm a huge fan of extension methods for extending built-in functionality (12). That's why I wrote a few extension methods for the Point and Rect structs that might come handy.

Rect
public static class RectExtensions
{   
   // Calculates the center point of this rectangle.
   public static Point Center(this Rect rect)
   {
      return new Point(rect.X + rect.Width * 0.5, rect.Y + rect.Height * 0.5);
   }

   // Tests if this rectangle intersects with the other.
   public static bool IntersectsWith(this Rect rect, Rect other)
   {
      // Test for separating axis
      if (other.Bottom < rect.Top || other.Right < rect.Left 
       || other.Top > rect.Bottom || other.Left > rect.Right)
      {
         return false;
      }
      return true;
   }
}

The usage should be pretty obvious.
Rect r = new Rect(0, 0, 200, 300);
Point center = r.Center();

bool isIntersecting = r.IntersectsWith(new Rect(500, 600, 100, 50));


Point
public static class PointExtensions
{
   // Calculates the distance vector of the points.
   public static Point Distance(this Point p1, Point p2)
   {
      return new Point(p1.X - p2.X, p1.Y - p2.Y);
   }

   // Calculates the length of the vector.
   public static double Length(this Point p)
   {
      return Math.Sqrt(p.X * p.X + p.Y * p.Y);
   }

   // Calculates the square length of the vector.
   public static double LengthSquare(this Point p)
   {
      return p.X * p.X + p.Y * p.Y;
   }
}

The squared length saves some cycles if this information is only needed for comparison.
Point p1 = new Point(200, 300);
Point p2 = new Point(400, 500);
Point distance = p1.Distance(p2);

double length = distance.Length();
double lengthSq = distance.LengthSquare();
length = Math.Sqrt(lengthSq);

Source Code
You can download the two C# files from here.

Tuesday, August 10, 2010

Coding4Fun - Part 1 of the Windows Phone Picture Effects App and Roadmap

My new Windows Phone 7 article for Microsoft's Coding4Fun site is live. It's the first part of a short series about the development of a Windows Phone 7 picture effects application called "PicFx". The first article will show how to create the base Windows Phone application and how to implement some basic effects. The source code is licensed under the Ms-PL and can be downloaded from the CodePlex site.
I'm already working on the second part of the series, which will explain how to implement advanced effects (the cool stuff) and other features. After this article I'll add more features and important effects, enhance the existing effects and release it as "Pictures Lab" on the Marketplace.

Video
The video below demonstrates the Coding4Fun PicFx application features and also shows how it can be used. It was recorded with the application running in the emulator.

Monday, August 2, 2010

Book Review - 3D Game Development with Microsoft Silverlight 3: Beginner's Guide

A couple of weeks ago I got a review copy of the book 3D Game Development with Microsoft Silverlight 3: Beginner's Guide. The book has 452 pages, is written by Gastón C. Hillar and shows how to write games with Silverlight.
Although the title includes "Silverlight 3", the concepts are also valid for newer versions of Silverlight, like the current version 4.
This blog post is a short review of the book. I also have one physical copy of the book to give away. Yeah, a free book, like free beer.






The Content
The book 3D Game Development with Microsoft Silverlight 3: Beginner's Guide starts by explaining what tools are needed for Silverlight game development. Then the first simple Silverlight application is developed.
The second chapter explains what Sprites are, how they can be used for 2D games and frame based animations. Silverlight 2.5D hardware accelerations is also covered and how basic vector transformations work.
The next chapter introduces a Sprite wrapper class and how to simplify the game loop with it. Basic 2D collision detection with an axis-aligned bounding box is covered too. The author also shows in this chapter how to use keyboard input for the game control.
Chapter 4 finally brings 3D game development. It starts with a WPF XAML Browser Application (XBAP) application that draws a 3D model, which was generated with the 3D modelling tool Blender and then exported to a XAML file. After this, the 3D engine Balder is introduced and a simple application is created. To be honest, Balder has come a long way since the book was written and a lot of new features were introduced. Nevertheless, many concepts and the basics are still valid.
The next chapter explains some 3D concepts like Cameras and shows how to use them with Balder and XBAP. The 6th chapter is about input controlling and demonstrates how to use DirectInput with the XBAP application. Chapter 7 explains textures, lights and the usage of these in a game. The next chapter is all about animation.
The 9th chapter introduces the Silverlight physics engine Farseer and chapter 10 shows how to detect collisions and apply basic artificial intelligence. The next chapter adds an asteroid belt to the space game, which is used as an example throughout the book.
In Chapter 12, the author shows how to measure the game progress and how to use Expression Blend to create screens for highscore and other statistics. The next chapter continues with this and also explains the usage of pixel shaders from the WPF Pixel Shader Effects Library. Persisting settings to the IsolatedStorage is covered too. The last chapter demonstrates how to play and control audio and video with the Silverlight MediaElement.

Summary
If you want to get into game development with Silverlight, this is the right book for you. It starts with the basic tools, then shows how to write a simple 2D game, finally how to write a 3D Silverlight game with Balder and how to add a physics system. Another nice thing of this book is that the tools and techniques to create / convert content are also shown step-by-step.
3D Game Development with Microsoft Silverlight 3: Beginner's Guide lives up to its title: "Beginner's Guide". If you are a beginner in the field of Silverlight game development and don't know where to start, buy this book here.

Free Book!
I actually got two physical copies of the book and I like to give one away. If you want the book, just write a comment why you should get this gift. Make sure to include some form of contact information.