LocalPlugin Class

FreeImage.NET

LocalPlugin Class
Class representing own FreeImage-Plugins.
Inheritance Hierarchy
SystemObject  FreeImageAPI.PluginsLocalPlugin

Namespace: FreeImageAPI.Plugins
Assembly: FreeImageNET (in FreeImageNET.dll) Version: 3.17.0.4 (3.17.0)
Syntax
C#
public abstract class LocalPlugin

The LocalPlugin type exposes the following members.

Constructors
  NameDescription
Public methodLocalPlugin
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.
Top
Properties
  NameDescription
Public propertyEnabled
Gets or sets if the plugin is enabled.
Public propertyFormat
Gets the FREE_IMAGE_FORMAT FreeImage assigned to this plugin.
Public propertyRegistered
Gets if the plugin was registered successfully.
Top
Methods
  NameDescription
Protected methodCloseProc
Function that can be implemented.
Protected methodDescriptionProc
Function that can be implemented.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodExtensionListProc
Function that can be implemented.
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Protected methodFormatProc
Implementation of FormatProc
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Protected methodGetImplementedMethods
Function that returns a bitfield containing the implemented methods.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodLoadProc
Function that can be implemented.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodMimeProc
Function that can be implemented.
Protected methodOpenProc
Function that can be implemented.
Protected methodPageCapabilityProc
Function that can be implemented.
Protected methodPageCountProc
Function that can be implemented.
Protected methodRead
Reads from an unmanaged stream.
Protected methodReadByte
Reads a single byte from an unmanaged stream.
Protected methodRegExprProc
Function that can be implemented.
Protected methodSaveProc
Function that can be implemented.
Protected methodSeek
Seeks in an unmanaged stream.
Protected methodSupportsExportBPPProc
Function that can be implemented.
Protected methodSupportsExportTypeProc
Function that can be implemented.
Protected methodSupportsICCProfilesProc
Function that can be implemented.
Protected methodTell
Retrieves the position of an unmanaged stream.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Protected methodValidateProc
Function that can be implemented.
Protected methodWrite
Writes to an unmanaged stream.
Protected methodWriteByte
Writes a single byte to an unmanaged stream.
Top
Fields
  NameDescription
Protected fieldformat
The format id assiged to the plugin.
Protected fieldimplementedMethods
A copy of the functions used to register.
Protected fieldregistered
When true the plugin was registered successfully else false.
Top
Remarks
FreeImages itself is plugin based. Each supported format is integrated by a seperat plugin, that handles loading, saving, descriptions, identifing ect. And of course the user can create own plugins and use them in FreeImage. To do that the above mentioned predefined methodes need to be implemented.

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.

See Also