Programmatically grabbing a screenshot of the primary display

This blog post has moved to https://matthewvaneerde.wordpress.com/2011/11/29/programmatically-grabbing-a-screenshot-of-the-primary-display/