WP7 Sample–Create a JPG screenshot of Bing maps control Today I saw a colleague ask an interesting question, how do you create a screenshot of a map that can be used in a list as a thumbnail? so I did some digging and came up with this sample that can be downloaded from the link below. http://cid-c6b45be43711d8b8.skydrive.live.com/self.aspx/Code%20Samples/wp7Sample.ScreenshotOfMap.zip In summary for those who don’t want to download the sample app, most of the work is done inside of the “Take picture” button, here is the source: // Store the size of the map control int Width = (int)mapTest.RenderSize.Width; int Height = (int)mapTest.RenderSize.Height; // Write the map control to a WriteableBitmap WriteableBitmap screenshot = new WriteableBitmap(mapTest, new TranslateTransform()); using (MemoryStream ms = new MemoryStream()) { // Save it to a memory stream screenshot.SaveJpeg(ms, Width, Height, 0, 100); // Take saved memory stream and put it back into an BitmapImage BitmapImage i...
Comments
Post a Comment