How to get a map screenshot or save map to a png file

Aug 24, 2010 at 6:55 AM

I want to save the mapcontrol image  into a png file. I tried silverlight 3's WriteableBitmap() to get the Map control snapshot:

WriteableBitmap bitmap = new WriteableBitmao(map,null);

img.Source = bitmap;

and hope to use .NET ImageTools  library 's(which is also a CodePlex project)  to get a png file.  Link of the method is 

Unfortanately, I get Security Exception errors when I call bitmap.ToImage() (this is the .Net ImageTools function. It will read pixel data. )

I cannot read pixel data using the bitmap.Pixels[], but I can put the bitmap to a image control as source.

It seems that Silverlight's WriteableBitmap does not full support MulitScaleImage,  seen form this post . As the DeepEarth's Map Controler is depend on the MultiScaleImage,  so trying to use WriteableBitmap is a wrong way?

I need this function very much, is there any way to do this?

Aug 24, 2010 at 9:10 AM
there is a security issue and you cannot read the pixels from the
WriteableBitmap when it is created from a MulitScaleImage and also
from a MediaElement e.g. a snapshot of a frame from a movie,
SoulSolutions/John tried to solve this issue too, but could not find a
way to do it
Aug 24, 2010 at 11:53 AM

Thanks, hope it can be solved  ^_^

Jul 7, 2011 at 3:45 PM

Any luck on this?

Jul 7, 2011 at 4:29 PM
Nope, when I tried I ran into security issues reading tiles from the tile provider.

Jul 7, 2011 at 6:30 PM
Edited Jul 7, 2011 at 6:41 PM

In the new example the following is used to get an image of the BaseLayer of the map for printing purposes. It seems to work just fine.

new Image { Source = new WriteableBitmap(MapInstance.BaseLayer.Msi, null) };

But what I want to do is print the map along with everything that is on it in the other layers. Any ideas?