Is there a way to use .ico,.bmp,& .png images that are part of the project resources when defining PointStyles w/ GeoImage ? I noticed GeoImage takes a file path, but nothing that'll resolve down from an Icon or Bitmap, unless it's a TIFF(stream).
I can make a icon directory & use that easy enough, just wondered if there was a way to use the project images, such as "Properties.Resoures.MyDefaultIcon"
With the event GeoImage.StreamLoading, you can set the GeoImage by stream, not need to be by path.Here is some sample code I think would be helpful.
// Here is how to set the GeoImage InMemoryFeatureLayer bitmapLayer = new InMemoryFeatureLayer(); bitmapLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.PointType = PointType.Bitmap; // we create a geoImage with no file path GeoImage geoImage = new GeoImage(); geoImage.StreamLoading += new EventHandler<StreamLoadingEventArgs>(geoImage_StreamLoading); bitmapLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.Image = geoImage; bitmapLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
// Here we pass in a stream to e.AlternateStream which is the stream of the GeoImage. // We don’t need to set a file stream, any kind of stream is fine here void geoImage_StreamLoading(object sender, StreamLoadingEventArgs e) { e.AlternateStream = new System.IO.FileStream(@"..\..\SampleData\Data\United States.png", System.IO.FileMode.Open); e.FileAccess = System.IO.FileAccess.Read; e.FileMode = System.IO.FileMode.Open; }
Hi Ben, thanks for the reply! I played around a bit and found the way to load the images from the project resource:
//for any .png,.bmp,jpg, or other images supported by System.Drawing.Bitmap MemoryStream memStream = new MemoryStream(); Bitmap bm = Properties.Resources.MyImage; bm.Save(memStream, System.Drawing.Imaging.ImageFormat.Tiff); //GeoImage geo = new GeoImage(memStream); //or //e.AlternateStream = memStream