public void SaveAsImage(String fileName, ImageFormat imageFormat, int height, int width) { Bitmap bitmap = new Bitmap(width, height); MapEngine mapEngine = new MapEngine { CurrentExtent = ExtentHelper.GetDrawingExtent(winformsMap1.CurrentExtent, bitmap.Width, bitmap.Height) }; GeoBrush gb = new GeoSolidBrush(new GeoColor(winformsMap1.BackColor.A, winformsMap1.BackColor.R, winformsMap1.BackColor.G, winformsMap1.BackColor.B)); mapEngine.BackgroundFillBrush = gb; if (tsmiMapShowGrid.Checked) { mapEngine.StaticLayers.Add(_gridLayer); } foreach (ShapeFileFeatureLayer shapeFileFeatureLayer in _modelLayers) { mapEngine.StaticLayers.Add(shapeFileFeatureLayer); } //now add the markers. List markerTypeIds = (from CheckBox c in flpMarkerType.Controls where c.Checked select ((MarkerType)c.Tag).IDMarkerType).ToList(); foreach (int idMarkerType in markerTypeIds) { MarkerType mt = MarkerTypeHelper.Get(idMarkerType); InMemoryFeatureLayer markerLayer = new InMemoryFeatureLayer(); Image image = ImageHelper.GetMarkerImage(mt); var ms = new MemoryStream(); image.Save(ms, ImageFormat.Png); ms.Position = 0; markerLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(new GeoImage(ms)); markerLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; markerLayer.FeatureSource.Open(); markerLayer.FeatureSource.BeginTransaction(); foreach (ThinkGeoMarker item in _markersOverlay.Markers.Where(m => ((Marker)m.Tag).IDMarkerType == idMarkerType)) { markerLayer.InternalFeatures.Add(new Feature(item.Position)); } markerLayer.FeatureSource.CommitTransaction(); markerLayer.FeatureSource.Close(); mapEngine.StaticLayers.Add(markerLayer); } //now add the cumulative factors. foreach (ThinkGeoMarker cumulativeFactor in _modelThinkGeoCumulativeMarkers.Where(m => m.Visible)) { InMemoryFeatureLayer markerLayer = new InMemoryFeatureLayer(); Panel pnl = (Panel)cumulativeFactor.Controls[0]; Bitmap bmp = new Bitmap(pnl.Width, pnl.Height); pnl.DrawToBitmap(bmp, new Rectangle(0, 0, pnl.Width, pnl.Height)); var ms = new MemoryStream(); bmp.Save(ms, ImageFormat.Jpeg); ms.Position = 0; markerLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(new GeoImage(ms)); markerLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; markerLayer.FeatureSource.Open(); markerLayer.FeatureSource.BeginTransaction(); markerLayer.InternalFeatures.Add(new Feature(cumulativeFactor.Position)); markerLayer.FeatureSource.CommitTransaction(); markerLayer.FeatureSource.Close(); mapEngine.StaticLayers.Add(markerLayer); } mapEngine.OpenAllLayers(); mapEngine.DrawStaticLayers(bitmap, GeographyUnit.DecimalDegree); mapEngine.CloseAllLayers(); bitmap.Save(fileName, imageFormat); }