📄 freeimagestaticimports.cs
字号:
/// eg: 0x0000FF</param>
/// <returns>Handle to a FreeImage bitmap.</returns>
[DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Allocate")]
public static extern FIBITMAP Allocate(int width, int height, int bpp,
uint red_mask, uint green_mask, uint blue_mask);
/// <summary>
/// Creates a new bitmap in memory.
/// </summary>
/// <param name="type">Type of the image.</param>
/// <param name="width">Width of the new bitmap.</param>
/// <param name="height">Height of the new bitmap.</param>
/// <param name="bpp">Bit depth of the new Bitmap.
/// Supported pixel depth: 1-, 4-, 8-, 16-, 24-, 32-bit per pixel for standard bitmap</param>
/// <param name="red_mask">Red part of the color layout.
/// eg: 0xFF0000</param>
/// <param name="green_mask">Green part of the color layout.
/// eg: 0x00FF00</param>
/// <param name="blue_mask">Blue part of the color layout.
/// eg: 0x0000FF</param>
/// <returns>Handle to a FreeImage bitmap.</returns>
[DllImport(FreeImageLibrary, EntryPoint = "FreeImage_AllocateT")]
public static extern FIBITMAP AllocateT(FREE_IMAGE_TYPE type, int width, int height, int bpp,
uint red_mask, uint green_mask, uint blue_mask);
/// <summary>
/// Makes an exact reproduction of an existing bitmap, including metadata and attached profile if any.
/// </summary>
/// <param name="dib">Handle to a FreeImage bitmap.</param>
/// <returns>Handle to a FreeImage bitmap.</returns>
[DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Clone")]
public static extern FIBITMAP Clone(FIBITMAP dib);
/// <summary>
/// Deletes a previously loaded FIBITMAP from memory.
/// </summary>
/// <param name="dib">Handle to a FreeImage bitmap.</param>
[DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Unload")]
public static extern void Unload(FIBITMAP dib);
/// <summary>
/// Decodes a bitmap, allocates memory for it and returns it as a FIBITMAP.
/// </summary>
/// <param name="fif">Type of the bitmap.</param>
/// <param name="filename">Name of the file to decode.</param>
/// <param name="flags">Flags to enable or disable plugin-features.</param>
/// <returns>Handle to a FreeImage bitmap.</returns>
[DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_LoadU")]
public static extern FIBITMAP Load(FREE_IMAGE_FORMAT fif, string filename, FREE_IMAGE_LOAD_FLAGS flags);
/// <summary>
/// Decodes a bitmap, allocates memory for it and returns it as a FIBITMAP.
/// The filename supports UNICODE.
/// </summary>
/// <param name="fif">Type of the bitmap.</param>
/// <param name="filename">Name of the file to decode.</param>
/// <param name="flags">Flags to enable or disable plugin-features.</param>
/// <returns>Handle to a FreeImage bitmap.</returns>
[DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_LoadU")]
private static extern FIBITMAP LoadU(FREE_IMAGE_FORMAT fif, string filename, FREE_IMAGE_LOAD_FLAGS flags);
/// <summary>
/// Loads a bitmap from an arbitrary source.
/// </summary>
/// <param name="fif">Type of the bitmap.</param>
/// <param name="io">A FreeImageIO structure with functionpointers to handle the source.</param>
/// <param name="handle">A handle to the source.</param>
/// <param name="flags">Flags to enable or disable plugin-features.</param>
/// <returns>Handle to a FreeImage bitmap.</returns>
[DllImport(FreeImageLibrary, EntryPoint = "FreeImage_LoadFromHandle")]
public static extern FIBITMAP LoadFromHandle(FREE_IMAGE_FORMAT fif, ref FreeImageIO io, fi_handle handle, FREE_IMAGE_LOAD_FLAGS flags);
/// <summary>
/// Saves a previosly loaded FIBITMAP to a file.
/// </summary>
/// <param name="fif">Type of the bitmap.</param>
/// <param name="dib">Handle to a FreeImage bitmap.</param>
/// <param name="filename">Name of the file to save to.</param>
/// <param name="flags">Flags to enable or disable plugin-features.</param>
/// <returns>Returns true on success, false on failure.</returns>
[DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_SaveU")]
public static extern bool Save(FREE_IMAGE_FORMAT fif, FIBITMAP dib, string filename, FREE_IMAGE_SAVE_FLAGS flags);
/// <summary>
/// Saves a previosly loaded FIBITMAP to a file.
/// The filename supports UNICODE.
/// </summary>
/// <param name="fif">Type of the bitmap.</param>
/// <param name="dib">Handle to a FreeImage bitmap.</param>
/// <param name="filename">Name of the file to save to.</param>
/// <param name="flags">Flags to enable or disable plugin-features.</param>
/// <returns>Returns true on success, false on failure.</returns>
[DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_SaveU")]
private static extern bool SaveU(FREE_IMAGE_FORMAT fif, FIBITMAP dib, string filename, FREE_IMAGE_SAVE_FLAGS flags);
/// <summary>
/// Saves a bitmap to an arbitrary source.
/// </summary>
/// <param name="fif">Type of the bitmap.</param>
/// <param name="dib">Handle to a FreeImage bitmap.</param>
/// <param name="io">A FreeImageIO structure with functionpointers to handle the source.</param>
/// <param name="handle">A handle to the source.</param>
/// <param name="flags">Flags to enable or disable plugin-features.</param>
/// <returns>Returns true on success, false on failure.</returns>
[DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SaveToHandle")]
public static extern bool SaveToHandle(FREE_IMAGE_FORMAT fif, FIBITMAP dib, ref FreeImageIO io, fi_handle handle,
FREE_IMAGE_SAVE_FLAGS flags);
#endregion
#region Memory I/O streams
/// <summary>
/// Open a memory stream.
/// </summary>
/// <param name="data">Pointer to the data in memory.</param>
/// <param name="size_in_bytes">Length of the data in byte.</param>
/// <returns>Handle to a memory stream.</returns>
[DllImport(FreeImageLibrary, EntryPoint = "FreeImage_OpenMemory")]
public static extern FIMEMORY OpenMemory(IntPtr data, uint size_in_bytes);
[DllImport(FreeImageLibrary, EntryPoint = "FreeImage_OpenMemory")]
internal static extern FIMEMORY OpenMemoryEx(byte[] data, uint size_in_bytes);
/// <summary>
/// Close and free a memory stream.
/// </summary>
/// <param name="stream">Handle to a memory stream.</param>
[DllImport(FreeImageLibrary, EntryPoint = "FreeImage_CloseMemory")]
public static extern void CloseMemory(FIMEMORY stream);
/// <summary>
/// Decodes a bitmap from a stream, allocates memory for it and returns it as a FIBITMAP.
/// </summary>
/// <param name="fif">Type of the bitmap.</param>
/// <param name="stream">Handle to a memory stream.</param>
/// <param name="flags">Flags to enable or disable plugin-features.</param>
/// <returns>Handle to a FreeImage bitmap.</returns>
[DllImport(FreeImageLibrary, EntryPoint = "FreeImage_LoadFromMemory")]
public static extern FIBITMAP LoadFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY stream, FREE_IMAGE_LOAD_FLAGS flags);
/// <summary>
/// Saves a previosly loaded FIBITMAP to a stream.
/// </summary>
/// <param name="fif">Type of the bitmap.</param>
/// <param name="dib">Handle to a FreeImage bitmap.</param>
/// <param name="stream">Handle to a memory stream.</param>
/// <param name="flags">Flags to enable or disable plugin-features.</param>
/// <returns>Returns true on success, false on failure.</returns>
[DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SaveToMemory")]
public static extern bool SaveToMemory(FREE_IMAGE_FORMAT fif, FIBITMAP dib, FIMEMORY stream, FREE_IMAGE_SAVE_FLAGS flags);
/// <summary>
/// Gets the current position of a memory handle.
/// </summary>
/// <param name="stream">Handle to a memory stream.</param>
/// <returns>The current file position if successful, -1 otherwise.</returns>
[DllImport(FreeImageLibrary, EntryPoint = "FreeImage_TellMemory")]
public static extern int TellMemory(FIMEMORY stream);
/// <summary>
/// Moves the memory handle to a specified location.
/// </summary>
/// <param name="stream">Handle to a memory stream.</param>
/// <param name="offset">Number of bytes from origin.</param>
/// <param name="origin">Initial position.</param>
/// <returns>Returns true on success, false on failure.</returns>
[DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SeekMemory")]
public static extern bool SeekMemory(FIMEMORY stream, int offset, System.IO.SeekOrigin origin);
/// <summary>
/// Provides a direct buffer access to a memory stream.
/// </summary>
/// <param name="stream">The target memory stream.</param>
/// <param name="data">Pointer to the data in memory.</param>
/// <param name="size_in_bytes">Size of the data in bytes.</param>
/// <returns>Returns true on success, false on failure.</returns>
[DllImport(FreeImageLibrary, EntryPoint = "FreeImage_AcquireMemory")]
public static extern bool AcquireMemory(FIMEMORY stream, ref IntPtr data, ref uint size_in_bytes);
/// <summary>
/// Reads data from a memory stream.
/// </summary>
/// <param name="buffer">The buffer to store the data in.</param>
/// <param name="size">Size in bytes of the items.</param>
/// <param name="count">Number of items to read.</param>
/// <param name="stream">The stream to read from.
/// The memory pointer associated with stream is increased by the number of bytes actually read.</param>
/// <returns>The number of full items actually read.
/// May be less than count on error or stream-end.</returns>
[DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ReadMemory")]
public static extern uint ReadMemory(byte[] buffer, uint size, uint count, FIMEMORY stream);
/// <summary>
/// Writes data to a memory stream.
/// </summary>
/// <param name="buffer">The buffer to read the data from.</param>
/// <param name="size">Size in bytes of the items.</param>
/// <param name="count">Number of items to write.</param>
/// <param name="stream">The stream to write to.
/// The memory pointer associated with stream is increased by the number of bytes actually written.</param>
/// <returns>The number of full items actually written.
/// May be less than count on error or stream-end.</returns>
[DllImport(FreeImageLibrary, EntryPoint = "FreeImage_WriteMemory")]
public static extern uint WriteMemory(byte[] buffer, uint size, uint count, FIMEMORY stream);
/// <summary>
/// Open a multi-page bitmap from a memory stream.
/// </summary>
/// <param name="fif">Type of the bitmap.</param>
/// <param name="stream">The stream to decode.</param>
/// <param name="flags">Flags to enable or disable plugin-features.</param>
/// <returns>Handle to a FreeImage multi-paged bitmap.</returns>
[DllImport(FreeImageLibrary, EntryPoint = "FreeImage_LoadMultiBitmapFromMemory")]
public static extern FIMULTIBITMAP LoadMultiBitmapFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY stream, FREE_IMAGE_LOAD_FLAGS flags);
#endregion
#region Plugin functions
/// <summary>
/// Registers a new plugin to be used in FreeImage.
/// </summary>
/// <param name="proc_address">Pointer to the function that initialises the plugin.</param>
/// <param name="format">A string describing the format of the plugin.</param>
/// <param name="description">A string describing the plugin.</param>
/// <param name="extension">A string witha comma sperated list of extensions. f.e: "pl,pl2,pl4"</param>
/// <param name="regexpr">A regular expression used to identify the bitmap.</param>
/// <returns>The format idientifier assigned by FreeImage.</returns>
[DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_RegisterLocalPlugin")]
public static extern FREE_IMAGE_FORMAT RegisterLocalPlugin(InitProc proc_address,
string format, string description, string extension, string regexpr);
/// <summary>
/// Registers a new plugin to be used in FreeImage. The plugin is residing in a DLL.
/// The Init function must be called 揑nit
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -