MapWinGIS:AxMap SnapShot2

This is a back-up of the WIKI.
Not all links might work
We're working on a new wiki.

Main Page | Recent changes | View source | Page history | Log in / create account |

Printable version | Disclaimers | Privacy policy


SnapShot2

Exports the map or a rectangular subregion of the map to an image. The extent and resolution of the image can be specified. In order to specify the image extents for the SnapShot2 function, there are two options:



VB.NET Usage

Function SnapShot2(ClippingLayerNbr As Integer, Zoom As Double, pWidth As Integer) As Object

            Parameters

ClippingLayerNbr The integer layer handle of the map layer. The extents of the exported image will be the same as the layer's extents.
Zoom Double - Set this value to 1.0
pWidth The width of the exported image in pixels. This parameter controls the resolution of the exported image. The value should not be greater than 3000.
Return Value Object - A MapWinGIS.Image object. This image can be saved to various image file formats.

VB.NET Sample Code

 'This code exports the current map view to an image with a width of 2000 pixels.
     'In the code, mainMap is the MapWindow 4 ActiveX map control.
     Private Sub CreateSnapShot2()
         Dim tempFileName As String = "c:\temp\Snapshot2.shp"
         Dim ImageWidth As Integer = 2000
         Dim tempShapefile As New MapWinGIS.Shapefile()
 
         'This is a temporary shapefile which outlines the extent of the snapshot
         If Not System.IO.File.Exists(tempFileName) Then
             tempShapefile.CreateNew(tempFileName, MapWinGIS.ShpfileType.SHP_POINT)
 
             'The temporary shapefile should also have at least one field
             Dim myFld As New MapWinGIS.Field
             myFld.Name = "Name"
             myFld.Type = MapWinGIS.FieldType.STRING_FIELD
             myFld.Width = 50
             tempShapefile.StartEditingShapes(True)
             Dim fldIndex As Integer = 0
             tempShapefile.EditInsertField(myFld, fldIndex, Nothing)
             tempShapefile.StopEditingShapes(True, True, Nothing)
         Else
             tempShapefile.Open(tempFileName)
         End If
 
         'Add the shapefile to the map as a temporary map layer
         Dim myHandle As Integer = mainMap.AddLayer(tempShapefile, True)
 
         'The extents of the current map view in projected coordinates
         Dim mapExtents As MapWinGIS.Extents = mainMap.Extents
 
         'Point located at bottom left corner of map view
         Dim myShape1 As New MapWinGIS.Shape
         myShape1.Create(MapWinGIS.ShpfileType.SHP_POINT)
         Dim myPoint1 As New MapWinGIS.Point
         myPoint1.x = mapExtents.xMin
         myPoint1.y = mapExtents.yMin
         myShape1.InsertPoint(myPoint1, myShape1.numPoints)
 
         'Point located at top right corner of map view
         Dim myShape2 As New MapWinGIS.Shape
         myShape2.Create(MapWinGIS.ShpfileType.SHP_POINT)
         Dim myPoint2 As New MapWinGIS.Point
         myPoint2.x = mapExtents.xMax
         myPoint2.y = mapExtents.yMax
         myShape2.InsertPoint(myPoint2, myShape2.numPoints)
 
         'Add the two corner points to the temporary shapefile
         tempShapefile.StartEditingShapes(True)
         tempShapefile.EditInsertShape(myShape1, tempShapefile.NumShapes)
         tempShapefile.EditInsertShape(myShape2, tempShapefile.NumShapes)
         tempShapefile.StopEditingShapes(True, True)
 
         'The map.Redraw() method must be called before executing Snapshot2
         mainMap.Redraw()
 
         'Execute the Snapshot2 Function
         Dim myImage As MapWinGIS.Image
         myImage = mainMap.SnapShot2(myHandle, 1.0, ImageWidth)
         If Not myImage Is Nothing Then
             myImage.Save("c:\temp\snapshot2.bmp", True)
         End If
 
         'Remove temporary layer from the map and clear shapes in temporary shapefile
         tempShapefile.StartEditingShapes(True)
         Dim shp As Integer = 0
         For shp = 0 To tempShapefile.NumShapes
             tempShapefile.EditDeleteShape(shp)
         Next
         mainMap.RemoveLayer(myHandle)
     End Sub

C# Usage

Object SnapShot2(int ClippingLayerNbr, double Zoom, int pWidth)

            Parameters

ClippingLayerNbr int
Zoom double
pWidth int
Return Value Object

C# Sample Code



VB 6 Usage

Function SnapShot2(ClippingLayerNbr As Long, Zoom As Double, pWidth As Long) As Object

            Parameters

ClippingLayerNbr Long
Zoom Double
pWidth Long
Return Value Object

VB 6 Sample Code


Back to MapWinGIS.Map

Retrieved from "http://mapwindow.org/wiki/index.php/MapWinGIS:AxMap_SnapShot2"

This page has been accessed 1,835 times. This page was last modified on 22 February 2009, at 06:34.