Gregory,
I can not recreate your problem under the latest version DesktopEdition by using the sample which you supply. Can you tell me which version you are using?
I don’t have jpeg image with world file, so I use tif file which you can find at SampleData folder under DesktopEdition install folder.
This is my client side code:
private void Form1_Load(object sender, EventArgs e)
{
winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
Bitmap bitmap = new Bitmap(@"..\..\App_Data\world.tif");
MemoryStream stream = new MemoryStream();
bitmap.Save(stream, ImageFormat.Tiff);
string worldFile = string.Empty;
using(StreamReader streamReader = new StreamReader( @"..\..\App_Data\world.tfw"))
{
worldFile = streamReader.ReadToEnd();
}
ImageRasterLayer worldImageLayer = new ImageRasterLayer(stream.ToArray(), worldFile);
worldImageLayer.UpperThreshold = double.MaxValue; worldImageLayer.LowerThreshold = 0;
worldImageLayer.IsGrayscale = false;
LayerOverlay ImageOverlay = new LayerOverlay();
ImageOverlay.Layers.Add("WorldImageLayer", worldImageLayer); winformsMap1.Overlays.Add(ImageOverlay);
winformsMap1.CurrentExtent = new RectangleShape(-118.098, 84.3, 118.098, -84.3);
winformsMap1.Refresh();
}
As you mentioned you have two kinds of DrawCore methods, both of them will throw exception.
If I use following code it works, not any exception.
protected override void DrawCore(GeoCanvas canvas, Collection<simplecandidate> labelsInAllLayers)
{
base.DrawCore(canvas, labelsInAllLayers);
}
If I following code it works first time call this method, when the second time, it will throw ArgumentException.
protected override void DrawCore(GeoCanvas canvas, Collection<simplecandidate> labelsInAllLayers)
{
this.ImageSource.Open();
base.DrawCore(canvas, labelsInAllLayers);
this.ImageSource.Close();
}
Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path)
at System.IO.Path.GetExtension(String path)
This exception is because the alternate stream name is wrong; you can update your method added following statement.
private void ImageRasterLayer_StreamLoading(object sender, StreamLoadingEventArgs e)
{
try
{
if (e.AlternateStreamName.IndexOf("JGW") < 0)
{
e.AlternateStream = OpenImageStream();
// add this code
e.AlternateStreamName = DOES_NOT_EXIST;
}
else
{
e.AlternateStream = OpenWorldFileStream();
}
}
catch (Exception ex)
{
ExceptionHandler.LogException(ex);
this.LoadedError = true;
this.LoadedException = ex;
}
}
Please let me know if you still have problem.
Thanks.
James