// ==========================================================
// FreeImage 3 .NET wrapper
// Original FreeImage 3 functions and .NET compatible derived functions
//
// Design and implementation by
// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net)
// - Carsten Klein (cklein05@users.sourceforge.net)
//
// Contributors:
// - David Boland (davidboland@vodafone.ie)
//
// Main reference : MSDN Knowlede Base
//
// This file is part of FreeImage 3
//
// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
// THIS DISCLAIMER.
//
// Use at your own risk!
// ==========================================================
// ==========================================================
// CVS
// $Revision: 1.4 $
// $Date: 2009/09/15 11:39:10 $
// $Id: Delegates.cs,v 1.4 2009/09/15 11:39:10 cklein05 Exp $
// ==========================================================
using System;
using System.IO;
using System.Runtime.InteropServices;
using FreeImageAPI.IO;
namespace FreeImageAPI
{
// Delegates used by the FreeImageIO structure
///
/// Delegate for capturing FreeImage error messages.
///
/// The format of the image.
/// The errormessage.
// DLL_API is missing in the definition of the callbackfuntion.
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi, ThrowOnUnmappableChar = false)]
public delegate void OutputMessageFunction(FREE_IMAGE_FORMAT fif, string message);
}
namespace FreeImageAPI.IO
{
///
/// Delegate to the C++ function fread.
///
/// Pointer to read from.
/// Item size in bytes.
/// Maximum number of items to be read.
/// Handle/stream to read from.
/// Number of full items actually read,
/// which may be less than count if an error occurs or
/// if the end of the file is encountered before reaching count.
public delegate uint ReadProc(IntPtr buffer, uint size, uint count, fi_handle handle);
///
/// Delegate to the C++ function fwrite.
///
/// Pointer to data to be written.
/// Item size in bytes.
/// Maximum number of items to be written.
/// Handle/stream to write to.
/// Number of full items actually written,
/// which may be less than count if an error occurs.
/// Also, if an error occurs, the file-position indicator cannot be determined.
public delegate uint WriteProc(IntPtr buffer, uint size, uint count, fi_handle handle);
///
/// Delegate to the C++ function fseek.
///
/// Handle/stream to seek in.
/// Number of bytes from origin.
/// Initial position.
/// If successful 0 is returned; otherwise a nonzero value.
public delegate int SeekProc(fi_handle handle, int offset, SeekOrigin origin);
///
/// Delegate to the C++ function ftell.
///
/// Handle/stream to retrieve its currents position from.
/// The current position.
public delegate int TellProc(fi_handle handle);
// Delegates used by 'Plugin' structure
}
namespace FreeImageAPI.Plugins
{
///
/// Delegate to a function that returns a string which describes
/// the plugins format.
///
public delegate string FormatProc();
///
/// Delegate to a function that returns a string which contains
/// a more detailed description.
///
public delegate string DescriptionProc();
///
/// Delegate to a function that returns a comma seperated list
/// of file extensions the plugin can read or write.
///
public delegate string ExtensionListProc();
///
/// Delegate to a function that returns a regular expression that
/// can be used to idientify whether a file can be handled by the plugin.
///
public delegate string RegExprProc();
///
/// Delegate to a function that opens a file.
///
public delegate IntPtr OpenProc(ref FreeImageIO io, fi_handle handle, bool read);
///
/// Delegate to a function that closes a previosly opened file.
///
public delegate void CloseProc(ref FreeImageIO io, fi_handle handle, IntPtr data);
///
/// Delegate to a function that returns the number of pages of a multipage
/// bitmap if the plugin is capable of handling multipage bitmaps.
///
public delegate int PageCountProc(ref FreeImageIO io, fi_handle handle, IntPtr data);
///
/// UNKNOWN
///
public delegate int PageCapabilityProc(ref FreeImageIO io, fi_handle handle, IntPtr data);
///
/// Delegate to a function that loads and decodes a bitmap into memory.
///
public delegate FIBITMAP LoadProc(ref FreeImageIO io, fi_handle handle, int page, int flags, IntPtr data);
///
/// Delegate to a function that saves a bitmap.
///
public delegate bool SaveProc(ref FreeImageIO io, FIBITMAP dib, fi_handle handle, int page, int flags, IntPtr data);
///
/// Delegate to a function that determines whether the source defined
/// by and is a valid image.
///
public delegate bool ValidateProc(ref FreeImageIO io, fi_handle handle);
///
/// Delegate to a function that returns a string which contains
/// the plugin's mime type.
///
public delegate string MimeProc();
///
/// Delegate to a function that returns whether the plugin can handle the
/// specified color depth.
///
public delegate bool SupportsExportBPPProc(int bpp);
///
/// Delegate to a function that returns whether the plugin can handle the
/// specified image type.
///
public delegate bool SupportsExportTypeProc(FREE_IMAGE_TYPE type);
///
/// Delegate to a function that returns whether the plugin can handle
/// ICC-Profiles.
///
public delegate bool SupportsICCProfilesProc();
///
/// Callback function used by FreeImage to register plugins.
///
public delegate void InitProc(ref Plugin plugin, int format_id);
}