Hi,
I am wondering how can I save an image from map control, and how can I save an image of collection of Features.
Is there any API call i am missing here?
Thanks for the help.
Save image from map
Hi lalitya,
I guess the following method of WpfMap class is what you were looking for:
Bitmap GetBitmap(int width, int height)
It can be used to save an image from map control. While some codes are required if you would like to save an image for collection of features, following are some hints:
private MapEngine mMapEngine = new MapEngine();
private void Form1_Load(object sender, EventArgs e)
{
// We create a new points Layer to host all the points.
ImMemoryFeatureLayer pointLayer = new InMemoryFeatureLayer(...);
pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.Capital;
// This setting will apply from ZoonLevel01 to ZoomLevel20, that means we can see the world the same style with ZoomLevel01 all the time no matter how far we zoom out/in.
pointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
// We need to add the world layer to the mapEngine's Static Layer collection.
mMapEngine.StaticLayers.Add(pointLayer);
// Set a proper extent for the Map. ExtentHelper.GetDrawingExtent will modify the extent based on the width/height of the canvas.
mMapEngine.CurrentExtent = ExtentHelper.GetDrawingExtent(new RectangleShape(0, 78, 30, 26), pictureBox1.Width, pictureBox1.Height);
// Create a bitmap to prepare for drawing on.
Bitmap bitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height);
// Open the layer and draw it on the bitmap.
mMapEngine.OpenAllLayers();
// We set the unit of measurement to DecimalDegree because this is the inherent unit in the "Countries02.shp" file.
mMapEngine.DrawStaticLayers(bitmap, GeographyUnit.DecimalDegree);
mMapEngine.CloseAllLayers();
// Set the bitmap to pictureBox1.
pictureBox1.Image = bitmap;
}
Thanks,
Johnny
Hi Jhonny,
Thanks… i am able to save the image.
Hi Joseph,
You are welcome, if you have any questions please let me know.
Thanks
Summer