LocalPlugin Class |
Namespace: FreeImageAPI.Plugins
Assembly: FreeImageNET (in FreeImageNET.dll) Version: 3.17.0.4 (3.17.0)
public abstract class LocalPlugin
The LocalPlugin type exposes the following members.
Name | Description | |
---|---|---|
LocalPlugin |
The constructor automatically registeres the plugin in FreeImage.
To do this it prepares a FreeImage defined structure with function pointers
to the implemented functions or null if not implemented.
Before registing the functions they are pinned in memory so the garbage collector
can't move them around in memory after we passed there addresses to FreeImage.
|
Name | Description | |
---|---|---|
Enabled |
Gets or sets if the plugin is enabled.
| |
Format |
Gets the FREE_IMAGE_FORMAT FreeImage assigned to this plugin.
| |
Registered |
Gets if the plugin was registered successfully.
|
Name | Description | |
---|---|---|
CloseProc |
Function that can be implemented.
| |
DescriptionProc |
Function that can be implemented.
| |
Equals | (Inherited from Object.) | |
ExtensionListProc |
Function that can be implemented.
| |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
FormatProc |
Implementation of FormatProc | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetImplementedMethods |
Function that returns a bitfield containing the
implemented methods.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
LoadProc |
Function that can be implemented.
| |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
MimeProc |
Function that can be implemented.
| |
OpenProc |
Function that can be implemented.
| |
PageCapabilityProc |
Function that can be implemented.
| |
PageCountProc |
Function that can be implemented.
| |
Read |
Reads from an unmanaged stream.
| |
ReadByte |
Reads a single byte from an unmanaged stream.
| |
RegExprProc |
Function that can be implemented.
| |
SaveProc |
Function that can be implemented.
| |
Seek |
Seeks in an unmanaged stream.
| |
SupportsExportBPPProc |
Function that can be implemented.
| |
SupportsExportTypeProc |
Function that can be implemented.
| |
SupportsICCProfilesProc |
Function that can be implemented.
| |
Tell |
Retrieves the position of an unmanaged stream.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
ValidateProc |
Function that can be implemented.
| |
Write |
Writes to an unmanaged stream.
| |
WriteByte |
Writes a single byte to an unmanaged stream.
|
Name | Description | |
---|---|---|
format |
The format id assiged to the plugin.
| |
implementedMethods |
A copy of the functions used to register.
| |
registered |
When true the plugin was registered successfully else false.
|
The class below handles the creation of such a plugin. The class itself is abstract as well as some core functions that need to be implemented. The class can be used to enable or disable the plugin in FreeImage after regististration or retrieve the formatid, assigned by FreeImage. The class handles the callback functions, garbage collector and pointer operation to make the implementation as user friendly as possible.
How to: There are two functions that need to be implemented: GetImplementedMethods and FormatProc. GetImplementedMethods is used by the constructor of the abstract class. FreeImage wants a list of the implemented functions. Each function is represented by a function pointer (a .NET Delegate). In case a function is not implemented FreeImage receives an empty delegate). To tell the constructor which functions have been implemented the information is represented by a disjunction of LocalPluginMethodFlags.
For example: return MethodFlags.LoadProc | MethodFlags.SaveProc;
The above statement means that LoadProc and SaveProc have been implemented by the user. Keep in mind, that each function has a standard implementation that has static return values that may cause errors if listed in GetImplementedMethods without a real implementation.
FormatProc is used by some checks of FreeImage and must be implemented. LoadProc(FreeImageIO, fi_handle, Int32, Int32, IntPtr) for example can be implemented if the plugin supports reading, but it doesn't have to, the plugin could only be used to save an already loaded bitmap in a special format.