Class NativeImageRasterSource
This class allows you to view standard .NET GDI+ image types such as BMP, TIF, JPG, and PNG.
public class NativeImageRasterSource : RasterSource
- Inheritance
-
NativeImageRasterSource
- Inherited Members
Remarks
This class handles all default supported image types of GDI+. As none of these types embed geographic information in them, you will need to ensure that the image file is always accompanied by a world file. The world file is text file that stores the associated geographic information we need to properly display the image along with your other feature data.
Constructors
NativeImageRasterSource()
This is the constructor the for the class.
public NativeImageRasterSource()
Remarks
None
NativeImageRasterSource(string)
This is the constructor the for the class.
public NativeImageRasterSource(string imagePathFilename)
Parameters
imagePathFilename
stringThis parameter represents the image you want to load.
Remarks
You can specify a path and filename that does not actually exist if you use the StreamLoading event. This event only uses the PathFilename parameter as a unique string that will be passed to you in the event, so that you can determine what stream you want to pass back.
NativeImageRasterSource(string, string)
This is the constructor the for the class.
public NativeImageRasterSource(string imagePathFilename, string worldfilePathFilename)
Parameters
imagePathFilename
stringThis parameter represents the image you want to load.
worldfilePathFilename
stringThis parameter represents the world file path and filename you want to load.
Remarks
You can specify a path and filename that does not actually exist if you use the StreamLoading event. This event only uses the PathFilename parameter as a unique string that will be passed to you in the event, so that you can determine what stream you want to pass back.
NativeImageRasterSource(string, RectangleShape)
This is the constructor the for the class.
public NativeImageRasterSource(string imagePathFilename, RectangleShape imageExtent)
Parameters
imagePathFilename
stringThis parameter represents the image you want to load.
imageExtent
RectangleShapeThis parameter represents the extnet of the image you want to load.
Remarks
You can specify a path and filename that does not actually exist if you use the StreamLoading event. This event only uses the PathFilename parameter as a unique string that will be passed to you in the event, so that you can determine what stream you want to pass back.
Properties
FileName
This property returns the filename part of the PathFilename.
public string FileName { get; }
Property Value
Remarks
None
FilePath
This property returns the path part of the PathFilename.
public string FilePath { get; }
Property Value
Remarks
None
ImagePathFilename
This property returns the path and filename of the image you want to represent.
public string ImagePathFilename { get; set; }
Property Value
Remarks
When you specify the path and filename, it should be in the correct format as such; however, the file does not need to actually exist on the file system. This is to allow us to accept streams supplied by the developer at runtime. If you choose to provide a file that exists, we will attempt to use it. If we cannot find it, then we will raise the SteamLoading event and allow you to supply the stream. For example, you can pass in "C:\NotARealPath\File1.jpg" which does not exist on the file system. When we raise the event for you to supply a stream, we will pass to you the path and filename so you can differentiate the files.
Exceptions
- ArgumentException
Setting an invalid FilePathName structure will throw an ArgumentException.
IsGrayscale
This property gets and sets whether the image shows in grayscale.
public bool IsGrayscale { get; set; }
Property Value
Remarks
This property allows you to show the image in grayscale.
IsNegative
This property gets and sets whether the image shows as negative (inverted colors).
public bool IsNegative { get; set; }
Property Value
Remarks
You can set this property to show the negative of the image.
Methods
CloseCore()
This method opens the Image so that it is initialized and ready to use.
protected override void CloseCore()
Remarks
This protected virtual method is called from the concrete public method Close.
The Close method plays an important role in the life cycle of the Image. It may
be called after drawing to release any memory and other resources that were allocated
since the Open method was called.
If you override this method, it is recommended that that you take the following things
into account: This method may be called multiple times, so we suggest you write the method so
that that a call to a closed FeatureSource is ignored and does not generate an error.
We also suggest that in the Close you free all resources that have been opened.
Remember that the object will not be destroyed, but will be re-opened possibly in the
near future.
GetBoundingBoxCore()
This method returns the bounding box of the RasterSource.
protected override RectangleShape GetBoundingBoxCore()
Returns
- RectangleShape
This method returns the bounding box of the RasterSource.
Remarks
This method returns the bounding box of the RasterSource.
Exceptions
- InvalidOperationException
In the event you attempt to call this method on a image source which has not been opened, it will throw an InvalidOperationException.
GetImageCore(RectangleShape, int, int)
This method returns an image based on the worldExtent, image width and image height.
protected override GeoImage GetImageCore(RectangleShape worldExtent, int canvasWidth, int canvasHeight)
Parameters
worldExtent
RectangleShapeThis parameter represents the worldExtent you want to draw.
canvasWidth
intThis parameter represents the width of the image you want to draw.
canvasHeight
intThis parameter represents the height of the image you want to draw.
Returns
- GeoImage
This method returns an image based on the worldExtent, image width and image height.
Remarks
This method is responsible for returning the image based on the parameters passed in.
Exceptions
- ArgumentNullException
If you pass in a worldExtent that is invalid, we will throw an ArgumentNullException.
- ArgumentException
If you pass in a worldExtent that is invalid, we will throw an ArgumentException.
- ArgumentOutOfRangeException
If you pass in a image width that is smaller than or equal to 0, we will throw an ArgumentOutOfRangeException.
- ArgumentOutOfRangeException
If you pass in a image height that is smaller than or equal to 0, we will throw an ArgumentOutOfRangeException.
- InvalidOperationException
In the event you attempt to call this method on a image source which has not been opened, it will throw an InvalidOperationException.
GetImageHeightCore()
This method returns the height of the image in screen coordinates.
protected override int GetImageHeightCore()
Returns
- int
This method returns the height of the image in screen coordinates.
Remarks
This method returns the height of the image in screen coordinates.
Exceptions
- InvalidOperationException
In the event you attempt to call this method on a image source which has not been opened, it will throw an InvalidOperationException.
GetImageWidthCore()
This method returns the width of the image in screen coordinates.
protected override int GetImageWidthCore()
Returns
- int
This method returns the width of the image in screen coordinates.
Remarks
This method returns the width of the image in screen coordinates.
Exceptions
- InvalidOperationException
In the event you attempt to call this method on a image source which has not been opened, it will throw an InvalidOperationException.
OnStreamLoading(StreamLoadingEventArgs)
This method allows you to raise the StreamLoading event.
protected virtual void OnStreamLoading(StreamLoadingEventArgs e)
Parameters
e
StreamLoadingEventArgsThis parameter represents the event arguments you want to raise the StreamLoading event with.
Remarks
This method allows you to raise the StreamLoading event. Normally events are not accessible to derived classes, so we exposed a way to raise the event as necessary through this protected method.
OpenCore()
This method opens the Image so that it is initialized and ready to use.
protected override void OpenCore()
Remarks
This protected virtual method is called from the concrete public method Open.
The Open method plays an important role, as it is responsible for initializing the
Image. Most methods on the Image will throw an exception if the state of
the Image is not opened. When the map draws each layer, it will open the
Image as one of its first steps; then, after it is finished drawing with that
layer, it will close it. In this way, we are sure to release all resources used by the
Image.
When implementing this abstract method, consider opening files for file-based sources,
connecting to databases in the database-based sources and so on. You will get a chance
to close these in the Close method of the Image.
Exceptions
- InvalidOperationException
In the event you attempt to call this method on a image source which has already been opened, it will throw an InvalidOperationException.
- NotSupportedException
If the file format you passed is not one of these: .bmp, .gif, .exig, .jpg, .png, or .tiff, we will throw a NotSupportedException.
- FileNotFoundException
If the world file cannot be found using the filename you passed, we will throw an FileNotFoundException when the source is not from a stream.
Events
StreamLoading
This event allows you to pass in your own stream to represent the image.
public event EventHandler<StreamLoadingEventArgs> StreamLoading
Event Type
Remarks
If you wish, you can pass in your own stream to represent the image. The stream can come from a variety of places, including isolated storage, a compressed file, or an encrypted stream. When the image is finished with the stream it will dispose of it, so be sure to keep this in mind when passing the stream in. If you do not pass in an alternate stream, the class will attempt to load the file from the file system using the PathFilename property.