Quantcast
Viewing all articles
Browse latest Browse all 2341

New Post: Loop through images to simulate video

well that may be what I'm doing? I am loading an image and adding as a layer. i then cycle through my other images and open those up with the same image object so I think it's still using the one layer but the reference to the image has been changed? Unless I am effectively clearing the current image before adding another. Can you take a look and see how this looks to you? It seems to work pretty well but I may be using more resources than I should. I am trying also to account for the case where the user clicks on the button more than once to replay the "video" more than once.
'global variables
Dim img As MapWinGIS.Image 
Dim hnd As Integer

 Private Sub btnLoadImages_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadImages.Click
        Try
            Dim gifFile As String = My.Computer.FileSystem.CombinePath(My.Application.Info.DirectoryPath(), "Wx\radar.gif")

            If My.Computer.FileSystem.FileExists(gifFile) Then
                If img IsNot Nothing Then
                    img.Clear()
                Else
                    img= New MapWinGIS.Image
                End If

                If img.Open(gifFile, MapWinGIS.ImageType.USE_FILE_EXTENSION) Then
                    hnd = mapMain.AddLayer(img, True)
                Else
                    MsgBox("Could not load image." & crlf & img.ErrorMsg(img.LastErrorCode), MsgBoxStyle.Critical)
                End If

                'cycle through the collection of images
                For i As Integer = 1 To 28 Step 1
                    System.Threading.Thread.Sleep(25)

                    gifFile = My.Computer.FileSystem.CombinePath(My.Application.Info.DirectoryPath(), "Wx\radarNTS" & i & ".gif")

                    img.Clear()
                    img.Open(gifFile, MapWinGIS.ImageType.USE_FILE_EXTENSION)
                    System.Threading.Thread.Sleep(25)

                    mapMain.Redraw()
                    mapMain.Refresh()
                    System.Threading.Thread.Sleep(25)
                    Application.DoEvents()
                Next i

                MsgBox("Done.", MsgBoxStyle.Information)
            Else
                MsgBox("Image file does not exist.", MsgBoxStyle.Exclamation)
            End If
        Catch ex As Exception
            MsgBox("There was an error encountered." & ControlChars.CrLf & ex.ToString, MsgBoxStyle.Critical)
        End Try
    End Sub

Viewing all articles
Browse latest Browse all 2341

Trending Articles