Home > Uncategorized > Upload screencapture Windows Phone 7.8

Upload screencapture Windows Phone 7.8

After upgrading my phone to Windows Phone 7.8 from 7.1, I noticed that my screen capture app stopped working. Which was very unfortunate, since there doesn’t appear to be another way of capturing images via Windows Phone 7 (I’m not talking about WP8)

I found a snippet of code that captures screenshots from within your own app, and saves it in your media library, which is cool, but as soon as I tried to resolve the reference to new MediaLibrary(), I saw that you needed to include the Microsoft XNA framework for Wndows Phone 7, which wouldn’t be a problem, only I’m running on Windows XP, and XNA for WP7 does not install in Windows XP!

In frustration, I decided to see if I could upload the image to my server, using a script I wrote earlier to store camera images from a iPhone app, – Changing the upload folder, of course, so that I wouldn’t mix up the images.

private void Panorama_ManipulationCompleted(object sender, 
ManipulationCompletedEventArgs e)

WriteableBitmap bmpCurrentScreenImage = new 
WriteableBitmap((int)this.ActualWidth, (int)this.ActualHeight);
bmpCurrentScreenImage.Render(LayoutRoot, new 


public void SaveToMediaLibrary(WriteableBitmap bitmap, int quality)
using (var stream = new System.IO.MemoryStream())
// Save the picture to the Windows Phone media library.
bitmap.SaveJpeg(stream, bitmap.PixelWidth, 
bitmap.PixelHeight, 0, quality);
stream.Seek(0, SeekOrigin.Begin);
var byteArray = stream.ToArray();
string strBase64 = Convert.ToBase64String(byteArray);
WebClient webClient = new WebClient();
webClient.Headers[HttpRequestHeader.ContentType] = 
var uri = new 
Uri("http://yourdomain.com/upload.aspx", UriKind.Absolute);
string strPostData = "image=" + 
webClient.Headers[HttpRequestHeader.ContentLength] = 
webClient.UploadStringAsync(uri, "POST", strPostData);

Note that I attached this to Panorama_ManipulationCompleted, which basically means it gets triggered every time the panorama control is scrolled, or touched, which tends to upload quite a large number of screenshots, but more is better than too few for my needs. Obviously, this code should be commented out before submitting to Microsft!

Categories: Uncategorized
  1. May 4, 2013 at 2:09 pm

    My last comment on this post was that the feature should be turned off before submitting to Microsoft… I accidentally forgot this part, and the interesting side effect is that I got to see exactly what the reviewer tested – hint – they always check light & dark themes ! 🙂


  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: