|
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
|
|
|
|
|
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.
|
|
|
|
|
Is it possible to save an image in grayscale mode from pixelFormat8bpp ?
|
|
|
|
|
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.
|
|
|
|
|
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);
}
}
|
|
|
|
|
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.
|
|
|
|
|
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
|
|
|
|
|
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?
|
|
|
|
|
For the interop methods to run correctly you must have the FreeImage.dll file in the same directory as your .exe file.
|
|
|
|
|
ok, i did it
but the problem is not that
it says, "unable to load freeimaged.dll", not freeimage.dll!
|
|
|
|
|
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
|
|
|
|
|
it drives me crazy
WHERE IS FreeImage.dll
please help me..
|
|
|
|
|
Leoni510
Google is your friend !!!
http://freeimage.sourceforge.net
|
|
|
|
|
Hi, I too saw that the FreeImage.dll is missing.
In these links you will find much better samples and all the files necessary to successfully build and run the FreeImage samples. They are from the actual creator of FreeImage.
The official site is The FreeImage Project[^]
You want the second link and perhaps the third, which is the official documentation.
The important 2nd link is titled Binary distribution includes DLL, linkage LIB, header file, C++, C#, Delphi and VB6 wrappers, and examples.
Download that zip and make sure you right click it, select properties then check the box that is titled Unblock
In that zip is the missing dlls, samples and wrappers for .NET.
It's also important to note you may need to add the FreeImage.dll to your project then right click on FreeImage.dll and select it build properties as Content then Copy If Newer. That will add the FreeImage.dll to your proper place in your project and Visual Studio will indicate to your project that FreeImage.dll is part of the project.
If you have build issues make sure that your project build properties match that of the FreeImage.dll. Example using x64 FreeImage.dll make sure your project build properties are set to x64 as well.
Some also indicated that FreeImage.dll needs to be in Windows\System folder but I didn't find that to be the case. The easiest way is download the official samples (link provided above) from the actual author of freeimage and those should run fine.
|
|
|
|
|
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
|
|
|
|
|
there are more parameters to pass through to openmultibitmap! check the documentation and change the declaration in dllimport!!! had the same problem once
|
|
|
|
|
oh! closemultibitmap .... hmmm check the documentation any way and check if it is the same as in in documentation!
|
|
|
|
|
john_b123 wrote: Line From dumpbinGUI:
12 C 000294F0 _FreeImage_CloseMultiBitmap@8
The '@8' at the end of the function tells you that it needs 8 bytes' worth of parameters. An int is only 4 bytes, so it would seem reasonable to assume that you need another int. Or that the imagefile needs an Int64 (which is doubtful).
According to the documentation of FreeImage 3.80, you need to supply a second int parameter, called flags, which you can default to 0. (C# doesn't support default values).
|
|
|
|
|
Hi everyone,
does anyone of you know how can a pass the DirectDraw BackBuffer to a FIMEMORY structure and the this structure to FIBITMAP?
I'm forced to use DirectX 6.
My code is as follows:
DDSURFACEDESC2 DDSurfaceDesc;
DDSurfaceDesc.dwSize = sizeof(DDSURFACEDESC2);
// Lock the Surface
HRESULT hres = g_pddsBackBuffer->Lock(NULL, &DDSurfaceDesc, DDLOCK_READONLY | DDLOCK_SURFACEMEMORYPTR, NULL);
DWORD dwSurfaceSize = DDSurfaceDesc.dwHeight * DDSurfaceDesc.lPitch;
// Try to pass the Surface to FIMEMORY
FIMEMORY *hmem = FreeImage_OpenMemory(reinterpret_cast<byte*>(DDSurfaceDesc.lpSurface), dwSurfaceSize);
FreeImage_SeekMemory(hmem, 0, SEEK_SET);
FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromMemory(hmem, 0);
// Load the image from the memory stream
FIBITMAP *dib_ = FreeImage_LoadFromMemory(fif, hmem);
...
// Unlock the surface
g_pddsBackBuffer->Unlock(NULL);
// As the Present of new versions
g_pddsPrimary->BltFast(0, 0, g_pddsBackBuffer, NULL, NULL);
My problem is that the "dib_" FIBITMAP is set to NULL after the FreeImage_LoadFromMemory call and I don't know why.
Does anyone have an idea about what is happening?
Any way to solve the problem?
Thank you very much in advance.
Coco
|
|
|
|
|
I'm using C# to try to implement this, but I've got an error message saying "Uable to load DLL (FreeImage.dll).
When I was trying to add an reference to the dll. It said "A reference to .... could not be added. This is not a valid assembly or COM component."
Any idea?
|
|
|
|
|
The FreeImage dll does not expose any COM objects, only Win32 function pointers, and as such you cannot automatically generate the interrop assembly to communicate with it. This is the reason for this article, since I had to manually create the interrop interface myself. To use this wrapper and library all you need to do is make sure FreeImage.dll is available to your application on startup, the simpliest way to do this is place FreeImage.dll in the same directory as your application or to put it into one of the system directories. When you call the FreeImage.NET wrapper functions the runtime will automatically redirect the calls to their Win32 equilivants.;)
David
|
|
|
|
|
Hi there, surely it is possible to display an image loaded with FreeImage in a .NET Application. On the web site there is a section that states how to convert the image into a HBitmap, a HBitmap (IntPtr) is all that is all that is needed to convert it into a .NET bitmap via the Bitmap classes shared method FromHBitmap(IntPtr).
I've tried so many different ways, firstly VB.NET, all I get is 1 black pixel, even if I call CreateDIBitmap with null values and in C# I just get generic errors. Has anyone used the FreeImage library in a .NET application? Surely there must be people out there that have? Thanks for any help!!
|
|
|
|
|
That's what I thought, too. But I haven't tried yet. Perhaps it is really better to convert the image first and then load. although this may take longer than directly displaying it.
Perhaps David Boland can implement an enhancement to System.Drawing.Image class in the future.
I would be one of the first using it, and helping, of course!
----
xasx
|
|
|
|
|
Hi lads,
From what I understand of the FreeImage API the reference you have to the FreeImage object is not a direct reference to your image.
What I'm doing myself is I'm persisting the converted image to disk and then loading it directly using whatever .NET image class I need. This may sound a little drastic but the underlying FreeImage library is written in C and as such is extremely fast.
If you look on the FreeImage OpenSource homepage you'll find a more comprehensive wrapper that I've written, if you feel like making a contribution like an enhancement to the System.Drawing.Image class it would be greatly appreciated
David
|
|
|
|
|
In release 3.0.4 of FreeImage, you will find a sample showing how to draw a FreeImage bitmap in C#, using the enhanced C# Wrapper to the FreeImage DLL.
Check http://freeimage.sourceforge.net/download.html#distributions
and download the "FreeImage DLL" distribution.
Hervé
|
|
|
|
|