Hi,
This is Nadia. I am using WpfDesktopEditionFull4.5.184 and trying to load stream loading of the image. I am using the following code:
private byte[] _imageStream; //initialized with bytes
private void WpfMap_Loaded(object sender, RoutedEventArgs e)
{
Map1.MapUnit = GeographyUnit.DecimalDegree;
Map1.CurrentExtent = new RectangleShape(-155.733, 95.60, 104.42, -81.9);
GdiPlusRasterLayer rasterLayer = new GdiPlusRasterLayer("dummy.jpg", new RectangleShape(-180, 90, 180, -90));
((GdiPlusRasterSource)rasterLayer.ImageSource).StreamLoading += new System.EventHandler<StreamLoadingEventArgs>(WpfMapExtended_StreamLoading_StreamLoading);
rasterLayer.UpperThreshold = double.MaxValue;
rasterLayer.LowerThreshold = 1;
LayerOverlay layerOverlay = new LayerOverlay();
layerOverlay.Layers.Add(rasterLayer);
Map1.Overlays.Add(layerOverlay);
Map1.Refresh();
}
void WpfMapExtended_StreamLoading(object sender, StreamLoadingEventArgs e) {
if (e.AlternateStreamName.Contains(".JPG") || e.AlternateStreamName.Contains(".jpg"))
{
MemoryStream memoryStream = new MemoryStream(_imageStream);
e.AlternateStream = memoryStream;
e.AlternateStreamName = "map.jpg";
}
else if (e.AlternateStreamName.Contains(".JGW") || e.AlternateStreamName.Contains(".jgw"))
{
//Convert the byte[] to image so that we can get width and height.
MemoryStream memoryStream = new MemoryStream(_imageStream);
Image mapImage = Image.FromStream(memoryStream);
WorldFile worldFile = new WorldFile(_fullExtend, mapImage.Width, mapImage.Height);
StringBuilder sb = new StringBuilder();
sb.AppendLine(worldFile.HorizontalResolution.ToString());
sb.AppendLine(worldFile.RotationRow.ToString());
sb.AppendLine(worldFile.RotationColumn.ToString());
sb.AppendLine(worldFile.VerticalResolution.ToString());
sb.AppendLine(worldFile.UpperLeftX.ToString());
sb.AppendLine(worldFile.UpperLeftY.ToString());
byte[] byteArray = Encoding.ASCII.GetBytes(sb.ToString());
MemoryStream stream = new MemoryStream(byteArray);
e.AlternateStream = stream;
e.AlternateStreamName = "map.jgw";
}
}
The problem is I am not getting any image. I used to get image with WpfDesktopEdition4.5 & now that I am trying to use WpfDesktopEditionFull4.5.184, the image is not there. Am i missing something?
Thanks,
Nadia