# Stream Loading using GdiPlusRasterLayer

**URL:** <https://community.thinkgeo.com/t/stream-loading-using-gdiplusrasterlayer/2995>\
**Category:** WPF\
**Created:** [May 17, 2011, 1:54pm UTC](https://community.thinkgeo.com/t/stream-loading-using-gdiplusrasterlayer/2995 "2011-05-17T13:54:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nadia](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/n/f19dbf/32.png) [@Nadia](https://community.thinkgeo.com/u/Nadia)\
**Post date:** [May 17, 2011, 1:54pm UTC](https://community.thinkgeo.com/t/stream-loading-using-gdiplusrasterlayer/2995/1 "2011-05-17T13:54:54Z")

</div>

Hi,

This&nbsp;is&nbsp;Nadia.&nbsp;I&nbsp;am&nbsp;using&nbsp;WpfDesktopEditionFull4.5.184&nbsp;and&nbsp;trying&nbsp;to&nbsp;load&nbsp;stream&nbsp;loading&nbsp;of&nbsp;the&nbsp;image.&nbsp;I&nbsp;am&nbsp;using&nbsp;the&nbsp;following&nbsp;code:

&nbsp;

`private byte[] _imageStream; //initialized with bytesprivate 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";   }}`

&nbsp;The&nbsp;problem&nbsp;is&nbsp;I&nbsp;am&nbsp;not&nbsp;getting&nbsp;any&nbsp;image.&nbsp;I&nbsp;used&nbsp;to&nbsp;get&nbsp;image&nbsp;with&nbsp;WpfDesktopEdition4.5&nbsp;&&nbsp;now&nbsp;that&nbsp;I&nbsp;am&nbsp;trying&nbsp;to&nbsp;use&nbsp;WpfDesktopEditionFull4.5.184,&nbsp;the&nbsp;image&nbsp;is&nbsp;not&nbsp;there.&nbsp;Am&nbsp;i&nbsp;missing&nbsp;something?&nbsp;

Thanks,&nbsp;

&nbsp;Nadia

---

<div class="post-metadata">

**Author:** ![Phil](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/p/e95f7d/32.png) [@Phil](https://community.thinkgeo.com/u/Phil)\
**Post date:** [May 17, 2011, 3:57pm UTC](https://community.thinkgeo.com/t/stream-loading-using-gdiplusrasterlayer/2995/2 "2011-05-17T15:57:12Z")

</div>

Nadia,

The&nbsp;4.5.184&nbsp;is&nbsp;a&nbsp;daily&nbsp;development&nbsp;build&nbsp;and&nbsp;it's&nbsp;possible&nbsp;this&nbsp;could&nbsp;be&nbsp;a&nbsp;bug.&nbsp;&nbsp;We&nbsp;have&nbsp;just&nbsp;released&nbsp;MapSuite&nbsp;5.0.&nbsp;&nbsp;If&nbsp;possible,&nbsp;I&nbsp;would&nbsp;recommend&nbsp;you&nbsp;visit&nbsp;[helpdesk.thinkgeo.com/FullDownload](http://helpdesk.thinkgeo.com/FullDownload)&nbsp;and&nbsp;download&nbsp;MapSuite&nbsp;5.0&nbsp;and&nbsp;see&nbsp;if&nbsp;that&nbsp;fixes&nbsp;your&nbsp;problem.&nbsp;

If&nbsp;you&nbsp;are&nbsp;still&nbsp;having&nbsp;troubles&nbsp;after&nbsp;the&nbsp;upgrade,&nbsp;please&nbsp;reply&nbsp;to&nbsp;this&nbsp;post&nbsp;and&nbsp;attach&nbsp;your&nbsp;sample&nbsp;imagery&nbsp;and&nbsp;we&nbsp;will&nbsp;address&nbsp;the&nbsp;problem.

Thanks,

Phil

---

<div class="post-metadata">

**Author:** ![Nadia](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/n/f19dbf/32.png) [@Nadia](https://community.thinkgeo.com/u/Nadia)\
**Post date:** [May 18, 2011, 12:29pm UTC](https://community.thinkgeo.com/t/stream-loading-using-gdiplusrasterlayer/2995/3 "2011-05-18T12:29:55Z")

</div>

Hi&nbsp;Phil,&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;used&nbsp;MapSuite&nbsp;5.0&nbsp;&&nbsp;instead&nbsp;of&nbsp;checking&nbsp;the&nbsp;AlternateStreamName,&nbsp;i&nbsp;checked&nbsp;StreamType&nbsp;and&nbsp;it&nbsp;worked.&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;help.&nbsp;  
&nbsp;&nbsp;  
&nbsp;regards,&nbsp;  
&nbsp;Nadia

---

<div class="post-metadata">

**Author:** ![Clint](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@Clint](https://community.thinkgeo.com/u/Clint)\
**Post date:** [May 18, 2011, 1:01pm UTC](https://community.thinkgeo.com/t/stream-loading-using-gdiplusrasterlayer/2995/4 "2011-05-18T13:01:58Z")

</div>

Nadia,&nbsp;  
&nbsp;&nbsp;  
&nbsp;I’m&nbsp;glad&nbsp;that&nbsp;fixed&nbsp;your&nbsp;issue!&nbsp;&nbsp;Thanks&nbsp;for&nbsp;posting.
