Hello
How can I update an ImageSource of raster layer on the fly, dynamically? I have tried an approach from StreamLoadingForGdiPlusRasterLayer example but no luck. Please explain when the streamloading event is called? Is it called only once? I need it to be called every time
my stream image changes.
Thanks
Janna
Update GdiPlusRasterLayer ImageSource on the fly
Hi Janna,
The StreamLoading event is called in Open() method, in other words, it’s just called only once for initialization. If you would like to change the ImageSource dynamically, a better way is that creating a customized GdiPlusRasterLayer and overwrite the DrawCore method, there you can create a new instance of GdiPlusRasterSource and assign it to this.ImageSource, then implement the base.DrawCore().
Regards,
Johnny
Hi Johnny
Can you provide a code for how the stream will be updated? My stream is memory and not saved to the file on disk. How can i pass the stream?
Thank you
Hi Janna,
I guess what Johnny means is like this:
internal class CustomGdiPlusRasterLayer : GdiPlusRasterLayer
{
protected override void DrawCore(GeoCanvas canvas, System.Collections.ObjectModel.Collection<
SimpleCandidate
> labelsInAllLayers)
{
this.StreamLoading += CustomGdiPlusRasterLayer_StreamLoading;
this.Open();
base.DrawCore(canvas, labelsInAllLayers);
}
void CustomGdiPlusRasterLayer_StreamLoading(object sender, StreamLoadingEventArgs e)
{
// e.AlternateStream = …
}
}
Please try it to see if it works for you.
Thanks,
Troy