|
Introduction
FreeImage is an extremely useful Open Source project for reading, manipulating and converting a large amount of graphical formats. However at present the library exists as Win32 Dynamic Link Library. As my latest fascination is C#, I decided to create a simple Interop wrapper for it.
Using the code
The code is very straightforward to use, which is a reflection on the FreeImage implementation itself. For my needs I wanted to be able to take a picture file in Portable Bitmap (PBM) format and convert it to a standard Bitmap (BMP). For this I needed 3 methods exposed via the FreeImage DLL, FreeImage_Load, FreeImage_Save and FreeImage_Unload, the signature for which are: DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Load(FREE_IMAGE_FORMAT fif,
const char *filename, int flags FI_DEFAULT(0));
DLL_API BOOL DLL_CALLCONV FreeImage_Save(FREE_IMAGE_FORMAT fif,
FIBITMAP *dib, const char *filename, int flags FI_DEFAULT(0));
DLL_API void DLL_CALLCONV FreeImage_Unload(FIBITMAP* dib);
Now the C# Interop signatures for these are: public class FreeImage
{
[DllImport("FreeImage.dll")]
public static extern int FreeImage_Load(FIF format,
string filename, int flags);
[DllImport("FreeImage.dll")]
public static extern void FreeImage_Unload(int handle);
[DllImport("FreeImage.dll")]
public static extern bool FreeImage_Save(FIF format,
int handle, string filename, int flags);
}
As an example, to convert a graphical image from PBM to BMP, all you need to do is the following (note the enum FIF is not documented here, but can be found in the source code). namespace Test
{
class MainClass
{
public static void Main(string[] args)
{
int handle = FreeImageAPI.FreeImage.FreeImage_Load(
FreeImageAPI.FIF.FIF_PBM,
@"c:\image.pbm",
0);
FreeImageAPI.FreeImage.FreeImage_Save(
FreeImageAPI.FIF.FIF_BMP,
handle,
@"c:\image.bmp",
0);
FreeImageAPI.FreeImage.FreeImage_Unload(handle);
}
}
}
| You must Sign In to use this message board. |
|
| | Msgs 1 to 25 of 41 (Total in Forum: 41) (Refresh) | FirstPrevNext |
|
|
 |
|
|
i try to compile a c# app for a smartphone (windows mobile 2003 for pocket pc) but i get always following exception: {System.MissingMethodException:MissingMethodException}
It happens at the first hit on FreeImageAPI.FreeImage.FreeImage_Load The Freeimage.dll is in place on the smarthpone. If i run the application locally, the issue doesn't occur. (the image gets loaded and saved perfectly.)
Do i miss something elementary like the freeimage.dll CAN'T run in a compact framework environment on a smartphone?
thanks, - ajs
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I am using wrapper and getting zero file size.
int handle = FreeImageAPI.FreeImage.FreeImage_Load( FreeImageAPI.FIF.FIF_BMP, "c:\\image.bmp", 0);
FreeImageAPI.FreeImage.FreeImage_Save( FreeImageAPI.FIF.FIF_PCX, handle,"c:\\image.pcx", 0);
FreeImageAPI.FreeImage.FreeImage_Unload(handle);
Nataliya
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
The file size is zero, because FreeImage is not able to save pcx files. It can only load them. Check the documentation (http://freeimage.sourceforge.net) to see which formats FreeImage can load and save.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
Hi,
I tried to load an image > 400 MB but resizing fails. With small images it works fine. I guess this is due to the fact that the pointer which the method returns is "uint" type but such large pictures would need a "long" type I'm using the C# wrapper and Version 3.9.1 of FreeImage.
Thanks for your help!
Gerrit
-- Gerrit Horeis
Software Developer CI-Gate Development & Consulting GmbH http://www.ci-gate.de http://www.xira.de http://www.bitbauer.de
|
| Sign In·View Thread·PermaLink | 2.29/5 (4 votes) |
|
|
|
 |
|
|
 |
|
|
I've noticed that none of the Metadata functions have been included. 
I've been trying to add them, but I find it very hard to convert the double pointers correctly.
How can the following function call be translated to C#?
DLL_API FIMETADATA *DLL_CALLCONV FreeImage_FindFirstMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, FITAG **tag);
Thanks for any pointers! (no pun intended :->)
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
I built the .dll using the latest release for C#. (build.bat) I tried to compile the Main.cs (under the test subdirectory) "csc /reference:FreeImageNET.dll Main.cs" but I got the following errors: Main.cs(43,15): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_Load' Main.cs(45,40): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetColorsUsed' Main.cs(47,34): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetBits' Main.cs(49,38): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetScanLine' Main.cs(51,33): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetBPP' Main.cs(53,35): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetWidth' Main.cs(55,36): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetHeight' Main.cs(57,34): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetLine' Main.cs(59,35): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetPitch' Main.cs(61,37): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetDIBSize' Main.cs(64,21): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetPalette' Main.cs(76,43): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetDotsPerMeterX' Main.cs(78,43): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetDotsPerMeterY' Main.cs(80,29): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetInfoHeader' Main.cs(95,21): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetInfo' Main.cs(115,39): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetColorType' Main.cs(117,37): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetRedMask' Main.cs(119,39): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetGreenMask' Main.cs(121,38): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetBlueMask' Main.cs(123,47): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetTransparencyCount' Main.cs(125,47): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetTransparencyTable' Main.cs(128,3): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_SetTransparent' Main.cs(130,40): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_IsTransparent' Main.cs(134,38): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetFileType' Main.cs(138,3): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_ConvertTo8Bits' Main.cs(141,3): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_ConvertTo16Bits555' Main.cs(144,3): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_ConvertTo16Bits565' Main.cs(147,3): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_ConvertTo24Bits' Main.cs(150,3): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_ConvertTo32Bits' Main.cs(153,3): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_ColorQuantize' Main.cs(157,3): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_ConvertFromRawBits' Main.cs(161,3): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_ConvertToRawBits' Main.cs(163,38): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetFIFCount' Main.cs(166,3): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_SetPluginEnabled' Main.cs(168,42): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_IsPluginEnabled' Main.cs(171,22): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetFormatFromFIF' Main.cs(174,43): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetFIFFromFormat' Main.cs(176,41): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetFIFFromMime' Main.cs(178,46): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetFIFExtensionList' Main.cs(180,44): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetFIFDescription' Main.cs(182,40): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetFIFRegExpr' Main.cs(184,45): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_GetFIFFromFilename' Main.cs(186,45): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_FIFSupportsReading' Main.cs(188,45): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_FIFSupportsWriting' Main.cs(190,47): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_FIFSupportsExportBPP' Main.cs(275,3): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_Save' Main.cs(278,3): error CS0117: 'FreeImageAPI.FreeImage' does not contain a definition for 'FreeImage_Unload' I hope you can help Thanks
Amir
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
Hi,
I want to insert images from C# to some specific word document such that each image is to be placed in specific position of diff. page in same word document. Any help would be appreciated.
Thanks in advance, Hiral.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
I have obtained the latest wrapper from freeimage.sourceforge.net.
I have compiled FreeImageNet.dll. I refrenced it. I made sure FreeImage.dll was in the windows/system32 folder and in the folder with the app.
I tried the following code:
public void PNGtoPCX(string PngFile, string PCXFile) { int handle = FreeImageAPI.FreeImage.Load(FreeImageAPI.FIF.FIF_PNG,PngFile,0); FreeImageAPI.FreeImage.Save(FreeImageAPI.FIF.FIF_PCX,handle,PCXFile,FreeImageAPI.LoadSaveFlags.PCX_DEFAULT); }
I get the error: C:\projects\SVGTest\SVG.cs(145): Argument '2': cannot convert from 'int' to 'uint'
I can see from intellisense that the second parameter is supposed to be "unit" but all of the examples show int. It says that it is "unit dib" but other than guessing that it is the file to be converted--or a refrence to it. I have no idea what it is.
Please help.
|
| Sign In·View Thread·PermaLink | 1.50/5 (2 votes) |
|
|
|
 |
|
|
Here is the interrop code I have for the Win32 FreeImage.dll library. As you can see this definition using unsigned int to represent the FIBITMAP object within the C# application. What I suggest is that you remove your reference to FreeImageNet.dll, paste this code into your own class and change you project to reference your interrop class. If your still getting problems then I can only suggest you change the definition or you make sure your using a compatible version of the FreeImage.dll file itself:
using System; using System.IO; using System.Runtime.InteropServices;
namespace FreeImageAPI { using PVOID = IntPtr; using FIBITMAP = UInt32; using FIMULTIBITMAP = UInt32; [StructLayout(LayoutKind.Sequential)] public class RGBQUAD { public byte rgbBlue; public byte rgbGreen; public byte rgbRed; public byte rgbReserved; } [StructLayout(LayoutKind.Sequential)] public class BITMAPINFOHEADER { public uint size; public int width; public int height; public ushort biPlanes; public ushort biBitCount; public uint biCompression; public uint biSizeImage; public int biXPelsPerMeter; public int biYPelsPerMeter; public uint biClrUsed; public uint biClrImportant; }
[StructLayout(LayoutKind.Sequential)] public class BITMAPINFO { public BITMAPINFOHEADER bmiHeader; public RGBQUAD bmiColors; }
public enum FIF { FIF_UNKNOWN = -1, FIF_BMP = 0, FIF_ICO = 1, FIF_JPEG = 2, FIF_JNG = 3, FIF_KOALA = 4, FIF_LBM = 5, FIF_IFF = FIF_LBM, FIF_MNG = 6, FIF_PBM = 7, FIF_PBMRAW = 8, FIF_PCD = 9, FIF_PCX = 10, FIF_PGM = 11, FIF_PGMRAW = 12, FIF_PNG = 13, FIF_PPM = 14, FIF_PPMRAW = 15, FIF_RAS = 16, FIF_TARGA = 17, FIF_TIFF = 18, FIF_WBMP = 19, FIF_PSD = 20, FIF_CUT = 21, FIF_XBM = 22, FIF_XPM = 23, FIF_DDS = 24, FIF_GIF = 25 } public enum FI_QUANTIZE { FIQ_WUQUANT = 0, FIQ_NNQUANT = 1 } public enum FI_DITHER { FID_FS = 0, FID_BAYER4x4 = 1, FID_BAYER8x8 = 2, FID_CLUSTER6x6 = 3, FID_CLUSTER8x8 = 4, FID_CLUSTER16x16= 5 } public enum FI_FILTER { FILTER_BOX = 0, FILTER_BICUBIC = 1, FILTER_BILINEAR = 2, FILTER_BSPLINE = 3, FILTER_CATMULLROM = 4, FILTER_LANCZOS3 = 5 }
public enum FI_COLOR_CHANNEL { FICC_RGB = 0, FICC_RED = 1, FICC_GREEN = 2, FICC_BLUE = 3, FICC_ALPHA = 4, FICC_BLACK = 5 }
public enum FIT // FREE_IMAGE_TYPE { FIT_UNKNOWN = 0, FIT_BITMAP = 1, FIT_UINT16 = 2, FIT_INT16 = 3, FIT_UINT32 = 4, FIT_INT32 = 5, FIT_FLOAT = 6, FIT_DOUBLE = 7, FIT_COMPLEX = 8 }
public delegate void FreeImage_OutputMessageFunction(FIF format, string msg); public class FreeImage { // 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(); // 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(FIT 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(FIF format, string filename, int flags); // missing FIBITMAP FreeImage_LoadFromHandle(FIF fif, // FreeImageIO *io, fi_handle handle, int flags);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_Save")] public static extern bool Save(FIF format, FIBITMAP dib, string filename, int flags); // missing BOOL FreeImage_SaveToHandle(FIF fif, FIBITMAP *dib, // FreeImageIO *io, fi_handle handle, int flags);
// Plugin interface ------------------------------------------- // missing FIF FreeImage_RegisterLocalPlugin(FI_InitProc proc_address, // const char *format, const char *description, // const char *extension, const char *regexpr); // // missing FIF 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(FIF format, bool enabled); [DllImport("FreeImage.dll", EntryPoint="FreeImage_IsPluginEnabled")] public static extern int IsPluginEnabled(FIF format); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetFIFFromFormat")] public static extern FIF GetFIFFromFormat(string format); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetFIFFromMime")] public static extern FIF GetFIFFromMime(string mime); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetFormatFromFIF")] public static extern string GetFormatFromFIF(FIF format); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetFIFExtensionList")] public static extern string GetFIFExtensionList(FIF format); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetFIFDescription")] public static extern string GetFIFDescription(FIF format); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetFIFRegExpr")] public static extern string GetFIFRegExpr(FIF format); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetFIFFromFilename")] public static extern FIF GetFIFFromFilename(string filename); [DllImport("FreeImage.dll", EntryPoint="FreeImage_FIFSupportsReading")] public static extern bool FIFSupportsReading(FIF format); [DllImport("FreeImage.dll", EntryPoint="FreeImage_FIFSupportsWriting")] public static extern bool FIFSupportsWriting(FIF format); [DllImport("FreeImage.dll", EntryPoint="FreeImage_FIFSupportsExportBPP")] public static extern bool FIFSupportsExportBPP(FIF format, int bpp); [DllImport("FreeImage.dll", EntryPoint="FreeImage_FIFSupportsExportType")] public static extern bool FIFSupportsExportType(FIF format, FIT ftype); [DllImport("FreeImage.dll", EntryPoint="FreeImage_FIFSupportsICCProfiles")] public static extern bool FIFSupportsICCProfiles(FIF format, FIT ftype);
// Multipage interface ---------------------------------------- [DllImport("FreeImage.dll", EntryPoint="FreeImage_OpenMultiBitmap")] public static extern FIMULTIBITMAP OpenMultiBitmap( FIF 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")] public static extern void InsertPage(FIMULTIBITMAP bitmap, int page, FIBITMAP data); [DllImport("FreeImage.dll", EntryPoint="FreeImage_DeletePage")] public static extern void DeletePage(FIMULTIBITMAP bitmap, int page); [DllImport("FreeImage.dll", EntryPoint="FreeImage_LockPage")] public static extern FIBITMAP LockPage(FIMULTIBITMAP bitmap, int page); [DllImport("FreeImage.dll", EntryPoint="FreeImage_UnlockPage")] public static extern void UnlockPage(FIMULTIBITMAP bitmap, int page, bool changed); [DllImport("FreeImage.dll", EntryPoint="FreeImage_MovePage")] public static extern bool MovePage(FIMULTIBITMAP bitmap, int target, int source); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetLockedPageNumbers")] public static extern bool GetLockedPageNumbers(FIMULTIBITMAP bitmap, IntPtr pages, IntPtr count); // File type request routines --------------------------------- [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetFileType")] public static extern FIF GetFileType(string filename, int size);
// missing FIF FreeImage_GetFileTypeFromHandle(FreeImageIO *io, // fi_handle handle, int size);
// Image type request routines -------------------------------- [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetImageType")] public static extern FIT GetImageType(FIBITMAP dib);
// Info functions --------------------------------------------- [DllImport("FreeImage.dll", EntryPoint="FreeImage_IsLittleEndian")] public static extern bool IsLittleEndian(); // Pixel access functions ------------------------------------- [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetBits")] public static extern IntPtr GetBits(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetScanLine")] public static extern IntPtr GetScanLine(FIBITMAP dib, int scanline); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetPixelIndex")] public static extern bool GetPixelIndex(FIBITMAP dib, uint x, uint y, byte value); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetColorsUsed")] public static extern uint GetColorsUsed(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetBPP")] public static extern uint GetBPP(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetWidth")] public static extern uint GetWidth(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetHeight")] public static extern uint GetHeight(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetLine")] public static extern uint GetLine(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetPitch")] public static extern uint GetPitch(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetDIBSize")] public static extern uint GetDIBSize(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetPalette")] [return: MarshalAs(UnmanagedType.LPStruct)] public static extern RGBQUAD GetPalette(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetDotsPerMeter")] public static extern uint GetDotsPerMeterX(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetDotsPerMeterY")] public static extern uint GetDotsPerMeterY(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetInfoHeader")] [return: MarshalAs(UnmanagedType.LPStruct)] public static extern BITMAPINFOHEADER GetInfoHeader(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetInfo")] [return: MarshalAs(UnmanagedType.LPStruct)] public static extern BITMAPINFO GetInfo(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetColorType")] public static extern int GetColorType(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetRedMask")] public static extern uint GetRedMask(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetGreenMask")] public static extern uint GetGreenMask(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetBlueMask")] public static extern uint GetBlueMask(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetTransparencyCount")] public static extern uint GetTransparencyCount(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetTransparencyTable")] public static extern IntPtr GetTransparencyTable(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_SetTransparent")] public static extern void SetTransparent(FIBITMAP dib, bool enabled); [DllImport("FreeImage.dll", EntryPoint="FreeImage_IsTransparent")] public static extern bool IsTransparent(FIBITMAP dib);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_ConvertTo8Bits")] public static extern FIBITMAP ConvertTo8Bits(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_ConvertTo16Bits555")] public static extern FIBITMAP ConvertTo16Bits555(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_ConvertTo16Bits565")] public static extern FIBITMAP ConvertTo16Bits565(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_ConvertTo24Bits")] public static extern FIBITMAP ConvertTo24Bits(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_ConvertTo32Bits")] public static extern FIBITMAP ConvertTo32Bits(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="ColorQuantize")] public static extern FIBITMAP ColorQuantize(FIBITMAP dib, FI_QUANTIZE quantize); [DllImport("FreeImage.dll", EntryPoint="FreeImage_Threshold")] public static extern FIBITMAP Threshold(FIBITMAP dib, uint t); [DllImport("FreeImage.dll", EntryPoint="FreeImage_Dither")] public static extern FIBITMAP Dither(FIBITMAP dib, FI_DITHER algorithm); [DllImport("FreeImage.dll", EntryPoint="FreeImage_ConvertFromRawBits")] public static extern FIBITMAP ConvertFromRawBits(byte[] bits, int width, int height, int pitch, uint bpp, uint redMask, uint greenMask, uint blueMask, bool topDown); [DllImport("FreeImage.dll", EntryPoint="FreeImage_ConvertToRawBits")] public static extern void ConvertToRawBits(IntPtr bits, FIBITMAP dib, int pitch, uint bpp, uint redMask, uint greenMask, uint blueMask, bool topDown);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_RotateClassic")] public static extern FIBITMAP RotateClassic(FIBITMAP dib, Double angle); [DllImport("FreeImage.dll", EntryPoint="FreeImage_RotateEx")] public static extern FIBITMAP RotateEx( FIBITMAP dib, Double angle, Double xShift, Double yShift, Double xOrigin, Double yOrigin, bool useMask); [DllImport("FreeImage.dll", EntryPoint="FreeImage_FlipHorizontal")] public static extern bool FlipHorizontal(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_FlipVertical")] public static extern bool FlipVertical(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_Rescale")] public static extern FIBITMAP Rescale(FIBITMAP dib, int dst_width, int dst_height, FI_FILTER filter); [DllImport("FreeImage.dll", EntryPoint="FreeImage_AdjustCurve")] public static extern bool AdjustCurve(FIBITMAP dib, byte[] lut, FI_COLOR_CHANNEL channel); [DllImport("FreeImage.dll", EntryPoint="FreeImage_AdjustGamma")] public static extern bool AdjustGamma(FIBITMAP dib, Double gamma); [DllImport("FreeImage.dll", EntryPoint="FreeImage_AdjustBrightness")] public static extern bool AdjustBrightness(FIBITMAP dib, Double percentage); [DllImport("FreeImage.dll", EntryPoint="FreeImage_AdjustContrast")] public static extern bool AdjustContrast(FIBITMAP dib, Double percentage); [DllImport("FreeImage.dll", EntryPoint="FreeImage_Invert")] public static extern bool Invert(FIBITMAP dib); [DllImport("FreeImage.dll", EntryPoint="FreeImage_GetHistogram")] public static extern bool GetHistogram(FIBITMAP dib, int histo, FI_COLOR_CHANNEL channel);
[DllImport("FreeImage.dll", EntryPoint="FreeImage_GetChannel")] public static extern bool GetChannel(FIBITMAP dib, FI_COLOR_CHANNEL channel); [DllImport("FreeImage.dll", EntryPoint="FreeImage_SetChannel")] public static extern bool SetChannel(FIBITMAP dib, FIBITMAP dib8, FI_COLOR_CHANNEL channel); [DllImport("FreeImage.dll", EntryPoint="FreeImage_Copy")] public static extern FIBITMAP Copy(FIBITMAP dib, int left, int top, int right, int bottom); [DllImport("FreeImage.dll", EntryPoint="FreeImage_Paste")] public static extern bool Paste(FIBITMAP dst, FIBITMAP src, int left, int top, int alpha); } }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
How can I update this wrapper for the last FreeImage (including metatag support)? There is a tool that generete this even if it is not a COM? Thanks, Mik.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Try downloading the source code for the definition of the wrapper class that best matches the FreeImage.dll file you need and then simply make whatever changes you have to.
David
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
i got freeimage.dll, i added the reference "FreeImageAPI"
when i compile the code, i get an error like this
"Unable to load FreeImaged.dll"
i understood freeimage.dll but what is freeimaged.dll?
how can i create it?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
For the interop methods to run correctly you must have the FreeImage.dll file in the same directory as your .exe file.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
you must build the freeimagemapper as release build, or rename the freeimage.dll to freeimaged.dll.
i found this in the constructor of the mapper:
#if (DEBUG) private const string dllName = "FreeImaged.dll"; #else private const string dllName = "FreeImage.dll"; #endif
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 |
|
|
Why do I get the following error: 'Unable to find an entry point named FreeImage_CloseMultiBitmap in DLL FreeImage.dll.' when trying to access CloseMultiBitmap function in FreeImage.dll.
I have used dumpbinGUI.exe to make sure it is there (see below)
Line From dumpbinGUI: 12 C 000294F0 _FreeImage_CloseMultiBitmap@8
Delcaration in .Net: [DllImport("FreeImage.dll")] public static extern void FreeImage_CloseMultiBitmap(int imagefile);
I have successfully accessed FreeImage_Load,FreeImage_Unload,FreeImage_AppendPage
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
there are more parameters to pass through to openmultibitmap! check the documentation and change the declaration in dllimport!!! had the same problem once
|
| Sign In·View Thread·PermaLink | 1.20/5 (2 votes) |
|
|
|
 |
|
|
oh! closemultibitmap .... hmmm check the documentation any way and check if it is the same as in in documentation!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
| | |