This project is read-only.

snapshot not working

Apr 26, 2014 at 8:28 PM
Edited May 4, 2014 at 12:05 PM

I'm trying to get a snapshot from a map. My problem is that I tried dozen of ways but my picturebox stays desperately empty !

Thanks for any help,

Mapwingis 4.8.8
May 3, 2014 at 2:36 PM
Edited May 4, 2014 at 12:04 PM
Here is the result :
Public Class Form1

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Dim image As New MapWinGIS.Image()
        Dim ex As MapWinGIS.Extents
            'Set extents to be the extents of the map
            ex = CType(Tablet2.WinMap1.Extents, MapWinGIS.Extents)
            'Take a picture of what is being displayed in map1 and store it in image
            image = CType(Tablet2.WinMap1.SnapShot(ex), MapWinGIS.Image)
            PictureBox1.Image = AxHostConverter.PictureDispToImage(CType(image.Picture, stdole.IPictureDisp))
        Catch exc As System.Exception
        End Try
    End Sub
End Class

Friend Class AxHostConverter
    Inherits AxHost
    Private Sub New()
    End Sub

    Public Shared Function ImageToPictureDisp(image As System.Drawing.Image) As stdole.IPictureDisp
        Return DirectCast(GetIPictureDispFromPicture(image), stdole.IPictureDisp)
    End Function

    Public Shared Function PictureDispToImage(pictureDisp As stdole.IPictureDisp) As System.Drawing.Image
        Return GetPictureFromIPicture(pictureDisp)
    End Function
End Class
May 6, 2014 at 5:51 AM
I recommend not to use snapshot but snapshot3 : using repetive calls to snapshot during mouseevent to drag the map, I get c++ runtime error after a dozen of seconds moving the map. Recursive or memory problems ?
Dec 5, 2014 at 8:10 AM
This might indeed by due to memory leaking.
For MapWinGIS v4.9.3 we are intensively hunting for memory leaks and found and fixed numerous ones.

It would be great if you could test your code with the latest version of MapWinGIS. The release of v4.9.3 is planned for Christmas 2014.


Dec 5, 2014 at 8:20 AM
Not, sure I will be ready for Xmas. but will try Paul