FreeImage.NET Class Library Reference
fi_handle Structure |
Wrapper for a custom handle.
Namespace: FreeImageAPI.IO
Assembly: FreeImageNET (in FreeImageNET.dll) Version: 3.17.0.4 (3.17.0)
Syntax
C#
[SerializableAttribute] public struct fi_handle : IComparable, IComparable<fi_handle>, IEquatable<fi_handle>, IDisposable
The fi_handle type exposes the following members.
Constructors
Properties
Methods
Name | Description | |
---|---|---|
CompareTo(Object) |
Compares this instance with a specified Object.
| |
CompareTo(fi_handle) |
Compares this instance with a specified fi_handle object.
| |
Dispose |
Releases all resources used by the instance.
| |
Equals(Object) |
Tests whether the specified object is a fi_handle structure
and is equivalent to this fi_handle structure.
(Overrides ValueTypeEquals(Object).) | |
Equals(fi_handle) |
Indicates whether the current object is equal to another object of the same type.
| |
GetHashCode |
Returns a hash code for this fi_handle structure.
(Overrides ValueTypeGetHashCode.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
ToString |
Converts the numeric value of the fi_handle object
to its equivalent string representation.
(Overrides ValueTypeToString.) |
Operators
Name | Description | |
---|---|---|
Equality |
Tests whether two specified fi_handle structures are equivalent.
| |
Inequality |
Tests whether two specified fi_handle structures are different.
|
Fields
Remarks
The fi_handle of FreeImage in C++ is a simple pointer, but in .NET
it's not that simple. This wrapper uses fi_handle in two different ways.
We implement a new plugin and FreeImage gives us a handle (pointer) that
we can simply pass through to the given functions in a 'FreeImageIO'
structure.
But when we want to use LoadFromhandle or SaveToHandle we need
a fi_handle (that we receive again in our own functions).
This handle is for example a stream (see LoadFromStream / SaveToStream)
that we want to work with. To know which stream a read/write is meant for
we could use a hash value that the wrapper itself handles or we can
go the unmanaged way of using a handle.
Therefor we use a GCHandle to receive a unique pointer that we can
convert back into a .NET object.
When the fi_handle instance is no longer needed the instance must be disposed
by the creater manually! It is recommended to use the using statement to
be sure the instance is always disposed:
What does that mean?
If we get a fi_handle from unmanaged code we get a pointer to unmanaged
memory that we do not have to care about, and just pass ist back to FreeImage.
If we have to create a handle our own we use the standard constructur
that fills the IntPtr with an pointer that represents the given object.
With calling GetObject the IntPtr is used to retrieve the original
object we passed through the constructor.
This way we can implement a fi_handle that works with managed an unmanaged
code.
using (fi_handle handle = new fi_handle(object)) { callSomeFunctions(handle); }
See Also