I am loading a TIFF using the following code, but the image does not appear. Is there something wrong (maybe with the World File? I downloaded the image from TerraServer and it came with the World File.
Private Sub AddRasterImage(ByVal filePath As String, ByVal OverlayKey As String)
Dim worldImageLayer As GdiPlusRasterLayer = New GdiPlusRasterLayer(filePath)
AddHandler (CType(worldImageLayer.ImageSource, GdiPlusRasterSource)).StreamLoading, AddressOf Image_StreamLoading
worldImageLayer.UpperThreshold = Double.MaxValue
worldImageLayer.LowerThreshold = 0
worldImageLayer.IsGrayscale = False
Dim ImageOverlay As LayerOverlay = New LayerOverlay()
ImageOverlay.Layers.Add(OverlayKey & "Layer", worldImageLayer)
WpfMap1.Overlays.Add(OverlayKey & "Overlay", ImageOverlay)
WpfMap1.Overlays.MoveToBottom(WpfMap1.Overlays.IndexOf(ImageOverlay))
End Sub
Private Sub Image_StreamLoading(ByVal sender As Object, ByVal e As StreamLoadingEventArgs)
If e.StreamType = "Image File" Then
Dim stream As IO.Stream = New FileStream(e.AlternateStreamName, FileMode.Open, FileAccess.Read)
e.AlternateStream = stream
End If
If e.StreamType = "World File" Then
Dim fName As String = IO.Path.GetFullPath(e.AlternateStreamName)
Select Case IO.Path.GetExtension(e.AlternateStreamName).ToUpper
Case ".TIF"
fName = fName.Substring(0, fName.Length - 3) & "tfw"
Case ".JPG"
fName = fName.Substring(0, fName.Length - 3) & "jgw"
End Select
Dim stream As IO.Stream = New FileStream(fName, FileMode.Open, FileAccess.Read)
e.AlternateStream = stream
End If
End Sub
The World File contains:
5.648000
0.000000
0.000000
-5.648000
573645.000000
2918226.000000
If I use:
Dim worldImageLayer As GdiPlusRasterLayer = New GdiPlusRasterLayer(filePath, New RectangleShape(-80.26173, 26.38224, -80.1914, 26.31811))
without streaming, then the image shows up