Sunday, March 27, 2011

A follow-on to "IC Game Design – A Key Tip for Success"

Michael Quandt posted a good tip about entering your WP7 app into Imagine Cup Game Design: basically, don't put your game in the Games Hub! The emulator doesn't include the Games Hub, which means when your .xap file gets deployed to the emulator, your game won't be accessible.

But how to actually fix this? Luckily, it's a simple change: in your project, find the WMAppManifest.xml file and change Genre="Apps.Games" to Genre="Apps.Normal". Now when you deploy your .xap to the emulator, it'll show up in the app list rather than the Games Hub.

Thursday, March 3, 2011

High Quality Dithering for Windows Phone 7

In my last post I showed how to use a 32bpp backbuffer to prevent banding in XNA games. But as it turns out, the WP7 hardware specifications only specify a 16-bit LCD at minimum - and that there are devices out there which only have a 16-bit LCD. (I've heard, but have not been able to confirm, that the Samsung devices suffer especially from this).

In that case, if a device only has an LCD capable of 16bpp, setting a 32bpp backbuffer isn't going to help. Instead, you need to dither your images, which will reduce the bit-depth to 16bpp but in a way which reduces visible banding.

I stumbled across this blog post "Photoshop Action for Windows Phone Dithering", which provides a photoshop script to dither images. It gets the job done, but I noticed that it produces a fairly low-quality dither - the end result is very grainy to my eyes.

A while back when I worked on Metropolitan Melbourne, I wrote my own little tool to dither images because WM6.5 only supported 16-bit colour graphics and I couldn't find any other simple tools for high-quality dithering. My tool is called ReduceBitDepthCPP, and takes an input 24-bit/32-bit image in .png or .bmp format, and reduces it to 16-bit (R5G6B5) colour using the Floyd-Steinberg algorithm. The Floyd-Steinberg algorithm eliminates banding while minimising quantisation error. Here's a comparison picture:

As expected, the undithered gradient has extreme banding. The "Photoshop" image was produced by using the script mentioned earlier. If you look closely, the Photoshop image does get rid of banding but also introduces a lot of noise - which makes the image very grainy.

On the top right is the Floyd-Steinberg algorithm produced by my tool, ReduceBitDepthCPP. It also eliminates banding but does so in a way that doesn't introduce a lot of noise, and the end result looks very close to the original.

You can download ReduceBitDepthCPP below, with source as well. It's free for any use, and the source code is distributed under the MIT license.


ReduceBitDepthCPP is a command-line tool, which makes it easier to integrate into your build. To use it:
  1. Extract the files somewhere (eg. C:\Temp\ReduceBitDepth\)
  2. Open up a command prompt by pressing [win]+[r] and typing in "cmd"
  3. Navigate to the directory where you extracted the files
  4. Run ReduceBitDepthCPP.exe using the following syntax:
    ReduceBitDepthCPP.exe infile outfile

ReduceBitDepthCPP.exe C:\Temp\meow_orig.png C:\Temp\meow_dithered.png

If you found this useful, don't forget to follow me on Twitter, and check out some of the stuff on my website!

Happy coding!

Wednesday, February 23, 2011

Tip of the Day: 32bpp BackBuffers in XNA

Here's a tip: by default, XNA uses a 16-bit R5G6B5 back buffer format. This causes horrific banding if you use lots of gradients in your game. You can fix this by manually telling XNA to use a 32-bit backbuffer format.

In you Game class's constructor, add this line:

graphics.PreparingDeviceSettings += PreparingDeviceSettingsEventHandler;

And somewhere in your Game class, add this method:

void PreparingDeviceSettingsEventHandler(object sender, PreparingDeviceSettingsEventArgs e)
    var pp = e.GraphicsDeviceInformation.PresentationParameters;
    pp.BackBufferFormat = SurfaceFormat.Color;

The difference won't show up in the emulator. But on an actual device, it'll vastly increase your image quality by getting rid of a lot of your banding.

Wednesday, February 16, 2011

SatView for Windows Phone 7 Released!

I'm happy to announce that SatView is now available on the Windows Phone 7 marketplace!

This'll be my entry to the DevVsDev competition. SatView is a satellite tracker and orbit predictor that allows you to track one of 1300+ different satellites as they orbit the Earth. Here's the marketing spiel from my site:

SatView is a realtime satellite tracker and orbit predictor. Track satellite positions, determine visibility, and calculate coordinates of over 1300 different satellites.

Included with SatView are both 2D and 3D viewing modes, allowing you to view the orbital trajectories of satellies from space or projected onto a map. SatView can also use your phone's GPS system to determine visibility and to calculate satellite passes over your location. SatView is ideal for budding astronomers and amateurs alike.


  • 1300+ different trackable satellites
  • Orbit prediction with adjustable time controls
  • GPS and location services support
  • Determine all visible satellites from your current location
  • Calculate next visible passes of a chosen satellite over your location
  • Search function for finding satellites by name or catalog number
  • 2D and 3D orbit viewing modes
  • Topographic and geocentric coordinates
  • Automatic updates for latest satellite orbital data

I'll admit that this is a pretty niche app. But still, I think it's cool. :) And remember, if you don't already know, DevVsDev closes in just a few weeks, so you'd better submit fast!

only US$1.29

Download for Windows Phone 7
Zune client software required.

More information at

Saturday, February 12, 2011

Super-secret projects

Apparently I suck at pressing "publish post". I pressed "save" instead of "publish" on that last post, so it's a few days late. Luckily, Blogger lets you arbitrarily set dates on your blog posts. :P

Over the past few weeks I've been working on my entry to the Microsoft DevVsDev competition. DevVsDev is a Windows Phone 7 application development contest run by Microsoft for Australian developers. Basically the gist of it is this: write an app for WP7. Submit it. Best app wins a trip to MIX11 in Las Vegas valued at $10k, and the next 5 runners up get free Windows Phone 7's. Entries close 28th February 2011, which is in just a couple of weeks. If you want to enter, you'd better act fast!

Today, I submitted my application to marketplace. Once it passes certification, I'll be entering it into DevVsDev. What is my app? Well, I'll reveal more once it hits marketplace. Is it good enough to win? Heck, I dunno. It's just something I've been working on in my free time, and I have no idea what my competition is. But seeing as the developer tools have been downloaded over 1 million times, I expect to see some pretty amazing apps in DevVsDev.

Regardless of whether I win anything or not, developing for WP7 is just plain fun. If you haven't already considered it, I would highly recommend submitting an entry and having a chance at one of 6 fabulous prizes!

Thursday, February 10, 2011

Microsoft Student Partner Summit 2011

Now that the MSP bootcamp is over, I guess I can officially call myself a Microsoft Student Partner. :D

Yesterday, I got back from the MSP 2011 Bootcamp. This is my first time as a Microsoft Student Partner, and the experience was certainly one to remember.

On Monday Microsoft flew us all to Sydney for a 3-day summit at their North Ryde Headquarters. 38 MSPs from all over Australia were there, representing 28 universities. I got to meet a lot of awesome fellow MSPs, as well as a bunch of equally awesome Microsofties.

Throughout the three days were a bunch of introductions, presentations, workshops, activities, and fun to be had all round. Oh, and free stuff. Lots of it. But maybe that's a post for another day.

Before the bootcamp, I was excited to be an MSP. Now? I'm PUMPED. I won't reveal just yet what's planned, but it's going to be an amazing year. I look forward to it!