Plugin functions

From version 2.1.0 on FreeImage provides a new, simplified interface besides the old style API.

The new API, known as the plugin API, treats bitmap formats and their accompanied loader and saver routines as plugin modules. A new series of functions provides access to these plugins. For example the new functions provide the means to retrieve a list of supported bitmap formats, as well as their descriptions and their possible file extensions. The new API has many advantages over the old one.

For a start the plugin interface will enable FreeImage's hot swap technology: a feature that allows you to compile and link the library only once in your program making instantly profit from bug fixes, newly supported bitmap formats and more without ever recompiling again. Second it opens the way to use plugins. You won't have these advantages when you use the standard API.

Subsections

FreeImage_GetFIFByIndex

FREE_IMAGE_FORMAT FreeImage_GetFIFByIndex(int index);

Returns the needed plugin id in the plugin list. The plugin list is sorted on the format string.

FreeImage_GetFIFCount

int FreeImage_GetFIFCount();

Returns the number of supported bitmap formats.

FreeImage_GetFIFFromFormat

FREE_IMAGE_FORMAT FreeImage_GetFIFFromFormat(const char *format);

Returns the FreeImage format ID for the given format string.

FreeImage_GetFormatFromFIF

const char *FreeImage_GetFormatFromFIF(FREE_IMAGE_FORMAT fif);

Returns a format string for the given FreeImage Format ID.

FreeImage_GetFIFExtensionList

const char *FreeImage_GetFIFExtensionList(FREE_IMAGE_FORMAT fif);

Returns a list of possible file extension for the given FreeImage Format ID. The extension list is a string containing one or more comma separated file extensions.

FreeImage_GetFIFDescription

const char *FreeImage_GetFIFDescription(FREE_IMAGE_FORMAT fif);

Returns a descriptive string for the given FreeImage Format ID.

FreeImage_GetFIFRegExpr

const char *FreeImage_GetFIFRegExpr(FREE_IMAGE_FORMAT fif);

Returns a regular expression for the given FreeImage Format ID, assisting external libraries to identify the bitmap format. Currently FreeImageQt uses this function.

FreeImage_GetFIFFromFilename

FREE_IMAGE_FORMAT FreeImage_GetFIFFromFilename(const char *filename);

Tries to identify a bitmap type by looking at the filename or a file extension. FreeImage_GetFIFFromFilename returns a valid FreeImage Format ID on success and FIF_UNKNOWN on failure.

FreeImage_FIFSupportsReading

BOOL FreeImage_FIFSupportsReading(FREE_IMAGE_FORMAT fif);

Returns true if the plugin belonging to this FreeImage Format ID supports reading, false otherwise.

FreeImage_FIFSupportsWriting

BOOL FreeImage_FIFSupportsWriting(FREE_IMAGE_FORMAT fif);

Returns true if the plugin belonging to this FreeImage Format ID supports writing, false otherwise.

FreeImage_LoadFromHandle

FIBITMAP * FreeImage_LoadFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0));

Loads a bitmap file into a FreeImage bitmap using the specified FreeImageIO struct and fi_handle. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadFromHandle returns NULL.

The fif parameter specifies the desired bitmap format to be loaded. The parameter accepts any valid FreeImage Format ID, such as FIF_BMP or FIF_JPEG, or an integer value obtained from any of the plugin interface functions.

FreeImage_Load

FIBITMAP *DLL_CALLCONV FreeImage_Load(FREE_IMAGE_FORMAT fif, const char *filename, int flags FI_DEFAULT(0));

Loads the bitmap file into a FreeImage bitmap. If the bitmap is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the bitmap couldn't be loaded, FreeImage_Load returns NULL.

FreeImage_SaveToHandle

BOOL FreeImage_SaveToHandle(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0));

Saves the FreeImage DIB to a bitmap file of the given type.

FreeImage_Save

BOOL FreeImage_Save(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, const char *filename, int flags FI_DEFAULT(0));

Saves the FreeImage DIB to a bitmap file of the given type.