📄 freeimageapi.cs
字号:
// ==========================================================
// FreeImage.NET 3
//
// Design and implementation by
// - David Boland (davidboland@vodafone.ie)
//
// Contributors:
// - Andrew S. Townley
//
// 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, FreeImage.FreeImageType 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!
//
// Modified by Sebastian Faltoni <sebastian@dotnetfireball.net>
//
// Modified by Riccardo Marzi <riccardo@dotnetfireball.net>
//
// ==========================================================
using System;
using System.IO;
using System.Runtime.InteropServices;
using Fireball.Drawing;
using Fireball.Win32;
namespace Fireball.Drawing.Internal
{
using PVOID = IntPtr;
using FIBITMAP = Int32;
using FIMULTIBITMAP = Int32;
/* [StructLayout(LayoutKind.Sequential)]
public class FreeImageIO
{
public FI_ReadProc readProc;
public FI_WriteProc writeProc;
public FI_SeekProc seekProc;
public FI_TellProc tellProc;
}
[StructLayout(LayoutKind.Sequential)]
public class FI_Handle
{
public FileStream stream;
}
public delegate void FI_ReadProc(IntPtr buffer, uint size, uint count, IntPtr handle);
public delegate void FI_WriteProc(IntPtr buffer, uint size, uint count, IntPtr handle);
public delegate int FI_SeekProc(IntPtr handle, long offset, int origin);
public delegate int FI_TellProc(IntPtr handle);
*/
internal delegate void FreeImage_OutputMessageFunction(FreeImage.FreeImageFormat format, string msg);
internal class FreeImageApi
{
// Init/Error routines ----------------------------------------
[DllImport("FreeImage.dll", EntryPoint="FreeImage_Initialise")]
public static extern void Initialise(bool loadLocalPluginsOnly);
// alias for Americans :)
[DllImport("FreeImage.dll", EntryPoint="FreeImage_Initialise")]
public static extern void Initialize(bool loadLocalPluginsOnly);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_DeInitialise")]
public static extern void DeInitialise();
// alias for Americians :)
[DllImport("FreeImage.dll", EntryPoint="FreeImage_DeInitialise")]
public static extern void DeInitialize();
[DllImport("FreeImage.dll", EntryPoint = "FreeImage_CloseMemory")]
public static extern void CloseMemory(IntPtr stream);
// Version routines -------------------------------------------
[DllImport("FreeImage.dll", EntryPoint="FreeImage_GetVersion")]
public static extern string GetVersion();
[DllImport("FreeImage.dll", EntryPoint="FreeImage_GetCopyrightMessage")]
public static extern string GetCopyrightMessage();
// Message Output routines ------------------------------------
// missing void FreeImage_OutputMessageProc(int fif,
// const char *fmt, ...);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_SetOutputMessage")]
public static extern void SetOutputMessage(FreeImage_OutputMessageFunction omf);
// Allocate/Clone/Unload routines -----------------------------
[DllImport("FreeImage.dll", EntryPoint="FreeImage_Allocate")]
public static extern FIBITMAP Allocate(int width, int height,
int bpp, uint red_mask, uint green_mask, uint blue_mask);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_AllocateT")]
public static extern FIBITMAP AllocateT(FreeImage.FreeImageType ftype, int width,
int height, int bpp, uint red_mask, uint green_mask,
uint blue_mask);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_Clone")]
public static extern FIBITMAP Clone(FIBITMAP dib);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_Unload")]
public static extern void Unload(FIBITMAP dib);
// Load/Save routines -----------------------------------------
[DllImport("FreeImage.dll", EntryPoint="FreeImage_Load")]
public static extern FIBITMAP Load(FreeImage.FreeImageFormat format, string filename, int flags);
// missing FIBITMAP FreeImage_LoadFromHandle(FreeImage.FreeImageFormat fif,
// FreeImageIO *io, fi_handle handle, int flags);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_Save")]
public static extern bool Save(FreeImage.FreeImageFormat format, FIBITMAP dib, string filename, int flags);
// missing BOOL FreeImage_SaveToHandle(FreeImage.FreeImageFormat fif, FIBITMAP *dib,
// FreeImageIO *io, fi_handle handle, int flags);
// Plugin interface -------------------------------------------
// missing FreeImage.FreeImageFormat FreeImage_RegisterLocalPlugin(FI_InitProc proc_address,
// const char *format, const char *description,
// const char *extension, const char *regexpr);
//
// missing FreeImage.FreeImageFormat FreeImage_RegisterExternalPlugin(const char *path,
// const char *format, const char *description,
// const char *extension, const char *regexpr);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_GetFIFCount")]
public static extern int GetFIFCount();
[DllImport("FreeImage.dll", EntryPoint="FreeImage_SetPluginEnabled")]
public static extern int SetPluginEnabled(FreeImage.FreeImageFormat format, bool enabled);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_IsPluginEnabled")]
public static extern int IsPluginEnabled(FreeImage.FreeImageFormat format);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_GetFIFFromFormat")]
public static extern FreeImage.FreeImageFormat GetFIFFromFormat(string format);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_GetFIFFromMime")]
public static extern FreeImage.FreeImageFormat GetFIFFromMime(string mime);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_GetFormatFromFIF")]
public static extern string GetFormatFromFIF(FreeImage.FreeImageFormat format);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_GetFIFExtensionList")]
public static extern string GetFIFExtensionList(FreeImage.FreeImageFormat format);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_GetFIFDescription")]
public static extern string GetFIFDescription(FreeImage.FreeImageFormat format);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_GetFIFRegExpr")]
public static extern string GetFIFRegExpr(FreeImage.FreeImageFormat format);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_GetFIFFromFilename")]
public static extern FreeImage.FreeImageFormat GetFIFFromFilename([MarshalAs( UnmanagedType.LPStr) ]string filename);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_FIFSupportsReading")]
public static extern bool FIFSupportsReading(FreeImage.FreeImageFormat format);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_FIFSupportsWriting")]
public static extern bool FIFSupportsWriting(FreeImage.FreeImageFormat format);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_FIFSupportsExportBPP")]
public static extern bool FIFSupportsExportBPP(FreeImage.FreeImageFormat format, int bpp);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_FIFSupportsExportType")]
public static extern bool FIFSupportsExportType(FreeImage.FreeImageFormat format, FreeImage.FreeImageType ftype);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_FIFSupportsICCProfiles")]
public static extern bool FIFSupportsICCProfiles(FreeImage.FreeImageFormat format, FreeImage.FreeImageType ftype);
// Multipage interface ----------------------------------------
[DllImport("FreeImage.dll", EntryPoint="FreeImage_OpenMultiBitmap")]
public static extern FIMULTIBITMAP OpenMultiBitmap(
FreeImage.FreeImageFormat format, string filename, bool createNew, bool readOnly, bool keepCacheInMemory);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_CloseMultiBitmap")]
public static extern long CloseMultiBitmap(FIMULTIBITMAP bitmap, int flags);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_GetPageCount")]
public static extern int GetPageCount(FIMULTIBITMAP bitmap);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_AppendPage")]
public static extern void AppendPage(FIMULTIBITMAP bitmap, FIBITMAP data);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_InsertPage")]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -